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

Here is the current quest and pvp i change pvp check i try to add time check also but always

i get errors on my gameserver :/

 

class Quest (JQuest) :

def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)

def onEvent (self,event,st) :
     htmltext = event
     if event == "30078-02.htm" :
        st.setState(STARTED)
        st.set("cond","1")
        st.playSound("ItemSound.quest_accept")
     return htmltext

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>=150 and Pvp<=400 :
             htmltext = "30078-01.htm"
         else:
             htmltext = "<html><body>This quest can only be taken by characters PvP count is more than 150 and up to 400!</body></html>"
             st.exitQuest(1)
     elif cond==1 :
         if st.getQuestItemsCount(BOX_OF_COOKIES)>=20 :
            htmltext = "30078-04.htm"
            st.giveItems(FARM_COIN,3000)
            st.takeItems(BOX_OF_COOKIES,-1)
            st.playSound("ItemSound.quest_finish")
            st.exitQuest(1)
         else :
            htmltext = "30078-03.htm"
     return htmltext

 

i add it here

class Quest (JQuest) :

def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)

def onEvent (self,event,st) :
     htmltext = event
     if event == "30078-02.htm" :
        st.setState(STARTED)
        st.set("cond","1")
        st.playSound("ItemSound.quest_accept")
     	player.removeEnterCooldownAfter24h();
 return htmltext

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>=150 and Pvp<=400 and  :
             htmltext = "30078-01.htm"
         else:
             htmltext = "<html><body>This quest can only be taken by characters PvP count is more than 150 and up to 400!</body></html>"
             st.exitQuest(1)
    			if (!player.canEnterQuest())
		{
			player.sendMessage("You must wait at least 24 hours since your last taken the quest");
			return;
		}
elif cond==1 :
         if st.getQuestItemsCount(BOX_OF_COOKIES)>=20 :
            htmltext = "30078-04.htm"
            st.giveItems(FARM_COIN,3000)
            st.takeItems(BOX_OF_COOKIES,-1)
            st.playSound("ItemSound.quest_finish")
            st.exitQuest(1)
         else :
            htmltext = "30078-03.htm"
     return htmltext

 

  • 0
Posted

Timer can't be kept on quests variables, because if the player removes the quest, variable is dropped.

 

The task as xdem said is pointless, a server restart and you lose information. And the code on L2PcInstance is totally useless to say the least...

 

Easier is, if you got numerous quests following that scheme, to add L2J system about daily quests (kamaloka and such).

 

It can be saved on ServerVariables, if you got such a thing on L2JFrozen. Each variablecould be QXXX_objId, with timer as value. If you haven't any daily system, and don't want to, that's your only possibility.

  • 0
Posted

Timer can't be kept on quests variables, because if the player removes the quest, variable is dropped.

 

The task as xdem said is pointless, a server restart and you lose information. And the code on L2PcInstance is totally useless to say the least...

 

Easier is, if you got numerous quests following that scheme, to add L2J system about daily quests (kamaloka and such).

 

It can be saved on ServerVariables, if you got such a thing on L2JFrozen. Each variablecould be QXXX_objId, with timer as value. If you haven't any daily system, and don't want to, that's your only possibility.

 

 

so its really difficult to code this.. and work normaly , i mean save time when player go out and when server do restart..

i have read the most quests.. no1 have something like this..

 

 

maybe if i find money to pay some1 to do it :/

  • 0
Posted

 

so its really difficult to code this.. and work normaly , i mean save time when player go out and when server do restart..

i have read the most quests.. no1 have something like this..

 

 

maybe if i find money to pay some1 to do it :/

 

fss its not, the simpliest way is, add column at characters.sql named "QuestTimer" with default 0,

then its simple, at the checks check if QuestTimer<currentTimeMilis() return;

else we store the currenttimeMilis at questTimer, and start the quest... I think its simple now

  • 0
Posted

 

so its really difficult to code this.. and work normaly , i mean save time when player go out and when server do restart..

i have read the most quests.. no1 have something like this..

 

 

maybe if i find money to pay some1 to do it :/

Overall that's 5-7 lines of code in your script. But continue to say it's difficult.

 

On L2JFrozen, deleteGlobalQuestVar / saveGlobalQuestVar(

  • 0
Posted

Overall that's 5-7 lines of code in your script. But continue to say it's difficult.

 

On L2JFrozen, deleteGlobalQuestVar / saveGlobalQuestVar(

 

whats the reason to mess with all those stuff? simply

on characters.sql save t0 with default 0

long t0=CurrentTimeMilis(); //the first enter of the player, then store it

then when the player requests again to to the quest we do again

long t1=currentTimeMilis();

and then is t0>t1? if yes return; sendMessage("try again tomorow")

this way you can send as message in how many minutes they can try again with a simple mod...

  • 0
Posted

Your stuff is most boring than mine, for real. All stuff is existing, why are you creating even more mess ?

 

I just said you had to add 5 lines of codes, how many lines will you add ? You have to edit characters table, create new methods and variables, and so on. I add strictly nothing.

 

I don't even say it's really specialized to that unique task, so reusability = 0.

  • 0
Posted

Your stuff is most boring than mine, for real. All stuff is existing, why are you creating even more mess ?

 

I just said you had to add 5 lines of codes, how many lines will you add ? You have to edit characters table, create new methods and variables, and so on. I add strictly nothing.

 

I don't even say it's really specialized to that unique task, so reusability = 0.

 

I gave a general answer to his problem, its the basic code for such situations, now for all that crap quest variables etc etc, I rly dont care for what is already iplemented on every pack, especialy a random revision of jfrozen, for me I would code it from scratch, so I could fully control the code, and for that 2 miliseconds or the 0.0000001 additional memory than your code I rly dont give a damn,lol :/

  • 0
Posted

I gave a general answer to his problem, its the basic code for such situations, now for all that crap quest variables etc etc, I rly dont care for what is already iplemented on every pack, especialy a random revision of jfrozen, for me I would code it from scratch, so I could fully control the code, and for that 2 miliseconds or the 0.0000001 additional memory than your code I rly dont give a damn,lol :/

I simply hope you aren't a real developer then. I'm not a pro, but that's the least to do when you code. Make code simplier for, in future, when you or someone has to edit it, understand what you did.

 

And it's not a general answer, that code is usable only for that particular case. As I said, no reusability. It's really important in a project. And as said Wyatt, it's also wrong approach.

 

L2PcInstance isn't a solution for all, but that's basic rule in MxC. There is a globalvariables system, with db table and associated methods. That's all, you're free to create one system per quest if you want. That's not my deving philosophy.

  • 0
Posted

I simply hope you aren't a real developer then. I'm not a pro, but that's the least to do when you code. Make code simplier for, in future, when you or someone has to edit it, understand what you did.

 

And it's not a general answer, that code is usable only for that particular case. As I said, no reusability. It's really important in a project. And as said Wyatt, it's also wrong approach.

 

L2PcInstance isn't a solution for all, but that's basic rule in MxC. There is a globalvariables system, with db table and associated methods. That's all, you're free to create one system per quest if you want. That's not my deving philosophy.

 

my global variables work as they should, but you still cant understand that he hasnt it, I dont know if its diffrent on interlude, I dont work with interlude

Guest
This topic is now closed to further replies.


×
×
  • Create New...