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.


  • Posts

    • Can't find you on discord ,can you share your discord profile here?
    • Hello lovely community, When you talk, about trust first of all I want you to stay and think for a second. - If was not a trusted person why I would even share this information? (seriously not a single reason) - I did not share any information about how this happened, and which company had the vulnurability (the issue has been fixed from their side and they was very helpful and took quick action + our dev as expert took that quick action) I also want warmly thank abusix.com for providing detailed information (not going to share the whole email for obivious reasons) Mentioning  - So lets clarify now what to except from the project. We have different different protocols and 2 engines. But first we are going to start with Interlude Mastered which is going to be a modern engine but a familiar one. Secondary project will be with the latest engine UE however this one needs allot of work is not that easy it takes time(so we will have it soon as is ready) I got to agree with Seamless, Good project are developed quietly. Also we have already clarified that the servers that we are working are under development how is possible guys to give you detailed information about something that is not finished yet? The topic opened on General Discussion Instead of  Private Servers for a reason. Some of you already have serves in this topic please and none of you have approach they way i do and be open for your own servers unless you have it ready until now so please.... atleast I'm taking a step and I'm pretty much open to share information with everyone. Once everything is ready Server information and everything will be shared in the topic: Private servers. Thanks in advance.  
    • Boost your connection speed and secure your privacy today!  Official Website: https://novproxy.com?kwd=tt-max
    • Good projects are developed quietly and launched only when they are ready to maintain a consistent online presence and build a community. The formula is simple, yet people keep making the same mistakes.   Start with an alpha phase and keep access limited. Since the author claims to already have an inner circle, use that group for early testing. Then open a closed beta through invitation keys or a similar system. Later, announce an open beta.   During these early stages, do not accept donations, partnerships, or other forms of support. Focus entirely on improving the project. Once it is stable, announce it and continue maintaining it regardless of the maximum number of users on
    • in best case this project will open with 100 ppl
  • 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..