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

    • L2 Kings    Stage 1 – The Awakening Dynasty and Moirai Level Cap: 83 Gear: Dynasty -Moirai & Weapons (Shop for Adena + Drop from mobs/instances ) Masterwork System: Available (Neolithics S required with neolithics u can do armor parts foundation aswell) Class Cloaks: Level 1 - Masterwork sets such us moirai/dynasty stats are boosted also vesper(stage 2) Olf T-Shirt: +6 (fails don’t reset) safe is +2 Dolls: Level 1 Belts: Low & Medium Enchant: Safe +3 / Max +8 / Attribution Easy in Moirai-Dynasty . Main Zones: Varka Outpost: Easy farm, Adena, EXP for new players = > 80- 100kk hour Dragon Valley: Main farm zone — , 100–120kk/hour Weapon Weakness System active (all classes can farm efficiently) Archers get vampiric auto-hits vs mobs Dragon Valley Center: Main Party Zone — boosted drops (Blessed enchants, Neolithics chance) => farm like 150-200kk per hour. Dragon Valley North: Spoil Zone (Asofe + crafting materials for MW) Primeval Isle: Safe autofarm zone (low adena for casual players) ==> 50kk per hour Forge of the Gods & Imperial Tomb: Available from Stage 1 (lower Adena reward in compare with Dragon Valley) Hellbound also avaliable from stage 1 In few words all zones opened but MAIN farm zone with boosted adena and drops is Dragon valley also has more mobs Instances: Zaken (24h Reuse) → Instead of Vespers drop Moirai , 100% chance to drop 1 of 9 dolls lvl 1, Zaken 7-Day Jewelry Raid Bosses (7 RBs): Drop Moirai Parts + Neolithic S grade instead of Vespers parts that has 7 Rb Quest give Icarus Weapons Special Feature 7rb bosses level up soul crystals aswell. Closed Areas : Monaster of SIlence, LOA, ( It wont have mobs) / Mahum Quest/Lizardmen off) Grand Epics: Unlocked on Day 4 of Stage 1 → Antharas, Valakas, Baium, AQ, etc ================================================================================= Stage 2 – Rise of Vespers Level Cap: 85 Gear: Moirai Armors (Adena GM SHOP / Craft/ Drop) Weapons: Icarus Cloaks: Level 2 Olf: +8 Dolls: Level 2 Belts: High & Top Enchant: Safe +3 / Max +8 Masterwork can be with Neolithics S84 aswell but higher so craft will be usefull aswell. 7 Raid Boss Quest Updated: Now works retail give vesper weapons 7rb Bosses Drops : Vespers Instances: Zaken : Drops to retail vespers + the dolls and the extra items that we added on stage 1 New Freya Instance: Added — drops vespers and instead of mid s84 weapons will drop vespers . Extra drops Blessed Bottle of Freya - drops 100% chance 1 of 9 dolls. Farm Areas Dragon Valley remains main farm New Zone : Lair of Antharas (mobs nerfed and added drop Noble stone so solo players can farm too) New Party Zone : LOA Circle   ============================================================================   Stage 3 – The Vorpal ERA Gear: Vorpal Unclock Cloaks: Level 3 Olf: +10 (max cap) Dolls: Level 3 Enchant: Safe +3 / Max +12 Farm Zones : Dragon Valley Center Scorpions becomes a normal solo zone (no longer party zone) Drops:   LOA & Knorik → Mid Weapons avaliable in drop New Party Zone Kariks Instances: Easy Freya Drops Mid Weapons Frintezza Release =================================================================================     Stage 4 – Elegia Era (Final Stage) Elegia Unlock Gear: Elegia Weapons: Elegia TOP s84 ( farmed via H-Freya/ Drops ) Cloaks: Level 5 Dolls: Level 3 (final bonuses) Enchant: Safe +6 / Max +16 Instances: Hard Freya → Drops Elegia Weapons + => The Instance will drop 2-3 parts for sure and also will be able to Join with 7 people . Party Zone will have also drop chances for elegia armor parts and weapons but small   Events (Hourly): Win: 50 Event Medals + 3 GCM + morewards Lose: 25 Medals + 1 GCM + more rewards Tie: 30 Medals + 2 GCM + more rewards   ================================================================================ Epic Fragments Currency Participating in Daily Bosses mass rewarding all players Participating in Instances (zaken freya frintezza etc) all players get reward ================================================================================ Adena - Main server currency (all items in gm shop require adena ) Event Medals (Festival Adena) - Event shop currency Donation coins you can buy with them dressme,cosmetics and premium account Epic Fragments you can buy with them fake epic jewels Olympiad Tokens you can buy many items from olympiad shop (Hero Coin even items that are on next stages) Olympiad Win = 1000 Tokens / Lose = 500 Tokens ================================================================================= Offline Autofarm Allows limited Offline farming requires offline autofarm ticket that you get by voting etc ================================================================================= Grand Epics have Specific Custom NPC that can spawn Epics EU/LATIN TIME ZONE ================================================================================= First Olympiad Day 19 December First Heroes 22 December ( 21 December Last day of 1st Period) After that olympiad will be weekly. ================================================================================= Item price and economy Since adena is main coin of server and NOT donation coins we will always add new items in gm shop with adena in order to burn the adena of server and not be inflation . =================================================================================        
    • Hello, I'd like to change a title color for custom npc.  I created custom NPC, cloned existing. I put unique id for it in npcname-e, npcgrp and database. I have "0" to serverSideName in db, so that it would use npcname-e, but instead it has "NoNameNPC"and no title color change.
    • Trusted Guy 100% ,  I asked him for some work and he did it right away.
  • 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