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 players ! Meet our project Lineage 2 Hiro Classic ! A low rate classic pvp oriented with many features. No pay to win, RB/AoE, group clan pvp castle etc ...  Dynamic rates, RB Xp 4x and soon massive update with auto farm ! Join now !  https://www.lineage2hiro.com/ Can't wait to see you online !
    • To all first time buyers we give a bonus + 10% of the order. 
    • 🔥 Looking for a powerful, clean, and player-friendly Auction House system for your Lineage 2 server? This fully-featured module is ready to plug into your project and provide your players with a modern, centralized marketplace!   💼 What is it? A complete Auction House system designed for fixed-price item sales between players. Forget about private stores and spammed zones—this system offers a smooth, secure, and offline-friendly way to buy and sell items across your server.   Photo Library: https://imgur.com/a/zLlUQbW   ✅ Main Features: 🔹 Fixed-Price Listings Only: Players list items at a set price. No bidding, no delays—just fast, clean trades. 🔹 Multi-Currency Support: Works with Adena, event coins, custom currencies—fully configurable. 🔹 Dynamic Interface: Players can filter items by name, type, and price. Easy-to-use HTML layout with smooth pagination. 🔹 Sell While Offline: Post items and receive payments even if you're not online—true passive trading. 🔹 Safety First: Full validation: no equipped/augmented/restricted items unless allowed. Prevents scams, mispricing, and listing errors. 🔹 Expiration Timer (Optional): Set listing time limits. Expired items go to warehouse/mail automatically. 🔹 Spam & Duplication Protection: Prevents multiple listings of identical items and unnecessary database load. 🔹 Performance Optimized: Clean, indexed SQL structure. No lag or bloating even with thousands of listings.   ⚙️ Plug & Play Clean Java code (compatible with aCis & derivatives). Easy setup with full instructions and sample configurations. Includes SQL, HTML files, and all Java classes – fully working out of the box.   💰 Pricing & Contact 📦 50 euro - One-time purchase with full support for setup & basic customization. 💬 Contact me here via PM or on Discord: @Luminous 🔐 Serious buyers only – source is clean, secure, and tested on live servers.     Give your server the next-level economy it deserves. No more chaotic trade zones. No more confusion. Just clean, efficient, server-wide trading.
    • We are certainly not an ambulance, but we will definitely cure you of blacklists and empty pockets. Live freely with SX! Each of you will receive a trial version of SX to familiarize yourself with the product, all you have to do is post in this thread
  • Topics

×
×
  • Create New...