Jump to content
Forgot your email address? ×
×
×
  • Create New...
  • 0

About Client-Quest communication


Koray

Question

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

7 answers to this question

Recommended Posts

  • 0

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
  • 0

 

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Announcements

  • -15% Discount in Metin2 Dev Store (01/10/2021 => 31/12/2021) => Code => 15_PCT_OCT_TO_DEC_2021


  • Read our Rules
  • Activity

    1. 1

      Shop Search System (No ItemIndex!) Problem

    2. 23

      Fix unknown header 100% server: 1k player online francec

    3. 1

      Shop Search System (No ItemIndex!) Problem

    4. 23

      Fix unknown header 100% server: 1k player online francec

    5. 23

      Fix unknown header 100% server: 1k player online francec

    6. 23

      Fix unknown header 100% server: 1k player online francec

    7. 23

      Fix unknown header 100% server: 1k player online francec

    8. 23

      Fix unknown header 100% server: 1k player online francec

  • Recently Browsing

    • No registered users viewing this page.

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.