EA - Admin Features

(I did these features using Eclipse Advance v3.0.7 but assume they will be pretty much the same in the Event System version or EO also)

First little feature is a Set Name button added to the admin panel. Click the spoiler for details

! Okay so for this we are going to use the txtAName and txtAAccess boxes already in the admin panel and will only be adding one new button called cmdAName. You can add this button anywhere on the admin panel it doesn’t matter.
! Now double click on cmdAName and replacePrivate Sub cmdAName_Click() ! End SubwithPrivate Sub cmdAName_Click() ! ' If debug mode, handle error then exit out ! If Options.Debug = 1 Then On Error GoTo errorhandler ! If GetPlayerAccess(MyIndex) < ADMIN_CREATOR Then ! Exit Sub ! End If ! If Len(Trim$(txtAName.text)) < 2 Then ! Exit Sub ! End If ! If IsNumeric(Trim$(txtAName.text)) Or IsNumeric(Trim$(txtAAccess.text)) Then ! Exit Sub ! End If ! SendSetName Trim$(txtAName.text), (Trim$(txtAAccess.text)) ! ' Error handler ! Exit Sub ! errorhandler: ! HandleError "cmdAName_Click", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext ! Err.Clear ! Exit Sub ! End SubNow search forPublic Sub SendSetAccess(ByVal name As String, ByVal Access As Byte)in modClientTCP and just below the End Sub for that add the following```
Public Sub SendSetName(ByVal name As String, ByVal newName As String)
! Dim buffer As clsBuffer
! ’ If debug mode, handle error then exit out
! If Options.Debug = 1 Then On Error GoTo errorhandler
! Set buffer = New clsBuffer
! buffer.WriteLong CSetName
! buffer.WriteString name
! buffer.WriteString newName
! SendData buffer.ToArray()
! Set buffer = Nothing
! ’ Error handler
! Exit Sub
! errorhandler:
! HandleError “SendSetName”, “modClientTCP”, Err.Number, Err.Description, Err.Source, Err.HelpContext
! Err.Clear
! Exit Sub
! End Sub

>! Now search for```
CSetAccess[code] in modEnumerations and right below it add [code]CSetName[/code]
>! That is it for the client side of editing. Save this and now open up the server source and now go to modEnumerations in the server source and once again find [code]CSetAccess[code] and add [code]CSetName[/code] below it. Now go to modHandleData and search for [code]HandleDataSub(CSetAccess) = GetAddress(AddressOf HandleSetAccess)[/code] below this add [code]HandleDataSub(CSetName) = GetAddress(AddressOf HandleSetName)[/code] Stay in modHandleData but now search for [code]Sub HandleSetAccess[/code] and below the End Sub for that add the following [code]' 


