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

/status, /mute and /away command


Krumelz
 Share

Recommended Posts

This is a tutorial for EO 1.1.0\. It may works for EO XMAS too, didnt test it though.
with this features you can add little status 'signs' next to the players name and mute some
spammer. Example Screenie:
![](http://www.freemmorpgmaker.com/files/imagehost/pics/1736b352c9b4973d9e89df8dc76c2d00.JPG)

Perhaps this is not the best way of doing it, but it works fine. Well, lets go.
Client Side

search for PlayerRec and after
```
Dir as byte
```
add
```
Status as string * 12
```
in mod enumerations before:
```
' Make sure CMSG_COUNT is below everything else
    CMSG_COUNT
```
add:
```
CCommands
```
Do the same for the servers PlayerRec and Mod enumerations!!

in mod ClientTCP, at the bottom add:
```
Public Sub SendCommand(ByVal command As String, ByVal target As String)
    Dim Buffer As New clsBuffer
    Set Buffer = New clsBuffer
    Buffer.WriteLong CCommands
    Buffer.WriteString command

    If target = "0" Then
        Buffer.WriteLong 0

    Else
        Buffer.WriteLong 1
        Buffer.WriteString target
    End If

    SendData Buffer.ToArray()
    Set Buffer = Nothing
End Sub
```
next find:
```
' // Mapper Admin Commands //
                    ' Location
                Case "/loc"
```
before that add:
```
                    Case "/status"
                If Not UBound(command) < 1 Then
                    Call SendCommand("status", Trim$(command(1)))
                Else
                    Call SendCommand("status", "0")
                End If

                Case "/away"
                    If Not UBound(command) < 1 Then
                        Exit Sub
                    Else

                        Call SendCommand("away", "0")
                    End If

                Case "/mute"
                    If Not UBound(command) < 1 Then
                    Call SendCommand("mute", command(1))
                Else
                    AddText "Usage: /mute playnername", BrightRed

                End If
```
find Sub DrawPlayerName

and replace the whole sub with:
```
Public Sub DrawPlayerName(ByVal index As Long)
    Dim TextX As Long
    Dim TextY As Long
    Dim color As Long
    Dim status As String
    status = Trim$(Player(index).status)

    ' Check access level
    If GetPlayerPK(index) = NO Then

        Select Case GetPlayerAccess(index)
            Case 0
                color = RGB(255, 96, 0)
            Case 1
                color = QBColor(DarkGrey)
            Case 2
                color = QBColor(Magenta)
            Case 3
                color = QBColor(BrightCyan)
            Case 4
                color = QBColor(Blue)
            Case 5
                color = QBColor(Yellow)
            Case Else
                color = QBColor(Yellow)
        End Select

    Else
        color = QBColor(BrightRed)
    End If

If status <> "" Then
    If GetPlayerSprite(index) < 1 Or GetPlayerSprite(index) > NumCharacters Then
        TextX = ConvertMapX(GetPlayerX(index) * PIC_X) + Player(index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(GetPlayerName(index) & " [" & status & "]")))
        TextY = ConvertMapY(GetPlayerY(index) * PIC_Y) + Player(index).YOffset - 16
    Else
        ' Determine location for text
        TextX = ConvertMapX(GetPlayerX(index) * PIC_X) + Player(index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(GetPlayerName(index) & " [" & status & "]")))
        TextY = ConvertMapY(GetPlayerY(index) * PIC_Y) + Player(index).YOffset - (DDSD_Character(GetPlayerSprite(index)).lHeight) + 16
    End If
Else
    If GetPlayerSprite(index) < 1 Or GetPlayerSprite(index) > NumCharacters Then
        TextX = ConvertMapX(GetPlayerX(index) * PIC_X) + Player(index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(GetPlayerName(index))))
        TextY = ConvertMapY(GetPlayerY(index) * PIC_Y) + Player(index).YOffset - 16
    Else
        ' Determine location for text
        TextX = ConvertMapX(GetPlayerX(index) * PIC_X) + Player(index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(GetPlayerName(index))))
        TextY = ConvertMapY(GetPlayerY(index) * PIC_Y) + Player(index).YOffset - (DDSD_Character(GetPlayerSprite(index)).lHeight) + 16
    End If
End If
    ' Draw name
If status <> "" Then
        Call DrawText(TexthDC, TextX, TextY, GetPlayerName(index) & " [" & status & "]", color)
Else
        Call DrawText(TexthDC, TextX, TextY, GetPlayerName(index), color)
End If
End Sub
```
Now find Sub HandlePlayerInfo and after:
```
  For x = 1 To Stats.Stat_Count - 1
        SetPlayerStat I, x, Buffer.ReadLong
    Next
```
add:
```
Player(I).status = Buffer.ReadString
```
Done client sided ^^
Server Side

If you havent added the code to mod enumerations and the PlayerRec do it now!

Mod handleData:

after:
```
HandleDataSub(CUntradeItem) = GetAddress(AddressOf HandleUntradeItem)
```
add:
```
HandleDataSub(CCommands) = GetAddress(AddressOf HandleCommands)
```
at the bottom of mod handledata add:
```
Sub HandleCommands(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim command As String
Dim target As String
Dim n As Long
Dim command2 As String
Dim Buffer As New clsBuffer
Set Buffer = New clsBuffer
Buffer.WriteBytes Data()
    command = Buffer.ReadString
    n = Buffer.ReadLong

    If n = 1 Then
        command2 = Buffer.ReadString
        target = FindPlayer(command2)
    Else
    End If

    Select Case command       
        Case "mute"

        If GetPlayerAccess(index) <= 1 Then
            PlayerMsg index, "Not a valid command!", BrightRed
            Exit Sub
        End If

            If Player(target).Status <> "MUTED" Then
                Player(target).Status = "MUTED"
            Else
                Player(target).Status = ""
            End If
            Call SendPlayerData(target)

        Case "away"
            If Player(index).Status <> "Away" Then
                Player(index).Status = "Away"
                Call GlobalMsg(GetPlayerName(index) & " is now away.", Yellow)
            Else
                Player(index).Status = ""
                Call GlobalMsg(GetPlayerName(index) & " has returned from being away.", Yellow)
            End If

            Call SendPlayerData(index)

        Case "status"

If Not Player(index).Status = "MUTED" Then
    If n = 1 Then
            Player(index).Status = command2
    Else
            Player(index).Status = ""
    End If

Else
    PlayerMsg index, "You are muted!", Red
End If

            Call SendPlayerData(index)

        Case Else
            Call PlayerMsg(index, "Not a valid command!", BrightRed)

    End Select

Set Buffer = Nothing
End Sub
```
in Function Playerdata, after:
```
    For I = 1 To Stats.Stat_Count - 1
        Buffer.WriteLong GetPlayerStat(index, I)
    Next
```
add:
```
Buffer.WriteString Player(index).Status
```
almost done, now to make the mute actually work..

in Sub HandleSayMsg, before:
```
Call AddLog("Map #" & GetPlayerMap(index) & ": " & GetPlayerName(index) & " says, '" & msg & "'", PLAYER_LOG)
```
add:
```
    If Player(index).Status = "MUTED" Then
        Call PlayerMsg(index, "You are muted!", BrightRed)
        Exit Sub
    End If
```
add the same in mod HandleEmoteMsg before:
```
Call AddLog("Map #" & GetPlayerMap(index) & ": " & GetPlayerName(index) & " " & msg, PLAYER_LOG)
```
in Sub HandleBroadcastMsg before:
```
s = "[Global]" & GetPlayerName(index) & ": " & msg
```
and in Sub HandlePlayerMsg before:
```
' Check if they are trying to talk to themselves
```
Hope I didnt miss anything and it works, if it doesnt just reply. No credits needed.
Hope you like it ~ Krumelz
Link to comment
Share on other sites

@Ecclestio:

> Nevermind, I got a blank client and installed it to that and it works great.  The simple thing is I can't get it to use uppercase and lowercase instead of just lowercase.  If you know how I could fix that.. it'd be great.

yea, got the same problem, working on that atm. Hope i can fix it soon. ^^
Link to comment
Share on other sites

  • 3 weeks later...
the current verison. 1.5

I think it showing up but it not showing up like it should. im seeing something at the very very top at first I didnt notice it but I started noticing like two something there. everytime my character moves it moves with him. but it like at the very top of the screen.

it could be due to the level code I added that shows players level.
Link to comment
Share on other sites

  • 2 weeks later...
There is also another problem you should look into.  Seeing as not everyone will know not to try to put spaces in their status(i.e. "/status run away").  You should make it so they are unable to do so, or find some way to allow spaces in it.  Otherwise it gives a run time error and the server crashes.

Also it'd be nice if it would accept capital letters as well, $UCase() or something.
Link to comment
Share on other sites

@saruish:

> the current verison. 1.5
>
> I think it showing up but it not showing up like it should. im seeing something at the very very top at first I didnt notice it but I started noticing like two something there. everytime my character moves it moves with him. but it like at the very top of the screen.
>
> it could be due to the level code I added that shows players level.

Thats odd. May you could send me the source of the subs you edited, so I can try to help you.
@Ecclestio:

> There is also another problem you should look into.  Seeing as not everyone will know not to try to put spaces in their status(I.e. "/status run away").  You should make it so they are unable to do so, or find some way to allow spaces in it.  Otherwise it gives a run time error and the server crashes.
>
> Also it'd be nice if it would accept capital letters as well, $UCase() or something.

Fixed both of it, just change

```
                    Case "/status"
                If Not UBound(command) < 1 Then
                    Call SendCommand("status", Trim$(command(1)))
                Else
                    Call SendCommand("status", "0")
                End If

```
to
```
Dim status As String
                status = Right$(ChatText, Len(ChatText) - 7)
                If Not UBound(command) < 1 Then
                    Call SendCommand("status", status)
                Else
                    Call SendCommand("status", "0")
                End If

```
Capitals and Spaces should work now.

Any other problem? Just reply, i hope i can help ^^

~Krumelz
Link to comment
Share on other sites

  • 10 months later...

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...