Derryl Posted June 12, 2011 Author Share Posted June 12, 2011 This tutorial is basically about making a party chat message system. I use /p for mine. So you will have to change the numbers in the "/p" code to fit the way you're chat messages work. Lets begin.**Client Side**At the bottom of "modClientTCP" add:```Public Sub SendPartyChatMsg(ByVal text As String) Dim Buffer As clsBuffer Set Buffer = New clsBuffer Buffer.WriteLong CPartyChatMsg Buffer.WriteString text SendData Buffer.ToArray() Set Buffer = NothingEnd Sub```In "modEnumerations", above:```' Make sure CMSG_COUNT is below everything else```Add:```CPartyChatMsg```In "modInput", in "Sub Handlekeypresses" under:```' Handle when the player presses the return key If KeyAscii = vbKeyReturn Then```Add:```' Party Msg If Left$(ChatText, 3) = "/p " Then ChatText = Mid$(ChatText, 4, Len(ChatText) - 3) If Len(ChatText) > 0 Then Call SendPartyChatMsg(ChatText) End If MyText = vbNullString frmMain.txtMyChat.text = vbNullString Exit Sub End If```And thats it for the client side. Again you will have to change the numbers in the above code if you want to use symbols to chat.**Server Side**In "modHandleData", in "Sub InitMessages" above the "End Sub" add:```HandleDataSub(CPartyChatMsg) = GetAddress(AddressOf HandlePartyChatMsg)```At the bottom of "modHandleData" add:```Sub HandlePartyChatMsg(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long) Dim Buffer As clsBuffer Set Buffer = New clsBuffer Buffer.WriteBytes Data() PartyChatMsg Index, Buffer.ReadString, Pink Set Buffer = NothingEnd Sub```At the bottom of "modServerTCP" add:```Public Sub PartyChatMsg(ByVal Index As Long, ByVal Msg As String, ByVal Color As Byte)Dim i As LongDim Member As IntegerDim partyNum As LongpartyNum = tempPlayer(Index).inParty ' not in a party? If tempPlayer(Index).inParty = 0 Then Call PlayerMsg(Index, "You are not in a party.", BrightRed) Exit Sub End If For i = 1 To MAX_PARTY_MEMBERS Member = Party(partyNum).Member(i) ' is online, does exist? If IsConnected(Party(partyNum).Member(i)) And IsPlaying(Party(partyNum).Member(i)) Then ' yep, send the message! Call PlayerMsg(Member, "[Party] " & GetPlayerName(Index) & ": " & Msg, Color) End If NextEnd Sub```In "modEnumerations", above:```' Make sure CMSG_COUNT is below everything else```Add:```CPartyChatMsg```And that's it. Goodluck. Link to comment Share on other sites More sharing options...
MrKris Posted June 12, 2011 Share Posted June 12, 2011 Ill try this out right now. Looks like it would work. Link to comment Share on other sites More sharing options...
Carim123 Posted June 12, 2011 Share Posted June 12, 2011 It does work, I've seen it used. Link to comment Share on other sites More sharing options...
Zopto Posted June 12, 2011 Share Posted June 12, 2011 ty man !!!!! Link to comment Share on other sites More sharing options...
erkro1 Posted June 12, 2011 Share Posted June 12, 2011 Wow, thanks dude ;) Link to comment Share on other sites More sharing options...
MrKris Posted June 12, 2011 Share Posted June 12, 2011 @Hamster:> It does work, I've seen it used.Never said it didn't work :P I just said it looked like it did. Link to comment Share on other sites More sharing options...
Derryl Posted June 12, 2011 Author Share Posted June 12, 2011 @Kris:> Never said it didn't work :P I just said it looked like it did.How would you know >_>.And thanks. Link to comment Share on other sites More sharing options...
Antisora Posted June 16, 2011 Share Posted June 16, 2011 ~~What do i put before what im typing so only my party can see it?~~/p. got it. Link to comment Share on other sites More sharing options...
RyokuHasu Posted June 24, 2011 Share Posted June 24, 2011 @Derryl:> How would you know >_>.> > And thanks.Some people can tell what code does based on what it says and where you tell them to put it. They don't have to test it to know if it will work or not. Link to comment Share on other sites More sharing options...
Domino_ Posted July 20, 2011 Share Posted July 20, 2011 im typing as example " /p hey! " and it inmiddietly send's without enter only this " h " like " /p h " … why?! xD Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now