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

    • Short version: took Vanganth's classic Interlude pack as the starting point and rebuilt the rest on top of the Classic Secret of Empire client (protocol 166).   Stuff that got reworked, but not limited to: The AI is the one I'm proudest of. ~600 individual NPC behavior scripts, all parsed and verified against retail. Aggro range, follow logic, target switching, idle pattern, social actions. All behaving the way they do on the official server, not the way "close enough" L2J packs usually do. ~2,5k skills loaded, full enchant tree, soul crystal absorption rules. Every formula in Formulas.java and StatFunctions.java got rewritten to match retail. Geodata is not excluded. NPCs/spawns, 6k+ templates, 28k+ spawns, all raid bosses, all the standard event content (Olympiad, Seven Signs with Festival of Darkness, Castle Sieges, Clan Hall stuff, Fortress sieges, Dimensional Rift, Four Sepulchers, Cardiff Invasion). all quest scripts. The engine itself runs both Interlude (protocol 740–770) and Secret of Empire (166) off the same codebase, opcode-mapped. The thing I want to be clear about: this is as close to PTS as L2J realistically gets. Most, not all, L2J packs out there have approximated formulas, stub AI, patchy geodata, hardcoded raid scripts. We didn't take that route.   When can you actually play it:   Server most likely opens next year. If I get more dev time over the coming months a beta by end of this year is realistic, possibly earlier. No promises, depends on how much time I can put in.   The server is already playable since the most important work is done. So if you'd like to collaborate, you'll be able to test it fairly soon. The server files are really good. You might even want to use them for your own server if we decide to go that route.   Server tiers being considered: Low-rate retail - the flagship, most likely first server. Strict PTS. Mid-to-high rate, minimal customs - almost certainly happening as a second server. More accessible but the engine integrity stays. Old L2Finest pride-style (high-rate, heavy customs, the original flavor some of you remember) - very low chance and definitely not soon. It's on the list but well behind the first two.   That's where we are. More updates as open beta gets closer.
    • Maybe some NPC is causing the problem for you, if you don't have a custom map, keep a backup of the database and remove the npc 1-1 to see where the problem is coming from. A custom npc is probably the problem. I had this problem before and searched a lot to find it.
    • 🔥 L2 REDMOON – INTERLUDE 🔥 🆕 Newly opened – Full players joining!   🌐 Discord: https://discord.gg/5PvP5BrGg 💬 Website: https://L2Redmoon.com   ⚔️ Progressive Server • Classic • No Pay To Win   📊 Stage System (Progressive): 🔹 Stage 1: Lv 1–42 | XP x3 | 2 weeks 🔹 Stage 2: Lv 43–60 | XP x4 | 2 weeks 🔹 Stage 3: Lv 61–75 | XP x5 | 10 days 🔹 Endgame: Lv 75–80 | XP x10   💰 General Rates: 💰 Adena x8 💎 Spoil x3 📦 Drop x3 📜 Quest x3   🚫 NO PAY TO WIN ⭐ Premium +30% (Optional) 🛡️ Safe +3 ⚔️ Max +16   🏆 Auto reward max for clans   🔥 ENDGAME – Final competitive phase   @everyone
    • @SkyLordwhats so funny nigga
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..