Credits to Giaken for Helping me make the packet and most of the complicated stuff
Credit to Me for doing the easy stuff that I didn't need help with xDKay. First Tutorial. Sorry If I miss something ;D
BEFORE ANYTHING:
Go to \Data\ (Server Folder)and Add an INI File called phraselist.ini. This is how you're going to change the phrase easily without having to go into the server coding.
In the INI File, Put:
Code:
[PHRASE]
Phrase=thisisthephrase
---------------
Okay, Make a new form called frmGuessPhrase. This is going to be where the player puts and sends the Word/Phrase. Add a textbox(txtPhrase) and a Command button(cmdEnterPhrase)
Next, Go to modInput. Find;
Code:
' Whos Online
Case "/who"
SendWhosOnline
(Or any of the other Player Commands, That is)
Add This Under it:
Code:
' Show Phrase Form
Case "/phrase"
frmGuessPhrase.Show
This Is going to make the frmGuessPhrase appear when the user types '/phrase' into chat
Next, We're going to make the Packet in the Client.
In ModEnumerations, Find;
Code:
Public Enum ClientPackets
At the very bottom of that list, Add;
Code:
CPhrase
Now, To send the packet to the Server, Go back to frmGuessPhrase, Double click your Command button, And add;
Code:
Call SendData(CPhrase & SEP_CHAR & txtPhrase.Text & END_CHAR)
txtPhrase.Text = vbNullString
The Call SendData code will send the phrase to the server to be checked.
SERVER-SIDEGo to ModEnumerations, Find:
Code:
Public Enum ClientPackets
Again, at the bottom, Add:
Code:
CPhrase
Go to ModHandleData, And find the list of Case (Whatever).
At the bottom of it, Right before the Case Else, Add;
Code:
Case CPhrase
Call HandlePhrase(Index, Parse)
At the very bottom of the module, Add:
Code:
Private Sub HandlePhrase(ByVal Index As Long, ByRef Parse() As String)
Dim phrase As String
phrase = GetVar(App.Path & "\Data\phraselist.ini", "PHRASE", "Phrase")
If Parse(1) = phrase Then
Call PlayerMsg(Index, "You got it right!", Green)
Call GiveItem(Index, 1, 500)
Else: Call PlayerMsg(Index, "You got it wrong!", Red)
End If
End Sub
What it does:
Dims phrase as a string. I put the path of the INI File in. You don't have to do this, You can just put If Parse(1) = GetVar(App.Path &....). I did it this way because it seems easier in my head. The If Parse(1) = Phrase Then Checks to see if the Phrase the player entered matches the phrase in your INI File. If they get it right, It will send them a Green PlayerMsg Saying they got it right, And Assuming gold is your Item 1, IT will send 500 Gold to them. The Else is If they put the wrong phrase in, IT will Send them a Red PlayerMsg Telling them they got it wrong.
-------------
I think thats it. If It goes wrong, PM me what happened and I'll fix the tutorial. Again, Credits to Giaken for helping me make the packet and get it to send back and forth between server and client.