Zetsu 78 Posted June 19, 2014 Share Posted June 19, 2014 Hello, I want to show you a new guide to make a communication between quest and client. Nowdays we can use game source..bla bla... but if you don't want/don't know how to compyle it, you can use this version (old and good ). So, let's begin: ### Send informations to client Spoiler For quest, we have a command... very simple to use and known by everybody(i guess, haha). quest communication_test begin -- QUEST NAME MUST BE communication_test.quest !!! state start begin when login begin local number = 5 cmdchat("command_name " .. number ) -- So, we'll find 'command_name' in client, in game.py. This is very important, so use a good name...Check if it doesn't exist end end end For client we have to add in game.py this: Look for: def __ServerCommand_Build(self): serverCommandList={ Add under this: "command_name" : self.command_name_python, Now we must create the function in python with name command_name_python or everything you used.. Be careful! You must align text(functions..etc) with TAB key space. ### Start a quest from client (for buttons sometimes...) Spoiler The quest looks like this: quest communication_test begin -- QUEST NAME MUST BE communication_test.quest !!! state start begin when login begin cmdchat("quest_name_index "..q.getcurrentquestindex()) --- this command send quest index to client, you'll see now why is important end when button or info begin say("Zetsu: It works! Quest is active.") end end end For client we have to add in game.py this: Look for: def __ServerCommand_Build(self): serverCommandList={ Add under this: "quest_name_index" : self.YOuCanUseAnyName, Now, create a function which must looks like: def YOuCanUseAnyName(self, questindex): constInfo.QUESTNAMEINDEX = questindex # you can use int(questindex) but in special cases Before the most important thing, we must open constInfo.py and add: QUESTNAMEINDEX = 0 Without any space in front! Now, everywhere in python you can use this function: def FunctionName(self): import event import constInfo event.QuestButtonClick(int(constInfo.QUESTNAMEINDEX)) Especially for buttons...But you can use it anyway. Don't make this function to be started by quest, cause you will get a "loop", so quest will be actived for infinite times(now it depends how did you code it). ### Get a variable from client (now for 34 & 40k update) Spoiler This trick is very important and you must read all the steps carefuly Quest looks like: quest communication_test begin -- QUEST NAME MUST BE communication_test.quest !!! state start begin when login begin cmdchat("quest_name_index "..q.getcurrentquestindex()) end function GetFromClient() cmdchat("init_getInfo") local variables = input(cmdchat("getInfo")) cmdchat("ignore_getInfo") return variables end when button or info begin local things = communication_test.GetFromClient() say(things) -- you can convert it with tonumber("") tostring(0) end end end For client we have to add in game.py this: Look for: def __ServerCommand_Build(self): serverCommandList={ Add under this: "init_getInfo" : self.InitTutorialGetInfo, "getInfo" : self.GetInfoTutByZetsu, "ignore_getInfo" : self.IgnoreTutorialGetInfo, We should start with constInfo. Add these cariables: IGNORE_GETINFO = 0INFORMATION_TO_SEND = "m2dev-tutByZetsu" Now, we move to interfacemodule.py ########################## For 34k+ versions you have: ######## def OpenQuestWindow(self, skin, idx): wnds = () q = uiQuest.QuestDialog(skin, idx) q.SetWindowName("QuestWindow" + str(idx)) q.Show() if skin: q.Lock() wnds = self.__HideWindows() # UNKNOWN_UPDATE q.AddOnDoneEvent(lambda tmp_self, args=wnds: self.__ShowWindows(args)) # END_OF_UNKNOWN_UPDATE if skin: q.AddOnCloseEvent(q.Unlock) q.AddOnCloseEvent(lambda s = self, qw = q: s.__dict__.__getitem__("wndQuestWindow").remove(qw)) # UNKNOWN_UPDATE self.wndQuestWindow.append(q) # END_OF_UNKNOWN_UPDATE Replace it with: def OpenQuestWindow(self, skin, idx): chat.AppendChat(chat.CHAT_TYPE_INFO, str(constInfo.WOD_IGNORE)) if constInfo.IGNORE_GETINFO == 1: # You see :D constInfo variable which stop/start quest window return else: wnds = () q = uiQuest.QuestDialog(skin, idx) q.SetWindowName("QuestWindow" + str(idx)) q.Show() if skin: q.Lock() wnds = self.__HideWindows() # UNKNOWN_UPDATE q.AddOnDoneEvent(lambda tmp_self, args=wnds: self.__ShowWindows(args)) # END_OF_UNKNOWN_UPDATE if skin: q.AddOnCloseEvent(q.Unlock) q.AddOnCloseEvent(lambda s = self, qw = q: s.__dict__.__getitem__("wndQuestWindow").remove(qw)) # UNKNOWN_UPDATE self.wndQuestWindow.append(q) # END_OF_UNKNOWN_UPDATE #########################For lower versions: ######## -Open uiquest.py search: def __init__(self,skin,idx): Under this add: import constInfo if constInfo.IGNORE_GETINFO == 1: return ######################### Lower Version steps end ######## And finally for game.py we have to create these functions: def InitTutorialGetInfo(self): constInfo.IGNORE_GETINFO = 1 def IgnoreTutorialGetInfo(self): constInfo.IGNORE_GETINFO = 0 def GetInfoTutByZetsu(self): #import net # if you work out of game.py (so delete first # if your script doesn't contain "import net") net.SendQuestInputStringPacket(str(constInfo.INFORMATION_TO_SEND)) # or any information/variable from any module/file If you add functions at the end of the game.py don't forget that any PY file have the last line empty! ### Send multiple informations to client once Spoiler The same as we have done at "Send informations to client" but you will use this: local var1 = 32 local var2 = "zts" local var3 = "m2dev" cmdchat("function_name "..var1.."|"..var2.."|"..var3) In the client, the same function,but to get variables you will use something like this: vararray= fromserver.split("|") # fromserver will be "32|zts|m2dev" #for var1: constInfo.VAR_1 = vararray[0] #for var2: constInfo.VAR_2 = vararray[1] #and for var3: constInfo.VAR_3 = vararray[2] Kind regards and i hope you understood me! Sorry for mistakes. 2 17 Link to comment Share on other sites More sharing options...
Sober 37 Posted June 19, 2014 Share Posted June 19, 2014 You are just God! This is good for newbies learning python Link to comment Share on other sites More sharing options...
Premium Galet 510 Posted June 19, 2014 Premium Share Posted June 19, 2014 Thanks you dude, marvellous Link to comment Share on other sites More sharing options...
Zetsu 78 Posted June 19, 2014 Author Share Posted June 19, 2014 Thanks! It's something simple, anyway... Link to comment Share on other sites More sharing options...
Hylight 2 Posted July 10, 2014 Share Posted July 10, 2014 dont work for me and i dont now why :/ can anyone help me? syserr.txt 0711 19:14:16289 :: Unknown Server Command quest_name_index 258 | quest_name_index Link to comment Share on other sites More sharing options...
Zetsu 78 Posted September 3, 2014 Author Share Posted September 3, 2014 dont work for me and i dont now why :/ can anyone help me? syserr.txt 0711 19:14:16289 :: Unknown Server Command quest_name_index 258 | quest_name_index You've done client-side wrong. Link to comment Share on other sites More sharing options...
Lupetto 44 Posted November 15, 2014 Share Posted November 15, 2014 Very nice and helpful Thanks. 1 Link to comment Share on other sites More sharing options...
KorraXD 0 Posted July 3, 2015 Share Posted July 3, 2015 q.getcurrentquestindex() Always gets 0 :/ Link to comment Share on other sites More sharing options...
AlCapone 67 Posted September 17, 2015 Share Posted September 17, 2015 Sorry for asking but for what is this good? Some more details please. Link to comment Share on other sites More sharing options...
TERROOOR 0 Posted January 28, 2020 Share Posted January 28, 2020 Thanks you dude Link to comment Share on other sites More sharing options...
Recommended Posts