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

    • Dear partners! At the moment we are in great need of the following positions: — Snapchat old and new accounts | With snapscores | Geo: Europe/USA | Full access via email/phone number — Reddit old (brute or hacked origin, self-registered) accounts with post and comment karma from 100 to 100,000+ | Full email access included — LinkedIn old accounts with real connections | Geo: Europe/USA | Full email access + active 2FA password — Instagram old accounts (2010–2023) | Full email access (possibly with active 2FA password) — Facebook old accounts (2010–2023) | Full email access (possibly with active 2FA password) | With friends or without friends | Geo: Europe/USA/Asia — Threads accounts | Full email access (possibly with active 2FA password) — TikTok/Facebook/Google ADS Agency advertising accounts — Email accounts: mail.ru, yahoo.com, gazeta.pl, gmx.ch / gmx.de / gmx.net (BUT NOT gmx.com) — Google ADS Manual Farm accounts (verified via email and phone number) | GEO: USA/Europe, mostly USA. — WhatsApp OLD Accounts — Twitter accounts with followers and posts (old accounts) Contact us via the details below. We will be glad to cooperate! We are also ready to consider other partnership and collaboration options. Active links to our projects: Digital goods store (Website): Go to Store Telegram bot: Go to – convenient access to the store via the Telegram messenger. Virtual numbers service: Go to Telegram bot for purchasing Telegram Stars: Go to – fast and profitable purchase of Stars in Telegram. SMM Panel: Go to – promotion of your social media accounts. Contacts and support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Dear partners! At the moment we are in great need of the following positions: — Snapchat old and new accounts | With snapscores | Geo: Europe/USA | Full access via email/phone number — Reddit old (brute or hacked origin, self-registered) accounts with post and comment karma from 100 to 100,000+ | Full email access included — LinkedIn old accounts with real connections | Geo: Europe/USA | Full email access + active 2FA password — Instagram old accounts (2010–2023) | Full email access (possibly with active 2FA password) — Facebook old accounts (2010–2023) | Full email access (possibly with active 2FA password) | With friends or without friends | Geo: Europe/USA/Asia — Threads accounts | Full email access (possibly with active 2FA password) — TikTok/Facebook/Google ADS Agency advertising accounts — Email accounts: mail.ru, yahoo.com, gazeta.pl, gmx.ch / gmx.de / gmx.net (BUT NOT gmx.com) — Google ADS Manual Farm accounts (verified via email and phone number) | GEO: USA/Europe, mostly USA. — WhatsApp OLD Accounts — Twitter accounts with followers and posts (old accounts) Contact us via the details below. We will be glad to cooperate! We are also ready to consider other partnership and collaboration options. Active links to our projects: Digital goods store (Website): Go to Store Telegram bot: Go to – convenient access to the store via the Telegram messenger. Virtual numbers service: Go to Telegram bot for purchasing Telegram Stars: Go to – fast and profitable purchase of Stars in Telegram. SMM Panel: Go to – promotion of your social media accounts. Contacts and support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • 冬天是享受优惠、省钱的好时机。 首次下单时使用促销码 SOCNET 即可获得 15% 折扣 ,适用于全场商品! 前往商店(网站) 前往商店(Telegram 机器人)
    • Winter is the time to save with benefits. Activate the promo code SOCNET on your first order and get a 15% discount on the entire assortment! Go to the store (website) Go to the store (Telegram bot)
    • Winter is the time to save with benefits. Activate the promo code SOCNET on your first order and get a 15% discount on the entire assortment! Go to the store (website) Go to the store (Telegram bot)
  • 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