>! Sub HandleSetName(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
>! Dim n As Long
>! Dim i As String
>! Dim buffer As clsBuffer
>! Set buffer = New clsBuffer
>! buffer.WriteBytes Data()
>! ' Prevent hacking
>! If GetPlayerAccess(index) < ADMIN_CREATOR Then
>! Exit Sub
>! End If
>! ' The index
>! n = FindPlayer(buffer.ReadString) 'Parse(1))
>! ' The new name
>! i = buffer.ReadString 'CLng(Parse(2))
>! Set buffer = Nothing
>! ' Check if player is on
>! If n > 0 Then
>! 'check to see if same level access is trying to change another access of the very same level and boot them if they are.
>! If GetPlayerAccess(n) = GetPlayerAccess(index) Then
>! Call PlayerMsg(index, "Invalid access level.", Red)
>! Exit Sub
>! End If
>! Call AddLog(GetPlayerName(index) & " has modified " & GetPlayerName(n) & "'s name too " & i & ".", ADMIN_LOG)
>! Call SetPlayerName(n, i)
>! Call SendPlayerData(n)
>! If GetPlayerAccess(n) <= 0 Then
>! Call PlayerMsg(n, "Your Name has been changed!", White)
>! Else
>! Call PlayerMsg(index, "Player is not online.", White)
>! End If
>! End Sub[/code]
>! That is it for this code. Now save your source for the server. To now use this ingame you just open your admin panel, type the players current name into the txtAName box and under Access in the txtAAccess you will type the players new name that you want to set. Once you have the current and new name in their boxes click on your cmdAName button and the players name will instantly change if they are online and they will get a message about their name being changed.
>! Now the next code is to change it so admin's do not get blocked by any objects, players or NPC's while moving around. This will let them walk through blocks, doors, resources, other players and all npc's. Click on the spoiler to see the code
>! [spoiler]
>! First go into your clients source and open up modGameLogic and search for [code]Function CheckDirection(ByVal direction As Byte) As Boolean[/code] Now find [code]If isDirBlocked(Map.Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).DirBlock, direction + 1) Then[/code] and replace it with [code]If isDirBlocked(Map.Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).DirBlock, direction + 1) And GetPlayerAccess(MyIndex) = 0 Then[/code] So we added the And GetPlayerAccess(MyIndex) = 0 into the check for a blocked direction. Now replace [code]If Map.Tile(x, y).Type = TILE_TYPE_BLOCKED then[/code] with [code]If Map.Tile(x, y).Type = TILE_TYPE_BLOCKED And GetPlayerAccess(MyIndex) = 0 Then[/code] replace [code]If Map.Tile(x, y).Type = TILE_TYPE_RESOURCE Then[/code] with [code]If Map.Tile(x, y).Type = TILE_TYPE_RESOURCE And GetPlayerAccess(MyIndex) = 0 Then[/code]
>! replace [code]If TempTile(x, y).DoorOpen = NO Then[/code] with [code]If TempTile(x, y).DoorOpen = NO And GetPlayerAccess(MyIndex) = 0 Then[/code] replace [code]If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then[/code] with [code]If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) And GetPlayerAccess(MyIndex) = 0 Then[/code] replace [code]If MapNpc(i).num > 0 Then[/code] with [code]If MapNpc(i).num > 0 And GetPlayerAccess(MyIndex) = 0 Then[/code] and replace [code]If Map.MapEvents(i).WalkThrough = 0 Then[/code] with [code]If Map.MapEvents(i).WalkThrough = 0 And GetPlayerAccess(MyIndex) = 0 Then[/code]
>! That is everything for the client side of things so you can save that now and open the server source. Go to modPlayer and find [code]Sub PlayerMove(ByVal index As Long, ByVal Dir As Long, ByVal movement As Long, Optional ByVal sendToSelf As Boolean = False)[/code] below that Replace [code]If Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).DirBlock, DIR_UP + 1) Then[/code] with [code]If Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).DirBlock, DIR_UP + 1) Or GetPlayerAccess(index) > 0 Then[/code] Replace [code]f Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type <> TILE_TYPE_BLOCKED Then[/code] with [code]If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type <> TILE_TYPE_BLOCKED Or GetPlayerAccess(index) > 0 Then[/code] replace [code]If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type <> TILE_TYPE_RESOURCE Then[/code] with [code]If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type <> TILE_TYPE_RESOURCE Or GetPlayerAccess(index) > 0 Then[/code]
>! Go through Case DIR_DOWN, Case DIR_LEFT and Case DIR_RIGHT and add the [code] Or GetPlayerAccess(index) > 0 [/code] checks into all the same places you did with Case DIR_UP. Once you have finished all of those save your server source and the code is complete.
>! Anyone admin rank can now run freely through anything that would normally stop a player.
>! [/spoiler]
>! The next feature as suggested by oǝɹo (and with help from him after I had an issue lol). This will be adding the Monitor (1), Mapper (2) and Developer (3) access levels into the server menu. They are already setup in the code, there just never was a way to set players as anything but Creator (4). Also since we are going into this section of the code, we will also be putting in a little bug fix that will stop the server from crashing if you try to kick, make admin or remove admin status from an empty slot in the server panel. Click the spoiler for the code
>! [spoiler]
>! This will all be done in the server source. Go to frmServer and double click anywhere on it.
>! Find [code]Private Sub mnuKickPlayer_Click()[/code]
>! Now replace the following [code]Private Sub mnuKickPlayer_Click()
>! Dim Name As String
>! Name = frmServer.lvwInfo.SelectedItem.SubItems(3)
>! If Not Name = "Not Playing" And Not FindPlayer(Name) = 0 Then
>! Call AlertMsg(FindPlayer(Name), "You have been kicked by the server owner!")
>! End If
>! End Sub
>! Sub mnuDisconnectPlayer_Click()
>! Dim Name As String
>! Name = frmServer.lvwInfo.SelectedItem.SubItems(3)
>! If Not Name = "Not Playing" And Not FindPlayer(Name) = 0 Then
>! CloseSocket (FindPlayer(Name))
>! End If
>! End Sub
>! Sub mnuBanPlayer_click()
>! Dim Name As String
>! Name = frmServer.lvwInfo.SelectedItem.SubItems(3)
>! If Not Name = "Not Playing" And Not FindPlayer(Name) = 0 Then
>! Call ServerBanIndex(FindPlayer(Name))
>! End If
>! End Sub
>! Sub mnuAdminPlayer_click()
>! Dim Name As String
>! Name = frmServer.lvwInfo.SelectedItem.SubItems(3)
>! If Not Name = "Not Playing" And Not FindPlayer(Name) = 0 Then
>! Call SetPlayerAccess(FindPlayer(Name), 4)
>! Call SendPlayerData(FindPlayer(Name))
>! Call PlayerMsg(FindPlayer(Name), "You have been granted administrator access.", BrightCyan)
>! End If
>! End Sub
>! Sub mnuRemoveAdmin_click()
>! Dim Name As String
>! Name = frmServer.lvwInfo.SelectedItem.SubItems(3)
>! If Not Name = "Not Playing" And Not FindPlayer(Name) = 0 Then
>! Call SetPlayerAccess(FindPlayer(Name), 0)
>! Call SendPlayerData(FindPlayer(Name))
>! Call PlayerMsg(FindPlayer(Name), "You have had your administrator access revoked.", BrightRed)
>! End If
>! End Sub[/code] with [code]Private Sub mnuKickPlayer_Click()
>! Dim Name As String
>! Name = frmServer.lvwInfo.SelectedItem.SubItems(3)
>! If Not Name = "Not Playing" And Not FindPlayer(Name) = 0 Then
>! Call AlertMsg(FindPlayer(Name), "You have been kicked by the server owner!")
>! End If
>! End Sub
>! Sub mnuDisconnectPlayer_Click()
>! Dim Name As String
>! Name = frmServer.lvwInfo.SelectedItem.SubItems(3)
>! If Not Name = "Not Playing" And Not FindPlayer(Name) = 0 Then
>! CloseSocket (FindPlayer(Name))
>! End If
>! End Sub
>! Sub mnuBanPlayer_click()
>! Dim Name As String
>! Name = frmServer.lvwInfo.SelectedItem.SubItems(3)
>! If Not Name = "Not Playing" And Not FindPlayer(Name) = 0 Then
>! Call ServerBanIndex(FindPlayer(Name))
>! End If
>! End Sub
>! Sub mnuAdminPlayer_click()
>! Dim Name As String
>! Name = frmServer.lvwInfo.SelectedItem.SubItems(3)
>! If Not Name = "Not Playing" And Not FindPlayer(Name) = 0 Then
>! Call SetPlayerAccess(FindPlayer(Name), 4)
>! Call SendPlayerData(FindPlayer(Name))
>! Call PlayerMsg(FindPlayer(Name), "You have been granted administrator access.", BrightCyan)
>! End If
>! End Sub
>! Sub mnuRemoveAdmin_click()
>! Dim Name As String
>! Name = frmServer.lvwInfo.SelectedItem.SubItems(3)
>! If Not Name = "Not Playing" And Not FindPlayer(Name) = 0 Then
>! Call SetPlayerAccess(FindPlayer(Name), 0)
>! Call SendPlayerData(FindPlayer(Name))
>! Call PlayerMsg(FindPlayer(Name), "You have had your administrator access revoked.", BrightRed)
>! End If
>! End Sub
>! Sub mnuModPlayer_click()
>! Dim Name As String
>! Name = frmServer.lvwInfo.SelectedItem.SubItems(3)
>! If Not Name = "Not Playing" And Not FindPlayer(Name) = 0 Then
>! Call SetPlayerAccess(FindPlayer(Name), 1)
>! Call SendPlayerData(FindPlayer(Name))
>! Call PlayerMsg(FindPlayer(Name), "You have been granted mapper access.", BrightCyan)
>! End If
>! End Sub
>! Sub mnuMapPlayer_click()
>! Dim Name As String
>! Name = frmServer.lvwInfo.SelectedItem.SubItems(3)
>! If Not Name = "Not Playing" And Not FindPlayer(Name) = 0 Then
>! Call SetPlayerAccess(FindPlayer(Name), 2)
>! Call SendPlayerData(FindPlayer(Name))
>! Call PlayerMsg(FindPlayer(Name), "You have been granted mapper access.", BrightCyan)
>! End If
>! End Sub
>! Sub mnuDevPlayer_click()
>! Dim Name As String
>! Name = frmServer.lvwInfo.SelectedItem.SubItems(3)
>! If Not Name = "Not Playing" And Not FindPlayer(Name) = 0 Then
>! Call SetPlayerAccess(FindPlayer(Name), 3)
>! Call SendPlayerData(FindPlayer(Name))
>! Call PlayerMsg(FindPlayer(Name), "You have been granted mapper access.", BrightCyan)
>! End If
>! End Sub
>! [/code]
What this did was add the check [code]And Not FindPlayer(Name) = 0[/code] every place the server used to only have [code] If Not Name = "Not Playing" Then[/code] which will stop the crashes from clicking on empty slots. We also added in the Subs for mnuModPlayer_click, mnuMapPlayer_click and mnuDevPlayer_click. Now we are almost done, we just need to add the actual buttons in.
>! Go back to the frmServer and click once anywhere on it so it is highlighted. Now click Ctrl E. A window will pop up called a Menu Editor. In the bottom of the Menu Editor click on what should look like ----Make Admin and click on the Insert button. Do this a total of three times so you should have three empty slots above Make Admin that just appear as ---- in the Menu Editor now.
>! Click on the top empty spot we just made right below ----Ban and in the caption box put Make Mod and in the Name box put mnuModPlayer (what you put in the caption doesn't have to be exactly  what I do, only the Name box it needs to be so it matches the code we added earlier. Now click on the next empty spot below Make Mod and set the caption to Make Mapper and Name to mnuMapPlayer. Click on the spot below that and caption as Make Dev with the name mnuDevPlayer. Now click on Ok button in the Menu Editor and it will close.
>! You can now save your server source and launch your game. Now when go to the Players tab and left click on any names in the box you will see are new Make Mod, Make Mapper and Make Dev button's. There is no need to make a button to remove any of the new status's as the Remove Admin button already made will reset any status back to 0 so we can use this for all of the admin statuses.
>! [/spoiler]
>! This next tutorial is a little change to the SetSprite function already in Eclipse. Right now you can only change your own sprite, with this change admins will be able to set any online players sprite and still their own if they want. Click the spoiler for the code...
>! [spoiler]
>! Ok, first open your client source and go to the frmMain. Double click on the SetSprite button. Now replace [code]Private Sub cmdASprite_Click()
>! ' If debug mode, handle error then exit out
>! If Options.Debug = 1 Then On Error GoTo errorhandler
>! If GetPlayerAccess(MyIndex) < ADMIN_MAPPER Then
>! Exit Sub
>! End If
>! If Len(Trim$(txtASprite.text)) < 1 Then
>! Exit Sub
>! End If
>! If Not IsNumeric(Trim$(txtASprite.text)) Then
>! Exit Sub
>! End If
>! SendSetSprite CLng(Trim$(txtASprite.text))
>! ' Error handler
>! Exit Sub
>! errorhandler:
>! HandleError "cmdASprite_Click", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext
>! Err.Clear
>! Exit Sub
>! End Sub[/code] with [code]Private Sub cmdASprite_Click()
>! ' If debug mode, handle error then exit out
>! If Options.Debug = 1 Then On Error GoTo errorhandler
>! If GetPlayerAccess(MyIndex) < ADMIN_MAPPER Then
>! Exit Sub
>! End If
>! If Len(Trim$(txtASprite.text)) < 1 Then
>! Exit Sub
>! End If
>! If Not IsNumeric(Trim$(txtASprite.text)) Then
>! Exit Sub
>! End If
>! If Len(Trim$(txtAName.text)) > 1 Then
>! SendSetSprite CLng(Trim$(txtASprite.text)), txtAName.text
>! Else
>! SendSetSprite CLng(Trim$(txtASprite.text)), GetPlayerName(MyIndex)
>! End If
>! ' Error handler
>! Exit Sub
>! errorhandler:
>! HandleError "cmdASprite_Click", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext
>! Err.Clear
>! Exit Sub
>! End Sub[/code] Now go to modInput and replace [code]SendSetSprite CLng(Command(1))[/code] with [code]SendSetSprite CLng(Command(1)), GetPlayerName(MyIndex)[/code] (This is just done to avoid errors with the other changes we made to SendSetSprite for the admin panel)
>! Now go to modClientTCP and replace [code]Public Sub SendSetSprite(ByVal SpriteNum As Long)
>! Dim buffer As clsBuffer
>! ' If debug mode, handle error then exit out
>! If Options.Debug = 1 Then On Error GoTo errorhandler
>! Set buffer = New clsBuffer
>! buffer.WriteLong CSetSprite
>! buffer.WriteLong SpriteNum
>! SendData buffer.ToArray()
>! Set buffer = Nothing
>! ' Error handler
>! Exit Sub
>! errorhandler:
>! HandleError "SendSetSprite", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext
>! Err.Clear
>! Exit Sub
>! End Sub[/code] with [code]Public Sub SendSetSprite(ByVal SpriteNum As Long, ByVal plName As String)
>! Dim buffer As clsBuffer
>! ' If debug mode, handle error then exit out
>! If Options.Debug = 1 Then On Error GoTo errorhandler
>! Set buffer = New clsBuffer
>! buffer.WriteLong CSetSprite
>! buffer.WriteLong SpriteNum
>! buffer.WriteString plName
>! SendData buffer.ToArray()
>! Set buffer = Nothing
>! ' Error handler
>! Exit Sub
>! errorhandler:
>! HandleError "SendSetSprite", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext
>! Err.Clear
>! Exit Sub
>! End Sub[/code] That is it for the client. Save the source and then open the server for a quick little change.
>! Go to modHandleData and find [code]Sub HandleSetSprite(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)[/code] and replace this whole Sub with [code]Sub HandleSetSprite(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
>! Dim n As Long
>! Dim i As String
>! Dim buffer As clsBuffer
>! Set buffer = New clsBuffer
>! buffer.WriteBytes Data()
>! ' Prevent hacking
>! If GetPlayerAccess(index) < ADMIN_MAPPER Then
>! Exit Sub
>! End If
>! ' The sprite
>! n = buffer.ReadLong 'CLng(Parse(1))
>! i = FindPlayer(buffer.ReadString)
>! Set buffer = Nothing
>! Call SetPlayerSprite(i, n)
>! Call SendPlayerData(i)
>! Exit Sub
>! End Sub[/code]
>! What we did was add a second variable to the SendSetSprite function which is a name. To change another online players sprite you just put their name in the txtAName box already in the admin panel. Then you put the new sprite number txtASprite box like normal and click the Set Sprite button. The Send function now checks for any input in the txtAName box and if there is, it sends that name with the function, if that box is empty it sends your own name with it. The server then gets the SendSetSprite packet like normal but this time with an name and sprite number and uses that to know who's sprite is being changed. So to change your own name either type it in or leave the name box empty.
>! [/spoiler]
>! I will try to keep adding new Admin feature tutorials to this thread as I think of ideas. If anyone has an idea for a feature they think would be cool or want/need just post suggestions here. Keep the suggestions to Admin features though as thats all I'll be adding to this thread.
>! If anyone has questions about any of the codes in this thread feel free to ask. I just added them to a blank version of Eclipse Advance today and tested them with no bugs so there shouldn't be any problems in the code.[/code][/code][/code]

just today i added the ability to make someone a mapper and i realized how easy it was! you should include that too! just a suggestion tho. its as simple as adding one small sub server side and editing the menu in server side to add the new label.

Nice features, good work Ertzel.

I added in the tutorial on how to add the Mapper status into the server (I also did it for the Monitor and Developer status) With that change I also added in a little bug fix that I found in EA earlier today that can cause a server crash if you try to Ban, Kick, Promote or Demote an empty slot without a player in it.

Has anyone figured a way to have an admin be able to set someone elses sprite? im pretty sure someone was asking about it in the shout box a few days ago. lol sorry for having random ideas.

I updated the original post again with the change to the set sprite system to allow admins to change any online members sprite (or their own like normal)

This next feature gives any player above access level 0 (so any kind of game admin) have the ability to go invisible to everyone but still see their own character. Click the spoiler for the tutorial…

! Okay, we will start this off in the client source. Open up modInput and search forCase "/mapreport"Add the following code either above or below this case! 'visibility toggle ! Case "/visible" ! If GetPlayerAccess(MyIndex) < ADMIN_MAPPER Then GoTo Continue ! SendVisibilityNow open up modClientTCP and search forPublic Sub SendMapReport()Right above this sub add the following code```
Public Sub SendVisibility()
! Dim buffer As clsBuffer
! ’ If debug mode, handle error then exit out
! If Options.Debug = 1 Then On Error GoTo errorhandler
! Set buffer = New clsBuffer
! buffer.WriteLong CPlayerVisibility
! SendData buffer.ToArray()
! Set buffer = Nothing
! If Not GetPlayerVisible(MyIndex) = 1 Then
! Call AddText("(Going invisible)", AlertColor)
! Else
! Call AddText("(Going visible)", AlertColor)
! End If
! ’ Error handler
! Exit Sub
! errorhandler:
! HandleError “SendVisibility”, “modClientTCP”, Err.Number, Err.Description, Err.Source, Err.HelpContext
! Err.Clear
! Exit Sub
! End Sub

>! Next go to modEnumerations and search add```
CPlayerVisibility
```right above```
' Make sure CMSG_COUNT is below everything else
>! CMSG_COUNT
```Now go into modHandleData and search for```
Private Sub HandlePlayerData(ByVal Index As Long, ByRef data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
```then in this sub, right under```
Call SetPlayerClass(i, buffer.ReadLong)
```add```
Call SetPlayerVisible(i, buffer.ReadLong)

! Now go to modDatabase and findFunction GetPlayerVital(ByVal Index As Long, ByVal Vital As Vitals) As LongRight above this function add the following```
Function GetPlayerVisible(ByVal Index As Long) As Long
! ’ If debug mode, handle error then exit out
! If Options.Debug = 1 Then On Error GoTo errorhandler
! If Index > MAX_PLAYERS Then Exit Function
! GetPlayerVisible = Player(Index).Visible
! ’ Error handler
! Exit Function
! errorhandler:
! HandleError “GetPlayerPK”, “modDatabase”, Err.Number, Err.Description, Err.Source, Err.HelpContext
! Err.Clear
! Exit Function
! End Function
! Sub SetPlayerVisible(ByVal Index As Long, ByVal Visible As Long)
! ’ If debug mode, handle error then exit out
! If Options.Debug = 1 Then On Error GoTo errorhandler
! If Index > MAX_PLAYERS Then Exit Sub
! Player(Index).Visible = Visible
! ’ Error handler
! Exit Sub
! errorhandler:
! HandleError “SetPlayerPK”, “modDatabase”, Err.Number, Err.Description, Err.Source, Err.HelpContext
! Err.Clear
! Exit Sub
! End Sub

>! Now go to modGraphics and search for```
' Players
```and replace```
]If Player(i).y = y Then
>! Call DrawPlayer(i)
>! End I
```with```
If Player(i).y = y And (Not GetPlayerVisible(i) = 1 Or i = MyIndex) Then
>! Call DrawPlayer(i)
>! End If
```Then search for```
' draw player names
```and replace```
If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
>! Call DrawPlayerName(i)
>! End If
```with```
If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) And (Not GetPlayerVisible(i) = 1 Or i = MyIndex) Then
>! Call DrawPlayerName(i)
>! End If
```Then search for```
' Draw the hover icon
```and replace```
If myTargetType = TARGET_TYPE_PLAYER
```with```
If myTargetType = TARGET_TYPE_PLAYER And myTarget = i Or GetPlayerVisible(i) = 1 Then
```Then go to modTypes and search for```
Private Type PlayerRec
```Anywhere in here add the following```
 ' Admins
>! Visible As Long

! That is all for the client portion so you can save that now and open the server source then go to modServerTCP and search forSub SendWelcome(ByVal index As Long)then add the following anywhere in that sub' Send visibility message ! If GetPlayerAccess(index) > ADMIN_MONITOR Then ! If GetPlayerVisible(index) = 1 Then ! Call PlayerMsg(index, "(invisible)", AlertColor) ! End If ! End IfNext search forbuffer.WriteLong GetPlayerClass(index)and below that add```
! buffer.WriteLong GetPlayerVisible(index)

>! Then go to modPlayer and search for```
Function GetPlayerVital(ByVal index As Long, ByVal Vital As Vitals) As Long
```Add the following just above that function```
Function GetPlayerVisible(ByVal index As Long) As Long
>! If index > MAX_PLAYERS Then Exit Function
>! GetPlayerVisible = Player(index).Visible
>! End Function
>! Sub SetPlayerVisible(ByVal index As Long, ByVal Visible As Long)
>! Player(index).Visible = Visible
>! End Sub
```Then go to modHandleData and find```
HandleDataSub(CSwitchesAndVariables) = GetAddress(AddressOf HandleSwitchesAndVariables)
```and below that add```
HandleDataSub(CPlayerVisibility) = GetAddress(AddressOf HandlePlayerVisibility)

! Next findSub HandleSearch(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)and replaceIf IsPlaying(i) Then ! If GetPlayerMap(index) = GetPlayerMap(i) Then ! If GetPlayerX(i) = x Then ! If GetPlayerY(i) = y Then ! ' Change target ! If TempPlayer(index).targetType = TARGET_TYPE_PLAYER And TempPlayer(index).Target = i Then ! TempPlayer(index).Target = 0 ! TempPlayer(index).targetType = TARGET_TYPE_NONE ! ' send target to player ! SendTarget index ! Else ! TempPlayer(index).Target = i ! TempPlayer(index).targetType = TARGET_TYPE_PLAYER ! ' send target to player ! SendTarget index ! End If ! Exit Sub ! End If ! End If ! End If ! End If ! End If ! NextwithIf IsPlaying(i) Then ! If GetPlayerMap(index) = GetPlayerMap(i) Then ! If Not GetPlayerVisible(i) = 1 Then ! If GetPlayerX(i) = x Then ! If GetPlayerY(i) = y Then ! ' Change target ! If TempPlayer(index).targetType = TARGET_TYPE_PLAYER And TempPlayer(index).Target = i Then ! TempPlayer(index).Target = 0 ! TempPlayer(index).targetType = TARGET_TYPE_NONE ! ' send target to player ! SendTarget index ! Else ! TempPlayer(index).Target = i ! TempPlayer(index).targetType = TARGET_TYPE_PLAYER ! ' send target to player ! SendTarget index ! End If ! Exit Sub ! End If ! End If ! End If ! End If ! End If ! NextThen at the bottom of modHandleData add the following```
Sub HandlePlayerVisibility(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
! If Not Player(index).Visible = 0 Then
! Player(index).Visible = 0
! Else
! Player(index).Visible = 1
! End If
! Call SendPlayerData(index)
! End Sub

>! Now go into modEnumerations and find```
' Make sure CMSG_COUNT is below everything else
```Just above that add```
CPlayerVisibility
```Then go to modTypes and search for```
Private Type PlayerRec
```Anywhere in here add the following```
 ' Admins
>! Visible As Long

! Then you can save the server and are done with this feature

To use it all a player who is above rank 0 needs to do is type /visible and they will toggle between invisible and visible mode. Since they will always be able to see themself no matter what mode, you will get a red message in your chat telling you what mode you changed to after you type /visible. Also if you logout while invisible, next time you login you will still be invisible and will be warned that you are invisible when you log in by another red message in your charbox.

This system works good with the second system I posted in the original post that makes it so admins can walk through other players, blocks, npc’s and resources.

Hey bro i added your tut to addon section of Eclipse Advanced :P

Do this tutorials work in eclipse 2.3 event system?

Yes Dawntide, the do

A new addition (I coded this last week and forgot to post it)

This next system is an Auto Kill button added to the admin panel and / commands that will let admins press a button or type a command to kill a player in one hit. Click the spoiler for the code….

! - Client Side -
! First go to frmMain and add a new button to the admin panel called cmdAKill. Next double click it and replace the blankPrivate Sub cmdAKill_Click(withPrivate Sub cmdAKill_Click() ! ' If debug mode, handle error then exit out ! If Options.Debug = 1 Then On Error GoTo errorhandler ! If GetPlayerAccess(MyIndex) < ADMIN_MONITOR Then ! Exit Sub ! End If ! If Len(Trim$(txtAName.text)) < 2 Then ! Exit Sub ! End If ! If IsNumeric(Trim$(txtAName.text)) Then ! Exit Sub ! End If ! SendKillPlayer Trim$(txtAName.text) ! ' Error handler ! Exit Sub ! errorhandler: ! HandleError "cmdAKill_Click", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext ! Err.Clear ! Exit Sub ! End SubNext go to modClientTCP and findPublic Sub SendSetSprite(ByVal SpriteNum As Long, ByVal plName As String)Above that sub add the followingPublic Sub SendKillPlayer(ByVal name As String) ! Dim buffer As clsBuffer ! ' If debug mode, handle error then exit out ! If Options.Debug = 1 Then On Error GoTo errorhandler ! Set buffer = New clsBuffer ! buffer.WriteLong CKillPlayer ! buffer.WriteString name ! SendData buffer.ToArray() ! Set buffer = Nothing ! ' Error handler ! Exit Sub ! errorhandler: ! HandleError "SendKillPlayer", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext ! Err.Clear ! Exit Sub ! End SubNow open modEnumerations and search forCWhosOnlineabove it add```
CKillPlayer

Next go to modInput and search for```
' // Developer Admin Commands //
```and above it add```
' Killing a player
>!                 Case "/kill"
>!                     If GetPlayerAccess(MyIndex) < ADMIN_MONITOR Then GoTo Continue
>!                     If UBound(Command) < 1 Then
>!                         AddText "Usage: /kill (name)", AlertColor
>!                         GoTo Continue
>!                     End If
>!                     SendKillPlayer Command(1)
```Thats it for the client. Save/Compile and then open the server
>! - Server Side -
>! go to modEnumerations and search for```
CWhosOnline
```above it add```
CKillPlayer
```Then open modHandleData and find```
HandleDataSub(CWhosOnline)
```and above it add```
HandleDataSub(CKillPlayer) = GetAddress(AddressOf HandleKillPlayer)
```Then anywhere in modHandleData below```
Sub HandleData(ByVal index As Long, ByRef Data() As Byte)
```add the following sub```
' 


>! Sub HandleKillPlayer(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
>!     Dim n As Long
>!     Dim buffer As clsBuffer
>!     Set buffer = New clsBuffer
>!     buffer.WriteBytes Data()
>!     ' Prevent hacking
>!     If GetPlayerAccess(index) < ADMIN_MONITOR Then
>!         Exit Sub
>!     End If
>!     ' The index
>!     n = FindPlayer(buffer.ReadString)
>!     Set buffer = Nothing
>!     ' Check if player is on
>!     If n > 0 Then
>!         Call SetPlayerVital(n, Vitals.HP, 0)
>!         Call SendVital(n, Vitals.HP)
>!         Call OnDeath(n)
>!         Call PlayerMsg(n, "You have been killed by " & GetPlayerName(index) & "!", BrightRed)
>!         Call AddLog(GetPlayerName(index) & " killed" & GetPlayerName(n) & ".", ADMIN_LOG)
>!     Else
>!         Call PlayerMsg(index, "Player is not online.", White)
>!     End If
>! End Sub

Then save/compile and thats it for this code. Now to use it you can enter the players name into the name box in the admin panel and click your Auto Kill button, or you can type /kill <playername>and it will kill that player.</playername>

This next feature is a little upgrade to the current Level Up button. Right now you can only use it to level your own character but with the following tutorial we will be making it so you can change your own level still or any other online players level. We will also be adding a /level command to go with the button. Click the spoiler for the code…

! - Client Side -
! First go into the client and go to modInput, we are going to be adding the /level command now. Find' // Developer Admin Commands //and below it add' Level up player ! Case "/level" ! If GetPlayerAccess(MyIndex) < ADMIN_DEVELOPER Then GoTo Continue ! If UBound(Command) < 1 Then ! AddText "Usage: /level (name)", AlertColor ! GoTo Continue ! End If ! SendRequestLevelUp Command(1)Then go to frmMain and double click the current Level Up button. Replace the lineSendRequestLevelUpwith the followingIf Len(Trim$(txtAName.text)) < 2 Then ! SendRequestLevelUp GetPlayerName(MyIndex) ! Else ! SendRequestLevelUp Trim$(txtAName.text) ! End IfNow go to modClientTCP and replace the subPublic Sub SendRequestLevelUp()with```
Public Sub SendRequestLevelUp(ByVal PlayerName As String)
! Dim buffer As clsBuffer
! ’ If debug mode, handle error then exit out
! If Options.Debug = 1 Then On Error GoTo errorhandler
! Set buffer = New clsBuffer
! buffer.WriteLong CRequestLevelUp
! buffer.WriteString PlayerName
! SendData buffer.ToArray()
! Set buffer = Nothing
! ’ Error handler
! Exit Sub
! errorhandler:
! HandleError “SendRequestLevelUp”, “modClientTCP”, Err.Number, Err.Description, Err.Source, Err.HelpContext
! Err.Clear
! Exit Sub
! End Sub

>! - Server Side-
>! Go to modHandleData and search for```
Sub HandleRequestLevelUp
```and replace the whole sub with the following```
Sub HandleRequestLevelUp(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
>!     Dim thePlr As Long
>!     Dim buffer As clsBuffer
>!     Set buffer = New clsBuffer
>!     buffer.WriteBytes Data()
>!     ' Prevent hacking
>!     If GetPlayerAccess(index) < ADMIN_DEVELOPER Then
>!         Exit Sub
>!     End If
>!     thePlr = FindPlayer(buffer.ReadString)
>!     If GetPlayerAccess(index) < ADMIN_DEVELOPER Then Exit Sub
>!     SetPlayerExp thePlr, GetPlayerNextLevel(thePlr)
>!     CheckPlayerLevelUp thePlr
>! End Sub

And thats all for server side, only needed to do the one change. Now save/compile and you are all done.

! To level yourself you just click the button like normal (or type /level <yourname>) and to level another player, put their name into the Name box already part of the admin panel and click the Level Up button (or type /level <playername>)</playername></yourname>

Another new little tutorial. This isn’t really an admin feature but more of an admin panel feature. Right now the only way to move the admin panel is by hardcoding it to a certain position and while ingame you can’t move it around. The following tutorial will show how to make it so you can click and drag the Admin Panel around the screen. Click the spoiler for details…

! This is all client side so open up the client and double click anywhere on frmMain. Scroll to the top of it and findPrivate PresentY As LongRight below it addPrivate mouseClicked As BooleanThen add the following anywhere in the frmMain codes```
Private Sub picAdmin_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
! mouseClicked = True
! End Sub
! Private Sub picAdmin_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
! mouseClicked = False
! End Sub
! Private Sub picAdmin_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
! If (mouseClicked = True) Then
! picAdmin.Left = picAdmin.Left + X
! picAdmin.Top = picAdmin.Top + Y
! End If
! End Sub

>! Now search for```
Private Sub Form_Load()
```and right below```
picAdmin.Left = 544
```add the following```
mouseClicked = False

Then save/compile the source and your done.

! Now when you open your admin panel (/admin from ingame) you can click on it and as long as your holding down the left mouse button you can drag your mouse across the screen and the panel will follow you. Release the left mouse button to drop it in place and stop it from moving.

Nice addons

thanks for it

Loved the tutorials. Currently trying to get them working in EA 21 (in the Dev Suite with the new menu - moveable admin panel and set sprite are already there as standard!)

Thanks Ertzel,

–Matt

how i can open the admin menu? i already putted my player as admin in the server, and now? i forgeted the key to open it…

type /admin into your chat.

Log in to reply