Jump to content

About Client-Quest communication


Recommended Posts

  • Active Member

Hi guys,

 

I am trying new event like ox, but question-answer shaped with using chat.

 

How it should work:

We add some questions and their answers to the quest file

like every 20 minutes a random question will be chosen from the question list

when a player writes the correct answer to chat label using this format: &&<answer>(quest input) he will get a reward

 

Example; November is how many days?

Answer; "30"

 

User send answer like this > "&& 30"

 

I am trying this way split answer and sending quest

 

 

com = text.split(" ")
 
if com[0] == "&&":
net.SendQuestInputStringPacket(com[1])
 
but of course it did not work because quest keys attached from game.py, I trying from uichat because chat label attached uichat
 
hopefully was able to tell, I'm really confused, please help
 
Regards

 

Link to comment
Share on other sites

In game.py, add in serverCommandList 

"QuestIndex"	: self.__ReceiveQuestIndex
"get_input_value"    : self.__GetInputValue

Then add the folowing functions in game.py:

		def __ReceiveQuestIndex(self, index):
			constInfo.QuestIndex = int(index)
		def __GetInputValue(self):
			net.SendQuestInputStringPacket(str(constInfo.Answer))

Then in constInfo.py, add:

QuestIndex = 0
Answer = ""

In uichat.py, in __SendChatPacket function, add:

if text[0] == '&' and text[1] == '&':
	com = text.split(" ")
	constInfo.Answer = com[1]
	import event
	event.QuestButtonClick(int(constInfo.QuestIndex))
	return

Now, in the quest, you receive the answer like this:

when login begin
        cmdchat("QuestIndex "..q.getcurrentquestindex())
end
when info or button begin
        
	local answer= input(cmdchat("get_input_value"))
	if answer == "CorrectAnswer" then
            chat("Your answer is correct!")
        end
end
 

I hope this will work, it is not tested.

You have to adapt the if answer == "CorrectAnswer" then to check the question too. If you do not succed, let me know.
 

 

 

 

  • Love 2
Link to comment
Share on other sites

  • Active Member

 

In game.py, add in serverCommandList 

"QuestIndex"	: self.__ReceiveQuestIndex
"get_input_value"    : self.__GetInputValue

Then add the folowing functions in game.py:

		def __ReceiveQuestIndex(self, index):
			constInfo.QuestIndex = int(index)
		def __GetInputValue(self):
			net.SendQuestInputStringPacket(str(constInfo.Answer))

Then in constInfo.py, add:

QuestIndex = 0
Answer = ""

In uichat.py, in __SendChatPacket function, add:

if text[0] == '&' and text[1] == '&':
	com = text.split(" ")
	constInfo.Answer = com[1]
	import event
	event.QuestButtonClick(int(constInfo.QuestIndex))
	return

Now, in the quest, you receive the answer like this:

when login begin
        cmdchat("QuestIndex "..q.getcurrentquestindex())
end
when info or button begin
        
	local answer= input(cmdchat("get_input_value"))
	if answer == "CorrectAnswer" then
            chat("Your answer is correct!")
        end
end
 

I hope this will work, it is not tested.

You have to adapt the if answer == "CorrectAnswer" then to check the question too. If you do not succed, let me know.

 

 

it worked thanks bro :)

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / 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.