Jump to content
  • 0

[Code] Request 1 Check.


Question

Posted

Hello there!!

 

I try to edit one quest and i need 2 check ,

1 check is working fine

is check for pvps , but i dont know how to add the second,

i m unskiled for java and i m searching for hours to find solution but i cant ...

 

as u see in code have check for pvp count,

>=20

i need also 1 check about time to able this quest to be done every 24hours

can u some write me check for time & pvp ?

 

 

 

 

 

def onTalk (self,npc,player):
     htmltext = "<html><body>You are either not carrying out your quest or don't meet the criteria.</body></html>"
     st = player.getQuestState(qn)
     if not st : return htmltext

     npcId = npc.getNpcId()
     id = st.getState()
     Pvp = player.getPvpKills()
     cond = st.getInt("cond")
     if id == CREATED :
         if Pvp>=20 :
             htmltext = "30078-01.htm"
         else:
             htmltext = "<html><body>This quest can only be taken by characters PvP count is more than 200 and higher!</body></html>"
             st.exitQuest(1)

Recommended Posts

  • 0
Posted

So normaly in php & mysql you have "date" and ++

return strtotime(date('Y-m-d H:i:s',time()))-strtotime($lasttime)+3600;

This is example... if you wanna make delay on instance[quest] you need to connect it with database... anyway about pvp restriction.

+		if (_type == SHOUT && activeChar.getPvpKills() < 50 && !activeChar.isGM())
+		{
+			activeChar.sendMessage("You need at least 50 pvp's in order to use shout chat!");
+			return;			
+		}

 

This is restriction for chat, you can modify it as you want.

  • 0
Posted

So normaly in php & mysql you have "date" and ++

return strtotime(date('Y-m-d H:i:s',time()))-strtotime($lasttime)+3600;

This is example... if you wanna make delay on instance[quest] you need to connect it with database... anyway about pvp restriction.

+		if (_type == SHOUT && activeChar.getPvpKills() < 50 && !activeChar.isGM())
+		{
+			activeChar.sendMessage("You need at least 50 pvp's in order to use shout chat!");
+			return;			
+		}

 

This is restriction for chat, you can modify it as you want.

 

 

about pvp check work normal , the only problem that i cant syndax it is time check ..

 

i find some time checks

 

