Sari la conținut

JUST4METIN.COM CAUTA STAFF ACTIV - PM Bogdan

Robot

[HowTo|Old]Quest-Client communication(for any version)

Postări Recomandate

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 :D). So, let's begin:

### Send informations to client

 

  Hide contents

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,

You should have something like this:
SpXkA.jpg

Now we must create the function in python with name command_name_python or everything you used..
TRi3e.jpg

Be careful! You must align text(functions..etc) with TAB key space.

 



### Start a quest from client (for buttons sometimes...)

 

  Hide contents

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:
http://pastebin.com/xMaDt8E5

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:
http://pastebin.com/qwziPVCw

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)

 

  Hide contents

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: ########
http://pastebin.com/GbveFpp9

Replace it with:
http://pastebin.com/MCVM6QvS

 

#########################For lower versions: ########
-Open uiquest.py
search:

def __init__(self,skin,idx):

Under this add:
http://pastebin.com/nNyY5WWi
######################### Lower Version steps end ########

 

And finally for game.py we have to create these functions:
http://pastebin.com/sZZ9F5J5

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

 

 

  Hide contents

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.

Partajează acest post


Link spre post
Distribuie pe alte site-uri

Creează un cont sau autentifică-te pentru a adăuga comentariu

Trebuie să fi un membru pentru a putea lăsa un comentariu.

Creează un cont

Înregistrează-te pentru un nou cont în comunitatea nostră. Este simplu!

Înregistrează un nou cont

Autentificare

Ai deja un cont? Autentifică-te aici.

Autentifică-te acum

×