Beanie93 Posted August 10, 2011 Author Share Posted August 10, 2011 This is my second tutorial here, on Eclipse.I've experimented with clsBuffer, and could get an AFK Command as the first thing I've ever done with clsBuffer, so the feature is not that big, nor so useful, but I thought I should post it in case someone wants it.We will edit both client and server, so open your client.vbp and server.vbp.**Client-side****modEnumerations**Look for``` ' Make sure CMSG_COUNT is below everything else```and above, add``` CAfk CBack```We're done here.**modGlobals**At the bottom, add```' afkPublic isAfk As Boolean```Done here.**modInput**In **Public Sub CheckInputKeys()**, look for``` If Options.Debug = 1 Then On Error GoTo errorhandler```and below, add``` If isAfk = True Then Exit Sub```This will prevent the player to move if he/she is AFK.Now, look for``` Case "/stats" Set Buffer = New clsBuffer Buffer.WriteLong CGetStats SendData Buffer.ToArray() Set Buffer = Nothing```and below, add``` Case "/afk" Dim pname As Long If isAfk = False Then isAfk = True Set Buffer = New clsBuffer Buffer.WriteLong CAfk Buffer.WriteLong pname SendData Buffer.ToArray() Set Buffer = Nothing Else isAfk = False Set Buffer = New clsBuffer Buffer.WriteLong CBack Buffer.WriteLong pname SendData Buffer.ToArray() Set Buffer = Nothing End If```We just used clsBuffer to send the Afk packet to the server if we are not Afk, and to send the Back packet if we are Afk.Done here.**modClientTCP**We want that when the Player logs off, isAfk is false, so look for **Sub DestroyTcp()** and below``` frmMain.Socket.Close```add``` isAfk = False```Client side is done.Now, we want the server to receive the packet, and make an action.**Server-side****modEnumerations**Do exactly what you did Client-side in here.**modHandleData**Look for``` HandleDataSub(CPartyLeave) = GetAddress(AddressOf HandlePartyLeave)```and below, add``` HandleDataSub(CAfk) = GetAddress(AddressOf HandleAfk) HandleDataSub(CBack) = GetAddress(AddressOf HandleBack)```Then, at the bottom, add these 2 subs:```Private Sub HandleAfk(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() Call TextAdd(GetPlayerName(index) & " has gone AFK.") Call GlobalMsg(GetPlayerName(index) & " has gone AFK!", Grey)End SubPrivate Sub HandleBack(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() Call TextAdd(GetPlayerName(index) & " is no longer AFK.") Call GlobalMsg(GetPlayerName(index) & " is no longer AFK!", Grey)End Sub```There we go, all done. Type /afk in the chat, and you should have it working.Hope this helped!**NOTE:** _This is the first time I ever use clsBuffer, I didn't find any tutorial, so I learnt by looking at other subs that used clsBuffer, so this is maybe not done properly, but it works._The _other_ way of doing it: (credit to King Butterfly/Carim):Inside **KeyHandlePresses**, add:``` Case "/afk" AFK = Not AFK If AFK = True Then EmoteMsg " is now AFK!" Else EmoteMsg " is no longer AFK!" End If```Anywhere at the declarations in modGlobal, add:```Public AFK As Boolean```Add, in Sub Main:``` AFK = False``` Link to comment Share on other sites More sharing options...
Carim123 Posted August 10, 2011 Share Posted August 10, 2011 You don't need to go to such lengths, this can be done in a couple of lines of code, and without the need to edit anything server-side (The wonders of abusing EmoteMsg. <3)* * *EDIT: May as well share what I mean…Inside HandleKeyPresses``` Case "/afk" AFK = Not AFK If AFK = True Then EmoteMsg " is now AFK!" Else EmoteMsg " is no longer AFK!" End If```Anywhere at the declarations in modGlobals```Public AFK As Boolean```And, in Sub Main``` AFK = False``` Link to comment Share on other sites More sharing options...
Beanie93 Posted August 10, 2011 Author Share Posted August 10, 2011 *facepalm* I didn't even know there was EmoteMsg. But well, this at least helped me see how packets work… Link to comment Share on other sites More sharing options...
Carim123 Posted August 10, 2011 Share Posted August 10, 2011 Yeah, I edited my post, feel free to use it.Nice to see you learn the thing, though. Better than most peoples attempts to learn. ^_^ Link to comment Share on other sites More sharing options...
Beanie93 Posted August 10, 2011 Author Share Posted August 10, 2011 I added it to the main post. Link to comment Share on other sites More sharing options...
Craselin Posted September 29, 2011 Share Posted September 29, 2011 Quick question, if the player moves and/or types something, does it automaticly say they are no longer afk (similar to the Minecraft server plugin, forgot the name though xD) Link to comment Share on other sites More sharing options...
Beanie93 Posted September 29, 2011 Author Share Posted September 29, 2011 No. It will say the player is back if the player who's AFK types "/back", but you can easily make it so that when you move, it says the player is no longer AFK. Link to comment Share on other sites More sharing options...
Likestodraw Posted November 26, 2011 Share Posted November 26, 2011 @Serenade:> You don't need to go to such lengths, this can be done in a couple of lines of code, and without the need to edit anything server-side (The wonders of abusing EmoteMsg. <3)> > * * *> > EDIT: May as well share what I mean…> > Inside HandleKeyPresses> > ```> Case "/afk"> > AFK = Not AFK> > If AFK = True Then> EmoteMsg " is now AFK!"> Else> EmoteMsg " is no longer AFK!"> End If> ```> Anywhere at the declarations in modGlobals> > ```> Public AFK As Boolean> ```> And, in Sub Main> > ```> AFK = False> ```Could you specify where you put the first bit of code for the noobs (points finger back at self) Link to comment Share on other sites More sharing options...
lexkymbeth Posted November 26, 2011 Share Posted November 26, 2011 re read full tut. don't just skip to end Link to comment Share on other sites More sharing options...
Taegan Posted November 26, 2011 Share Posted November 26, 2011 @Likestodraw:> Could you specify where you put the first bit of code for the noobs (points finger back at self)Open client.vbp and search full Project for```Case "/who"``` Link to comment Share on other sites More sharing options...
Likestodraw Posted November 27, 2011 Share Posted November 27, 2011 @Taegan:> Open client.vbp and search full Project for```> Case "/who"> ```Look at what I quoted there. Link to comment Share on other sites More sharing options...
Justn Posted November 27, 2011 Share Posted November 27, 2011 @Likestodraw:> Look at what I quoted there.are u even using vb6 yet or still trying with notepad? 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