function toStamp($Username,$SiteId)
{
$lasttime=getTime($Username,$SiteId);
return strtotime(date('Y-m-d H:i:s',time()))-strtotime($lasttime)+3600;
}
function showRemain($Username,$SiteId,$DelayTime)
{
$lasttime=getTime($Username,$SiteId);
$pasedtime=strtotime(date('Y-m-d H:i:s',time()))-strtotime($lasttime)+3600;
if($DelayTime[$SiteId]-$pasedtime>0)
{
return (date('H',$DelayTime[$SiteId]-$pasedtime)-1).date(":i:s",($DelayTime[$SiteId]-$pasedtime));
}
else 
{
return 0;

 

 

but i cant fix it for mine..

  • 0
Posted

I found this code at one quest ...

 

def onKill(self,npc,player,isPet):
    npcId = npc.getNpcId()
    if npcId == BUMPALUMP :
        respawnMinDelay = 43200000  * int(Config.RAID_MIN_RESPAWN_MULTIPLIER)
        respawnMaxDelay = 129600000 * int(Config.RAID_MAX_RESPAWN_MULTIPLIER)
        respawn_delay = Rnd.get(respawnMinDelay,respawnMaxDelay)
        self.saveGlobalQuestVar("625_respawn", str(System.currentTimeMillis()+respawn_delay))
        self.startQuestTimer("spawn_npc", respawn_delay, None, None)
        self.cancelQuestTimer("Icicle Emperor Bumbalump has despawned",npc,None)

 

 

is this for Questdelay?

 

 

i edit to

 

 

 npcId = npc.getNpcId()
     id = st.getState()
     delay = player.getQuestState()
     cond = st.getInt("cond")
     if id == CREATED :
         if delay = Rnd.get(43200000) :
         self.saveGlobalQuestVar("341_delay", str(System.currentTimeMillis()+delay))

  • 0
Posted

This kind of delay should be stored on your database, then call it a restrictions with a Boolean like: hasRestriction()  GL

  • 0
Posted

If you want static 24 hours you have to add 24 * 60 * 60 * 1000 to the current time. Atm you use a rnd value.

 

Finally (and use your brain for following), you are saving the value at creation. That's probably wrong. You want to CHECK if timer is currently ok at creation, and SAVE when you end the quest.

 

Once you store the value you have to reuse it. Call back 341_delay and compare with current time, as I told you on PM.

 

PS : verify 341_delay doesn't already exist.

 

To finish (and I repeat myself) :

- you do the quest, it creates it as you haven't any timer.

- you finish the quest, it saves timer (aka current time + 24 static hour).

- you try to do the quest again ; it verifies the timer, if stored time < current time, then it's ok otherwise you're still on reuse.

 

FINALLY SAVEGLOBAL IS USED FOR SINGLE USE, IT CAN'T/SHOULDN'T BE USED TO SAVE SUCH TIMERS, UNTIL YOU CAN MAKE THAT QUEST ONLY ONCE FOR THE WHOLE SERVER PER DAY.

  • 0
Posted

If you want static 24 hours you have to add 24 * 60 * 60 * 1000 to the current time. Atm you use a rnd value.

 

Finally (and use your brain for following), you are saving the value at creation. That's probably wrong. You want to CHECK if timer is currently ok at creation, and SAVE when you end the quest.

 

Once you store the value you have to reuse it. Call back 341_delay and compare with current time, as I told you on PM.

 

PS : verify 341_delay doesn't already exist.

 

To finish (and I repeat myself) :

- you do the quest, it creates it as you haven't any timer.

- you finish the quest, it saves timer (aka current time + 24 static hour).

- you try to do the quest again ; it verifies the timer, if stored time < current time, then it's ok otherwise you're still on reuse.

 

FINALLY SAVEGLOBAL IS USED FOR SINGLE USE, IT CAN'T/SHOULDN'T BE USED TO SAVE SUCH TIMERS, UNTIL YOU CAN MAKE THAT QUEST ONLY ONCE FOR THE WHOLE SERVER PER DAY.

 

Don't waste your time mate, they want the code not the guide

  • 0
Posted

Don't waste your time mate, they want the code not the guide

 

isnt easy to do somthing new with 0 java knowledge.. isnt shame to spent so many hours for this , while i have to much work to do with my server :/

 

anyway i do all time tests i will try to undestand how it works , i m near i hope to find solution for this .

 

  • 0
Posted

Don't waste your time mate, they want the code not the guide

 

What Tryskell mean is that answering 1 person will learn 100...

  • 0
Posted

anyway i thing to add different check , i wanna make some  quests and i cant spend all my time to search for this check ,

 

also my paypall is empty ... thats why i  m asking for help here,

 

 

if some1 wanna write me that check , i can say just thanks.

 

 

 

  • 0
Posted

here is your code...

 

add this on L2PcInstance.java

boolean _canEnterQuest=true;
public boolean canEnterQuest()
{
	return _canEnterQuest;
}
public void removeEnterCooldownAfter24h()
{
	_canEnterQuest=false;
	ThreadPoolManager.getInstance().scheduleGeneral(new removeEnterCoolDown(), 1000*60*60*24);
}
public class removeEnterCoolDown implements Runnable
{
	@Override
	public void run()
	{
		_canEnterQuest=true;
	}
}

anywhere, just dont mess other codes...

then go to your NPC at the checks lines and add

		if (!player.canEnterQuest())
		{
			player.sendMessage("You must wait at least 24 hours since your last taken the quest");
			return;
		}

 

then, when the player enters the quest add these:

 

player.removeEnterCooldownAfter24h();

in order to refresh the cooldown

 

Important: this code, is written on hand, I didnt test but should work. You must add the boolean into your database, no mood for me to code it, neither interlude core files

Secondly, Im not sure that the removeEnterCooldownAfter24h() will work if the player is offline, for this ask someone else Im not sure.

 

mainly I wrote this code in order to guide you on how to work, this is your base, and the last code I do for you since you will never learn if you dont study and try to solve your problems by urself.

 

Cheers xdem

 

  • 0
Posted

here is your code...

 

add this on L2PcInstance.java

....etc

Too dirty... what up with Threadpool if server does a restart? :/

Why not to use

InstanceManager.getInstance().setInstanceTime();
InstanceManager.getInstance().getInstanceTime();

?

  • 0
Posted

Too dirty... what up with Threadpool if server does a restart? :/

Why not to use

InstanceManager.getInstance().setInstanceTime();
InstanceManager.getInstance().getInstanceTime();

?

 

he is interlude, no instances there...

 

The last choice is System.currentMilis(); on the first enter, store in db... then at the checks if previus Milis>currentMilis return; but he will never make it this way, so I considered the first one easier, nvm

Guest
This topic is now closed to further replies.


  • Posts

    • Hi,   I’m reporting @nuturazvan for attempting to scam me out of 70€.   Last week, he contacted me on Discord saying he was looking for a control panel. I initially offered NimeraCP, but after I told him the price, he said he couldn’t afford it. I then told him I could develop a custom control panel within his budget. After discussing the details, we agreed on the following:   Control / Donate Panel includes: Donate page Account registration page Login page Password reset page Stripe integration Agreed price: 70€ Deal date: December 3, 2025   I finished developing the panel on December 6, 2025, but I have not delivered it yet. The code is complete and currently sitting in a private GitHub repository, waiting for payment. As of December 14, 2025, I still haven’t received any payment. I’ve asked him multiple times when I can expect it, and he keeps making excuses, saying a friend owes him money and that he’s waiting to get paid first.   If you don’t have the money, you shouldn’t be ordering work. I take responsibility for starting the work without upfront payment, but that doesn’t excuse repeatedly delaying payment.   Posting this as a warning to others.  
    • WTB GRACIA FINAL INTERFACE
    • Dear partners! At the moment we are in great need of the following positions: — Snapchat old and new accounts | With snapscores | Geo: Europe/USA | Full access via email/phone number — Reddit old (brute or hacked origin, self-registered) accounts with post and comment karma from 100 to 100,000+ | Full email access included — LinkedIn old accounts with real connections | Geo: Europe/USA | Full email access + active 2FA password — Instagram old accounts (2010–2023) | Full email access (possibly with active 2FA password) — Facebook old accounts (2010–2023) | Full email access (possibly with active 2FA password) | With friends or without friends | Geo: Europe/USA/Asia — Threads accounts | Full email access (possibly with active 2FA password) — TikTok/Facebook/Google ADS Agency advertising accounts — Email accounts: mail.ru, yahoo.com, gazeta.pl, gmx.ch / gmx.de / gmx.net (BUT NOT gmx.com) — Google ADS Manual Farm accounts (verified via email and phone number) | GEO: USA/Europe, mostly USA. — WhatsApp OLD Accounts — Twitter accounts with followers and posts (old accounts) Contact us via the details below. We will be glad to cooperate! We are also ready to consider other partnership and collaboration options. Active links to our projects: Digital goods store (Website): Go to Store Telegram bot: Go to – convenient access to the store via the Telegram messenger. Virtual numbers service: Go to Telegram bot for purchasing Telegram Stars: Go to – fast and profitable purchase of Stars in Telegram. SMM Panel: Go to – promotion of your social media accounts. Contacts and support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Dear partners! At the moment we are in great need of the following positions: — Snapchat old and new accounts | With snapscores | Geo: Europe/USA | Full access via email/phone number — Reddit old (brute or hacked origin, self-registered) accounts with post and comment karma from 100 to 100,000+ | Full email access included — LinkedIn old accounts with real connections | Geo: Europe/USA | Full email access + active 2FA password — Instagram old accounts (2010–2023) | Full email access (possibly with active 2FA password) — Facebook old accounts (2010–2023) | Full email access (possibly with active 2FA password) | With friends or without friends | Geo: Europe/USA/Asia — Threads accounts | Full email access (possibly with active 2FA password) — TikTok/Facebook/Google ADS Agency advertising accounts — Email accounts: mail.ru, yahoo.com, gazeta.pl, gmx.ch / gmx.de / gmx.net (BUT NOT gmx.com) — Google ADS Manual Farm accounts (verified via email and phone number) | GEO: USA/Europe, mostly USA. — WhatsApp OLD Accounts — Twitter accounts with followers and posts (old accounts) Contact us via the details below. We will be glad to cooperate! We are also ready to consider other partnership and collaboration options. Active links to our projects: Digital goods store (Website): Go to Store Telegram bot: Go to – convenient access to the store via the Telegram messenger. Virtual numbers service: Go to Telegram bot for purchasing Telegram Stars: Go to – fast and profitable purchase of Stars in Telegram. SMM Panel: Go to – promotion of your social media accounts. Contacts and support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock