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

[EO] Server Text Commands


The New World
 Share

Recommended Posts

In this tutorial you'll be editing only the server. After the completion of this tutorial when entering a command into the txtChat control of your server, if it matches a handled command, that command will be executed, if not, the message will continue to be relayed as a global message.

All of these editions will be made **Server-Side** in the frmServer's _txtChat_KeyPress_ sub.

Your current _txtChat_KeyPress_ sub should look like this in this an untouched or raw, copy of the source code,

```
Private Sub txtChat_KeyPress(KeyAscii As Integer)

    If KeyAscii = vbKeyReturn Then
        If LenB(Trim$(txtChat.Text)) > 0 Then
            Call GlobalMsg(txtChat.Text, White)
            Call TextAdd("Server: " & txtChat.Text)
            txtChat.Text = vbNullString
        End If

        KeyAscii = 0
    End If

End Sub
```
Now, change that enter sub to match this one,

```
Private Sub txtChat_KeyPress(KeyAscii As Integer)

    If KeyAscii = vbKeyReturn Then
        Select Case (txtChat.Text)
            Case "cls", "clear":
                txtText.Text = ""
                txtChat.Text = vbNullString
            Case Else:
                If LenB(Trim$(txtChat.Text)) > 0 Then
                    Call GlobalMsg(txtChat.Text, White)
                    Call TextAdd("Server: " & txtChat.Text)
                    txtChat.Text = vbNullString
                Else
                    KeyAscii = 0
                End If
        End Select
    End If

End Sub
```
Now, to break it down. This set of code comes with one command that takes two different inputs, "cls" and "clear".

```
If KeyAscii = vbKeyReturn Then
```
This code checks if the keyboard's input was the "return" or "enter" key, and if it was, it will proceed.

```
Select Case (txtChat.Text)
```
This code takes the a set of procedures and executes them based on the contents of txtChat.text when the return or enter key is pressed as said before.

```
Case "cls", "clear":
```
This code is one of the procedures to be executed if the case is true. If txtChat.text's contents were "cls" or "clear" it will execute the procedure within this case.

```
txtText.Text = ""
txtChat.Text = vbNullString

```
This code, changes the txtText.text's contents to be empty, and then changes the txtChat.text's contents to a null or empty string.

```
Case Else:
```
This code is executed if none of the cases before it matched the input, and it executes the original code, sending a global message.
Link to comment
Share on other sites

  • 6 months later...
  • 7 months later...
i know this is an old post but i found it and was messing around with it and started making commands with it

i have made 2 so far

one for making admin and the other removing admin

but plan on making one later on

but here is what i done

after u replace the code in the first post

ok u need to add this code in above the Select Case (txtChat.text)

```
Dim Func As String
        If InStr(txtChat.Text, ":") Then
        Func = Split(txtChat.Text, ":")(1)
        End If 

```
to explain the above code what it does is split the command from the name example admin:Jimmy

it will split admin and Jimmy

then it will be used in the select case statement which will allow the commands to work right

you can change the ":" to anything u want but if you change it in the above code you will have to change it in the
command code to

find this
```
Case "cls", "clear":
                txtText.Text = ""
                txtChat.Text = vbNullString

```
add this after
```
Case "adm:" & Func, "admin:" & Func:
                MakeAdmin (Func)
                txtChat.Text = vbNullString
Case "radm:" & Func, "radmin:" & Func:
                RemoveAdmin (Func)
                txtChat.Text = vbNullString

```
ok and the last part i done was made two functions for the commands which will go above (that is where i put them but u can place then anywhere in the code) the Private Sub txtChat_KeyPress(KeyAscii As Integer)

```
Function MakeAdmin(Name As String)
    If Not Name = "Not Playing" Then
        Call SetPlayerAccess(FindPlayer(Name), 4)
        Call SendPlayerData(FindPlayer(Name))
        Call PlayerMsg(FindPlayer(Name), "You have been granted administrator access.", BrightCyan)
    End If
End Function

Function RemoveAdmin(Name As String)
    If Not Name = "Not Playing" 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 Function

```
if u find any bugs in the code please let me know and i will fix them as fast as i can :)
Link to comment
Share on other sites

There is absolutely 0 security in your code, I can get admin access and remove yours by just sending a few packets to the server. Do a check if the admin access is high enough before setting/removing access, for examples of that just check the security for the other / commands.

And do you have a friend called "Not Playing" that you really dislike? Otherwise Im guessing what you're trying to do is

```
If IsPlaying(name)=false then exit function
```
Link to comment
Share on other sites

@Joost:

> There is absolutely 0 security in your code, I can get admin access and remove yours by just sending a few packets to the server. Do a check if the admin access is high enough before setting/removing access, for examples of that just check the security for the other / commands.

i will look into i am still kinda of new i found this and just started messing with it

@Joost:

> And do you have a friend called "Not Playing" that you really dislike? Otherwise Im guessing what you're trying to do is
>
> ```
> If IsPlaying(name)=false then exit function
> ```

idk i just copied the code from the right click menu on the server and put in the function to be able to use it
Link to comment
Share on other sites

@Joost:

> There is absolutely 0 security in your code, I can get admin access and remove yours by just sending a few packets to the server. Do a check if the admin access is high enough before setting/removing access, for examples of that just check the security for the other / commands.
>
> And do you have a friend called "Not Playing" that you really dislike? Otherwise Im guessing what you're trying to do is
>
> ```
> If IsPlaying(name)=false then exit function
> ```

You could send a packet to activate a function within the server which isn't even natively accessed by packets as it is?

I'm assuming you just don't understand the fact that these are commands you type through the server interface, it has nothing to do with the client, otherwise you'd be somewhat more correct.
Link to comment
Share on other sites

  • 4 months later...
```

Case "/adm:" & Func, "/adm", "/admin:" & Func, "/admin", "/adminhelp", "/admhelp":

Call TextAdd("adm1:(name) / admin1:(name) / mon:(name) / monitor:(name) = Gives player monitor access.")

Call TextAdd("adm2:(name) / admin2:(name) / map:(name) / mapper:(name) = Gives player mapper access.")

Call TextAdd("adm3:(name) / admin3:(name) / dev:(name) / developer:(name) = Gives player developer access.")

Call TextAdd("adm4:(name) / admin4:(name) / cre:(name) / creator:(name) = Gives player creator access.")

Call TextAdd("radm:(name) / radmin:(name) / player:(name) = Sets player access level back to player.")

Case "/adm1:" & Func, "/admin1:" & Func, "/mon:" & Func, "/monitor:" & Func:

If IsPlaying(Func) = False Then Exit Sub

Call SetPlayerAccess(FindPlayer(Name), ADMIN_MONITOR)

Call SendPlayerData(FindPlayer(Name))

Call PlayerMsg(FindPlayer(Name), "You have been granted administrator access.", BrightCyan)

txtChat.Text = vbNullString

Case "/adm2:" & Func, "/admin2:" & Func, "/map:" & Func, "/mapper:" & Func:

If IsPlaying(Func) = False Then Exit Sub

Call SetPlayerAccess(FindPlayer(Name), ADMIN_MAPPER)

Call SendPlayerData(FindPlayer(Name))

Call PlayerMsg(FindPlayer(Name), "You have been granted administrator access.", BrightCyan)

txtChat.Text = vbNullString

Case "/adm3:" & Func, "/admin3:" & Func, "/dev:" & Func, "/developer:" & Func:

If IsPlaying(Func) = False Then Exit Sub

Call SetPlayerAccess(FindPlayer(Name), ADMIN_DEVELOPER)

Call SendPlayerData(FindPlayer(Name))

Call PlayerMsg(FindPlayer(Name), "You have been granted administrator access.", BrightCyan)

txtChat.Text = vbNullString

Case "/adm4:" & Func, "/admin4:" & Func, "/cre:" & Func, "/creator:" & Func:

If IsPlaying(Func) = False Then Exit Sub

Call SetPlayerAccess(FindPlayer(Name), ADMIN_CREATOR)

Call SendPlayerData(FindPlayer(Name))

Call PlayerMsg(FindPlayer(Name), "You have been granted administrator access.", BrightCyan)

txtChat.Text = vbNullString

Case "/radm:" & Func, "/radmin:" & Func, "/player:" & Func:

If IsPlaying(Func) = False Then Exit Sub

Call SetPlayerAccess(FindPlayer(Name), 0)

Call SendPlayerData(FindPlayer(Name))

Call PlayerMsg(FindPlayer(Name), "You have had your administrator access revoked.", BrightRed)

txtChat.Text = vbNullString

Case "/ban:" & Func:

If IsPlaying(Func) = False Then Exit Sub

Call ServerBanIndex(FindPlayer(Func))

txtChat.Text = vbNullString

Case "/kill:" & Func:

If IsPlaying(Func) = False Then Exit Sub

Call KillPlayer(FindPlayer(Func))

txtChat.Text = vbNullString

Case "/home:" & Func:

If IsPlaying(Func) = False Then Exit Sub

Call PlayerWarp(FindPlayer(Func), START_MAP, START_X, START_Y)

txtChat.Text = vbNullString

Case "/boot:" & Func:

If IsPlaying(Func) = False Then Exit Sub

If Map(GetPlayerMap(Func)).BootMap = 0 Then Exit Sub

Call PlayerWarp(FindPlayer(Func), Map(GetPlayerMap(Func)).BootMap, Map(GetPlayerMap(Func)).BootX, Map(GetPlayerMap(Func)).BootY)

txtChat.Text = vbNullString

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