Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[Request] /afk command


Kaymak
 Share

Recommended Posts

Server and Client
>! Look for "PlayerRec". At the bottom, put there this
>! ```
>! afk as byte
```
Look for "Public Enum ServerPackets" and at the bottom of the enum, put there
>! ```
>! SPlayerToggledAfk
>! ```
Look for "Public Enum ClientPackets" and at the bottom of the enum, put there
>! ```
>! CToggleAfk
>! ```

Server
>! Look for "Public Sub InitMessages()" and anywhere in that sub, put there
>! ```
>! HandleDataSub(CToggleAfk) = GetAddress(AddressOf HandleToggleAfk)
>! ```
Now, go to the bottom of modHandleData and put there
>! ```
>! Sub HandleToggleAfk(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
If Player(index).afk = 1 Then
Player(index) = 0
Else
Player(index).afk = 1
End If

SendPlayerToggledAfk (index)
End Sub
>! ```
Go to the bottom of modServerTCP and put this there
>! ```
>! Public Sub SendPlayerToggledAfk(ByVal index As Long)
Dim Buffer As clsBuffer
>! Set Buffer = New clsBuffer
Buffer.WriteLong SPlayerToggledAfk
Buffer.WriteLong index
Buffer.WriteLong Player(index).afk
SendDataToMap Player(index).Map, Buffer.ToArray()
Set Buffer = Nothing
End Sub
>! ```
Lastly, look for "Function PlayerData(ByVal index As Long) As Byte()" and put this
>! ```
>! Buffer.WriteLong Player(index).afk
>! ```
above
>! ```
>! PlayerData = Buffer.ToArray()
>! ```

Client
>! Look for "Public Sub InitMessages()" and put there this
>! ```
>! HandleDataSub(SPlayerToggledAfk) = GetAddress(AddressOf HandlePlayerToggledAfk)
>! ```
Go to the bottom of modHandleData, and put there this
>! ```
>! Sub HandlePlayerToggledAfk(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim Buffer As clsBuffer
Dim playerIndex As Long
>! Set Buffer = New clsBuffer
Buffer.WriteBytes Data()
playerIndex = Buffer.ReadLong
Player(Index).afk = Buffer.ReadLong
Set Buffer = Nothing
End Sub
>! ```
Look for "Public Sub DrawPlayerName(ByVal Index As Long)" and look for the chunk that looks like this
>! ```
>! Select Case GetPlayerAccess(Index)
Case 0
color = RGB(255, 96, 0)
Case 1
color = QBColor(DarkGrey)
Case 2
color = QBColor(Cyan)
Case 3
color = QBColor(BrightGreen)
Case 4
color = QBColor(Yellow)
End Select
>! ```
Replace it with this
>! ```
>! If Player(Index).afk = 0 Then
Select Case GetPlayerAccess(Index)
Case 0
color = RGB(255, 96, 0)
Case 1
color = QBColor(DarkGrey)
Case 2
color = QBColor(Cyan)
Case 3
color = QBColor(BrightGreen)
Case 4
color = QBColor(Yellow)
End Select
Else
color = RGB(65, 65, 65)
End If
>! ```
Look for "Select Case Command(0)" and put this under it
>! ```
>! Case "/afk"
SendToggleAfk
>! ```
Now go to modClientTcp, and put this at the bottom
>! ```
>! Public Sub SendToggleAfk()
Dim Buffer As clsBuffer
>! Set Buffer = New clsBuffer
Buffer.WriteLong CToggleAfk
SendData Buffer.ToArray()
Set Buffer = Nothing
End Sub
>! ```

I think that should be everything. Save, compile, and enjoy. **Remember that you need to delete all old accounts, or make a data converter.** I haven't tested it, but I'll go through it now.
Link to comment
Share on other sites

> Look for "Public Sub InitMessages()" and anywhere in that sub, put there
>
> ```
>
> HandleDataSub(CToggleAfk) = GetAddress(AddressOf HandleToggleAfk)
>
> ```

you put CToggleAfk here, which is right, but you use SToggleAfk in the rest of the code…  :x

```

Sub HandleToggleAfk(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
If Player(index).afk = 1 Then
Player(index) = 0 <-- didn't you mean Player(index).afk = 0 ?
Else
Player(index).afk = 1
End If

SendPlayerToggledAfk (index)
End Sub

```
:)
Link to comment
Share on other sites

Well again thanks for the code, but sadly

![](http://s14.directupload.net/images/141120/j7u778pz.png)

my character has no name anymore  :P ( yes deleted account)

/EDIT -> I fixxed it

```

If Player(Index).afk = 0 Then
Select Case GetPlayerAccess(Index)
Case 0
color = RGB(255, 96, 0)
Case 1
color = QBColor(DarkGrey)
Case 2
color = QBColor(Cyan)
Case 3
color = QBColor(BrightGreen)
Case 4
color = QBColor(Yellow)
End Select
Else
color = RGB(65, 65, 65)
End If 
```
i changed it with this cause QBColor etc ( using Directx8 :P

```
If Player(Index).afk = 0 Then
Select Case GetPlayerAccess(Index)
Case 0
color = Orange
Case 1
color = DarkGrey
Case 2
color = Cyan
Case 3
color = BrightGreen
Case 4
color = Yellow
End Select
Else
color = DarkGrey
End If 
```
also you got a little mistake in the code nothing important

```
Sub HandleToggleAfk(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
If Player(index).afk = 1 Then
Player(index) = 0
Else
Player(index).afk = 1
End If

SendPlayerToggledAfk (index)
End Sub 
```
```
If Player(index).afk = 1 Then
Player(index) = 0
Else 
```
instead of 

```
Player(index).afk = 0
```
you wrote

```
Player(index) = 0

```
Link to comment
Share on other sites

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
 Share

×
×
  • Create New...