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

[EO] GM/DEV Tags


Ertzel
 Share

Recommended Posts

**[Updated with some of Robins suggestions]**
**[Added another step]**
**[Updated with Tylian colored tags]**

Ok, so this tutorial will let you add [GM] before your Moderator/Mappers names ingame and in the chat, and [DEV] Before you DEVs/Admins names ingame and in the chat. The thing is, this does not actually add the tag to your character it only appears as it does. This way it doesn't screw up player files when you make someone an Admin or kick them from Admin. It also auto-updates if their access changes.

If you want to change the tags to something else just replace [GM] and [DEV] with something else.

Here is a preview of what it does.
![](http://www.freemmorpgmaker.com/files/imagehost/pics/dd19bf0e4271baf04fafeaac50634f8c.png)
As you can see, my name is still Ertzel but it has the [DEV] tag before it. So when players want to send you a personal message they don't need to include the tag.

All of the Chat parts are Source, and the in-game parts are client so first we will start with the chat…

**- Server -**

In modPlayer go to the bottom and add
```
Public Function GetPlayerTag(ByVal index As Long) As String
    Select Case GetPlayerAccess(index)
        Case ADMIN_MONITOR, ADMIN_MAPPER
            GetPlayerTag = "[GM] "
        Case ADMIN_DEVELOPER, ADMIN_CREATOR
            GetPlayerTag = "[Dev] "
        Case Else
            GetPlayerTag = " "
    End Select
End Function
```
In modHandleData replace all of this sub
```
Private Sub HandleEmoteMsg(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
```
with this
```
Private Sub HandleEmoteMsg(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
    Dim Msg As String
    Dim I As Long
    Dim Buffer As clsBuffer
    Set Buffer = New clsBuffer
    Buffer.WriteBytes Data()
    Msg = Buffer.ReadString

    ' Prevent hacking
    For I = 1 To Len(Msg)

        If AscW(Mid$(Msg, I, 1)) < 32 Or AscW(Mid$(Msg, I, 1)) > 126 Then
            Exit Sub
        End If

    Next
    Call AddLog("Map #" & GetPlayerMap(index) & ": " & GetPlayerName(index) & " " & Msg, PLAYER_LOG)
    Call MapMsg(GetPlayerMap(index), GetPlayerTag(index) & GetPlayerName(index) & " " & Right$(Msg, Len(Msg) - 1), EmoteColor)
    Set Buffer = Nothing
End Sub
```
In modServerTCP replace
```
Sub SayMsg_Map(ByVal MapNum As Long, ByVal Index As Long, ByVal message As String, ByVal saycolour As Long)
```
and
```
Sub SayMsg_Global(ByVal Index As Long, ByVal message As String, ByVal saycolour As Long)
```
With this
```
Sub SayMsg_Map(ByVal MapNum As Long, ByVal index As Long, ByVal message As String, ByVal saycolour As Long)
    Dim Buffer As clsBuffer

    Set Buffer = New clsBuffer
    Buffer.WriteLong SSayMsg
    Buffer.WriteString GetPlayerName(index)
    Buffer.WriteLong GetPlayerAccess(index)
    Buffer.WriteLong GetPlayerPK(index)
    Buffer.WriteString message
    Buffer.WriteString "[Map] " & GetPlayerTag(index)
    Buffer.WriteLong saycolour

    SendDataToMap MapNum, Buffer.ToArray()

    Set Buffer = Nothing
End Sub

Sub SayMsg_Global(ByVal index As Long, ByVal message As String, ByVal saycolour As Long)
    Dim Buffer As clsBuffer

    Set Buffer = New clsBuffer
    Buffer.WriteLong SSayMsg
    Buffer.WriteString GetPlayerName(index)
    Buffer.WriteLong GetPlayerAccess(index)
    Buffer.WriteLong GetPlayerPK(index)
    Buffer.WriteString message
    Buffer.WriteString "[Global]" & GetPlayerTag(index)
    Buffer.WriteLong saycolour

    SendDataToAll Buffer.ToArray()

    Set Buffer = Nothing
End Sub
```
Now for the Client side…

**- Client -**

In modText replace all of
```
Public Sub DrawPlayerName(ByVal Index As Long)
```
with this
```
Public Sub DrawPlayerName(ByVal Index As Long)
    Dim TextX As Long
    Dim TextY As Long
    Dim color As Long
    Dim sTag As String

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

        Select Case GetPlayerAccess(Index)
            Case 0
                color = RGB(255, 96, 0)
                sTag = vbNullString
            Case 1
                color = QBColor(DarkGrey)
                sTag = "[GM] "
            Case 2
                color = QBColor(Cyan)
                sTag = "[GM] "
            Case 3
                color = QBColor(BrightGreen)
                sTag = "[DEV] "
            Case 4
                color = QBColor(Yellow)
                sTag = "[DEV] "
        End Select

    Else
        color = QBColor(BrightRed)
    End If

    If GetPlayerSprite(Index) < 1 Or GetPlayerSprite(Index) > NumCharacters Then
        TextX = ConvertMapX(GetPlayerX(Index) * PIC_X) + Player(Index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(sTag & GetPlayerName(Index))))
        TextY = ConvertMapY(GetPlayerY(Index) * PIC_Y) + Player(Index).YOffset - 16
    Else
        TextX = ConvertMapX(GetPlayerX(Index) * PIC_X) + Player(Index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(sTag & GetPlayerName(Index))))
        TextY = ConvertMapY(GetPlayerY(Index) * PIC_Y) + Player(Index).YOffset - (DDSD_Character(GetPlayerSprite(Index)).lHeight) + 16
    End If

    Call DrawText(TexthDC, TextX, TextY, sTag & GetPlayerName(Index), color)
End Sub
```
If you want your GM/DEV tags to have their own color different from the players name replace all of
```
Public Sub DrawPlayerName(ByVal Index As Long)
```
with this

```
Public Sub DrawPlayerName(ByVal Index As Long)
    Dim TextX As Long
    Dim TextY As Long
    Dim Color As Long
    Dim Tag As String
    Dim TagWidth As Long
    Dim TagColor As Long

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

        Select Case GetPlayerAccess(Index)
            Case 0
                color = RGB(255, 96, 0)
                Tag = vbNullString
            Case 1
                color = QBColor(DarkGrey)
                Tag = "[GM] "
                TagColor = QBColor(Red)
            Case 2
                color = QBColor(Cyan)
                Tag = "[GM] "
                TagColor = QBColor(Red)
            Case 3
                color = QBColor(BrightGreen)
                Tag = "[DEV] "
                TagColor = QBColor(Blue)
            Case 4
                color = QBColor(Yellow)
                Tag = "[DEV] "
                TagColor = QBColor(Blue)
        End Select

    Else
        color = QBColor(BrightRed)
    End If

    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

    If GetPlayerAccess(Index) > ADMIN_MONITOR Then
        TagWidth = getWidth(TexthDC, Tag)
        TextX = TextX + TagWidth

        Call DrawText(TexthDC, TextX - TagWidth * 2, TextY, Tag, TagColor)
    End If

    ' Draw name
    Call DrawText(TexthDC, TextX, TextY, GetPlayerName(Index), Color)
End Sub
```(Coded by Tylian)

I have tested all of this and it works in EO as you can see in the screenshot at the top of the post.
(This is my first Source Tutorial so sorry if I missed anything)
Link to comment
Share on other sites

Not bad. Your nesting is completely wrong, however. It should be like this:

```
If [condition] then
    ' nested code
else
    ' nested code
end if

```
Here are some improvements to your actual code. You've got the same code over and over again which generates the player's dev tag. Make it a centralised function.

```
Public Function GetPlayerTag() As String
Select Case GetPlayerAccess(Index)
    Case ADMIN_MONITOR, ADMIN_MAPPER
        GetPlayerTag = "[GM] "
    Case ADMIN_DEVELOPER, ADMIN_CREATOR
        GetPlayerTag = "[Dev] "
    Case Else
        GetPlayerTag = " "
End Select
End Function

```
```
MapMsg GetPlayerMap(Index), GetPlayerTag(index) & GetPlayerName(Index) & " " & Right$(Msg, Len(Msg) - 1), EmoteColor

```
You've really made a mess of DrawPlayerName, too. ;o

Here's a better procedure.

```
Public Sub DrawPlayerName(ByVal Index As Long)
    Dim TextX As Long
    Dim TextY As Long
    Dim color As Long
    Dim sTag As String

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

        Select Case GetPlayerAccess(Index)
            Case 0
                color = RGB(255, 96, 0)
                sTag = vbNullString
            Case 1
                color = QBColor(DarkGrey)
                sTag = "[GM] "
            Case 2
                color = QBColor(Cyan)
                sTag = "[GM] "
            Case 3
                color = QBColor(BrightGreen)
                sTag = "[DEV] "
            Case 4
                color = QBColor(Yellow)
                sTag = "[DEV] "
        End Select

    Else
        color = QBColor(BrightRed)
    End If

    If GetPlayerSprite(Index) < 1 Or GetPlayerSprite(Index) > NumCharacters Then
        TextX = ConvertMapX(GetPlayerX(Index) * PIC_X) + Player(Index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(sTag & GetPlayerName(Index))))
        TextY = ConvertMapY(GetPlayerY(Index) * PIC_Y) + Player(Index).YOffset - 16
    Else
        TextX = ConvertMapX(GetPlayerX(Index) * PIC_X) + Player(Index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(sTag & GetPlayerName(Index))))
        TextY = ConvertMapY(GetPlayerY(Index) * PIC_Y) + Player(Index).YOffset - (DDSD_Character(GetPlayerSprite(Index)).lHeight) + 16
    End If

    Call DrawText(TexthDC, TextX, TextY, sTag & GetPlayerName(Index), color)
End Sub

```
I quickly edited all this in notepad, so I have no idea if it'll work by just copying & pasting it, but it should.
Link to comment
Share on other sites

Ok, I updated the client side stuff to the way you said because it is a lot cleaner. Also updated the Sub SayMsg_Map and Sub SayMsg_Global in the server with a cleaner code.

When I tried to add in the GetPlayerTag and the MapMsg with your code I was getting Type Missmatch errors so I left my old code in for now because I couldn't find the problem.
Link to comment
Share on other sites

@Robin:

> _Please_ sort out your nesting. Your code is unreadable.

Ok, what do you mean…

@Robin:

> Where did you get the mismatch error?

Ok, I got it to work using this..
```
Private Sub HandleEmoteMsg(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
    Dim Msg As String
    Dim I As Long
    Dim Buffer As clsBuffer
    Set Buffer = New clsBuffer
    Buffer.WriteBytes Data()
    Msg = Buffer.ReadString

    ' Prevent hacking
    For I = 1 To Len(Msg)

        If AscW(Mid$(Msg, I, 1)) < 32 Or AscW(Mid$(Msg, I, 1)) > 126 Then
            Exit Sub
        End If

    Next
    Call AddLog("Map #" & GetPlayerMap(Index) & ": " & GetPlayerName(Index) & " " & Msg, PLAYER_LOG)
        Select Case GetPlayerAccess(Index)
        Case ADMIN_MONITOR, ADMIN_MAPPER
            Call MapMsg(GetPlayerMap(Index), "[GM] " & GetPlayerName(Index) & " " & Right$(Msg, Len(Msg) - 1), EmoteColor)
        Case ADMIN_DEVELOPER, ADMIN_CREATOR
            Call MapMsg(GetPlayerMap(Index), "[DEV] " & GetPlayerName(Index) & " " & Right$(Msg, Len(Msg) - 1), EmoteColor)
        Case Else
            Call MapMsg(GetPlayerMap(Index), GetPlayerName(Index) & " " & Right$(Msg, Len(Msg) - 1), EmoteColor)
    End Select
    Set Buffer = Nothing
End Sub
```
Link to comment
Share on other sites

Whats the point of adding a whole other Function and a call for it when u can just take the code in that function and  add it into the chat sending…

And you posted saying to use what I am using, just with no Elfishs which will just lead to more codes..

Also I took out all that stuff and used the Select Case now to make it better, I have them in the middle of the code because its all to do with sending packets and I didn't want to change the order of anything...
Link to comment
Share on other sites

I basically already did this for my game.

Although I never use the DEV one, it's ugly. xD
(see attachements. :p)

Ertzel, Robin has a point. If your adding the tag to every chat message sent, that's repeating ALOT of code.

If you just used Robins function, and something like this:

> Call MapMsg(GetPlayerMap(Index), **GetPlayerTag(Index)** & GetPlayerName(Index) & " " & Right$(Msg, Len(Msg) - 1), EmoteColor)

It's alot better than a giant select case in every social packet sub.

**Edit:**
Code from mine if you want it. Replace DrawPlayerName with:
```
Public Sub DrawPlayerName(ByVal Index As Long)
    Dim TextX As Long
    Dim TextY As Long
    Dim Color As Long
    Dim Tag As String
    Dim TagWidth As Long
    Dim TagColor As Long

    ' 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(Cyan)
                TagColor = QBColor(Blue)
                Tag = "DEV"
            Case 3
                Color = QBColor(BrightGreen)
                TagColor = QBColor(Blue)
                Tag = "DEV"
            Case 4
                Color = QBColor(Yellow)
                TagColor = QBColor(BrightRed)
                Tag = "GM"
        End Select

    Else
        Color = QBColor(BrightRed)
    End If

    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

    If GetPlayerAccess(Index) > ADMIN_MONITOR Then
        TagWidth = getWidth(TexthDC, Tag)
        TextX = TextX + TagWidth

        Call DrawText(TexthDC, TextX - TagWidth * 2, TextY, Tag, TagColor)
    End If

    ' Draw name
    Call DrawText(TexthDC, TextX, TextY, GetPlayerName(Index), Color)
End Sub

```
Link to comment
Share on other sites

Ohh ok, Never mind, I he was talking about something else, and I didn't see the fix for the GetPlayerTag function…

The first post as been changed to add the GetPlayerTag in to use up less code.

Off topic...

Tylian why is your highest rank a GM? o.O
Link to comment
Share on other sites

  • 1 year later...
  • 2 weeks later...
Any idea how the text is being drawn so far away from the sprite? :/

Here's my Client-side sub:

```
Public Sub DrawPlayerName(ByVal Index As Long)
    Dim TextX As Long
    Dim TextY As Long
    Dim color As Long
    Dim Tag As String
    Dim TagWidth As Long
    Dim TagColor As Long

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

        Select Case GetPlayerAccess(Index)
            Case 0
                color = RGB(255, 96, 0)
                Tag = vbNullString
            Case 1
                color = QBColor(DarkGrey)
                Tag = "[s] "
                TagColor = QBColor(White)
            Case 2
                color = QBColor(DarkGrey)
                Tag = "[s] "
                TagColor = QBColor(Cyan)
            Case 3
                color = QBColor(DarkGrey)
                Tag = "[s] "
                TagColor = QBColor(Yellow)
            Case 4
                color = QBColor(Yellow)
                Tag = "[s] "
                TagColor = QBColor(BrightRed)
        End Select

    Else
        color = QBColor(BrightRed)
    End If

    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

    If GetPlayerAccess(Index) > ADMIN_MONITOR Then
        TagWidth = getWidth(TexthDC, Tag)
        TextX = TextX + TagWidth

        Call DrawText(TexthDC, TextX - TagWidth * 2, TextY, Tag, TagColor)
    End If

    ' Draw name
    Call DrawText(TexthDC, TextX, TextY, GetPlayerName(Index), color)
End Sub

Help is greatly appreciated  :embarrassed:[/s][/s][/s][/s]
```
Link to comment
Share on other sites

  • 2 months later...
@DimenXion:

> Any idea how the text is being drawn so far away from the sprite? :/

> 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

That determines the Y-Axis for the drawname.
Link to comment
Share on other sites

  • 7 months later...
  • 2 months later...
If your name so away from your character.

Try this.

Search:

```

Public Sub DrawPlayerName(ByVal Index As Long)

```

Delete sub and paste;

```

Public Sub DrawPlayerName(ByVal Index As Long)

Dim TextX As Long

Dim TextY As Long

Dim Color As Long

Dim sTag As String

' Check access level

If GetPlayerPK(Index) = NO Then

Select Case GetPlayerAccess(Index)

Case 0

Color = RGB(255, 96, 0)

sTag = vbNullString

Case 1

Color = QBColor(BrightCyan)

sTag = "[Gm.1] "

Case 2

Color = QBColor(BrightCyan)

sTag = "[Gm.2] "

Case 3

Color = QBColor(BrightGreen)

sTag = "[Gm.3] "

Case 4

Color = RGB(150, 52, 226)

sTag = "[DEV] "

End Select

Else

Color = QBColor(BrightRed)

End If

If GetPlayerSprite(Index) < 1 Or GetPlayerSprite(Index) > NumCharacters Then

TextX = ConvertMapX(GetPlayerX(Index) * PIC_X) + Player(Index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(sTag & GetPlayerName(Index))))

TextY = ConvertMapY(GetPlayerY(Index) * PIC_Y) + Player(Index).YOffset - 128

Else

TextX = ConvertMapX(GetPlayerX(Index) * PIC_X) + Player(Index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(sTag & GetPlayerName(Index))))

TextY = ConvertMapY(GetPlayerY(Index) * PIC_Y) + Player(Index).YOffset - (DDSD_Character(GetPlayerSprite(Index)).lHeight) + 128

End If

Call DrawText(TexthDC, TextX, TextY, sTag & GetPlayerName(Index), Color)

End Sub

```
Link to comment
Share on other sites

  • 2 months later...
> If your name so away from your character.
>
> Try this.
>
> Search:
>
> ```
> Public Sub DrawPlayerName(ByVal Index As Long)
>
> ```
> Delete sub and paste;
> ```
> Public Sub DrawPlayerName(ByVal Index As Long)
> Dim TextX As Long
> Dim TextY As Long
> Dim Color As Long
> Dim sTag As String
>
> ' Check access level
> If GetPlayerPK(Index) = NO Then
>
> Select Case GetPlayerAccess(Index)
> Case 0
> Color = RGB(255, 96, 0)
> sTag = vbNullString
> Case 1
> Color = QBColor(BrightCyan)
> sTag = "[Gm.1] "
> Case 2
> Color = QBColor(BrightCyan)
> sTag = "[Gm.2] "
> Case 3
> Color = QBColor(BrightGreen)
> sTag = "[Gm.3] "
> Case 4
> Color = RGB(150, 52, 226)
> sTag = "[DEV] "
> End Select
>
> Else
> Color = QBColor(BrightRed)
> End If
>
> If GetPlayerSprite(Index) < 1 Or GetPlayerSprite(Index) > NumCharacters Then
> TextX = ConvertMapX(GetPlayerX(Index) * PIC_X) + Player(Index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(sTag & GetPlayerName(Index))))
> TextY = ConvertMapY(GetPlayerY(Index) * PIC_Y) + Player(Index).YOffset - 128
> Else
> TextX = ConvertMapX(GetPlayerX(Index) * PIC_X) + Player(Index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(sTag & GetPlayerName(Index))))
> TextY = ConvertMapY(GetPlayerY(Index) * PIC_Y) + Player(Index).YOffset - (DDSD_Character(GetPlayerSprite(Index)).lHeight) + 128
> End If
>
> Call DrawText(TexthDC, TextX, TextY, sTag & GetPlayerName(Index), Color)
> End Sub
>
> ```

Thx. It works :)
Link to comment
Share on other sites

  • 3 weeks 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...