The New World Posted February 26, 2011 Author Share Posted February 26, 2011 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 IfEnd 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 IfEnd 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 More sharing options...
Spiked Posted September 24, 2011 Share Posted September 24, 2011 This doesn't work for me /forgive me if this is some sort of necro post o-o Link to comment Share on other sites More sharing options...
The New World Posted September 24, 2011 Author Share Posted September 24, 2011 You did something wrong. Link to comment Share on other sites More sharing options...
Spiked Posted September 24, 2011 Share Posted September 24, 2011 can't get it to work, sent you a PM =] Link to comment Share on other sites More sharing options...
PKDemon Posted April 25, 2012 Share Posted April 25, 2012 i know this is an old post but i found it and was messing around with it and started making commands with iti have made 2 so farone for making admin and the other removing adminbut plan on making one later onbut here is what i doneafter u replace the code in the first postok 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:Jimmyit will split admin and Jimmythen it will be used in the select case statement which will allow the commands to work rightyou can change the ":" to anything u want but if you change it in the above code you will have to change it in thecommand code tofind this```Case "cls", "clear": txtText.Text = "" txtChat.Text = vbNullString```add this after```Case "adm:" & Func, "admin:" & Func: MakeAdmin (Func) txtChat.Text = vbNullStringCase "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 IfEnd FunctionFunction 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 IfEnd 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 More sharing options...
Joost Posted April 25, 2012 Share Posted April 25, 2012 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 More sharing options...
PKDemon Posted April 25, 2012 Share Posted April 25, 2012 @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 More sharing options...
The New World Posted April 25, 2012 Author Share Posted April 25, 2012 @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 More sharing options...
Joost Posted April 25, 2012 Share Posted April 25, 2012 you're right, im an idiot, did not realize server handled / commands as well. Link to comment Share on other sites More sharing options...
The New World Posted April 25, 2012 Author Share Posted April 25, 2012 Thats the entire basis of this tutorial. Link to comment Share on other sites More sharing options...
PKDemon Posted April 26, 2012 Share Posted April 26, 2012 well i am sure you could make these prolly work through the client but would have to make it my secure Link to comment Share on other sites More sharing options...
bunny123 Posted September 19, 2012 Share Posted September 19, 2012 ```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 SubCall SetPlayerAccess(FindPlayer(Name), ADMIN_MONITOR)Call SendPlayerData(FindPlayer(Name))Call PlayerMsg(FindPlayer(Name), "You have been granted administrator access.", BrightCyan)txtChat.Text = vbNullStringCase "/adm2:" & Func, "/admin2:" & Func, "/map:" & Func, "/mapper:" & Func:If IsPlaying(Func) = False Then Exit SubCall SetPlayerAccess(FindPlayer(Name), ADMIN_MAPPER)Call SendPlayerData(FindPlayer(Name))Call PlayerMsg(FindPlayer(Name), "You have been granted administrator access.", BrightCyan)txtChat.Text = vbNullStringCase "/adm3:" & Func, "/admin3:" & Func, "/dev:" & Func, "/developer:" & Func:If IsPlaying(Func) = False Then Exit SubCall SetPlayerAccess(FindPlayer(Name), ADMIN_DEVELOPER)Call SendPlayerData(FindPlayer(Name))Call PlayerMsg(FindPlayer(Name), "You have been granted administrator access.", BrightCyan)txtChat.Text = vbNullStringCase "/adm4:" & Func, "/admin4:" & Func, "/cre:" & Func, "/creator:" & Func:If IsPlaying(Func) = False Then Exit SubCall SetPlayerAccess(FindPlayer(Name), ADMIN_CREATOR)Call SendPlayerData(FindPlayer(Name))Call PlayerMsg(FindPlayer(Name), "You have been granted administrator access.", BrightCyan)txtChat.Text = vbNullStringCase "/radm:" & Func, "/radmin:" & Func, "/player:" & Func:If IsPlaying(Func) = False Then Exit SubCall SetPlayerAccess(FindPlayer(Name), 0)Call SendPlayerData(FindPlayer(Name))Call PlayerMsg(FindPlayer(Name), "You have had your administrator access revoked.", BrightRed)txtChat.Text = vbNullStringCase "/ban:" & Func:If IsPlaying(Func) = False Then Exit SubCall ServerBanIndex(FindPlayer(Func))txtChat.Text = vbNullStringCase "/kill:" & Func:If IsPlaying(Func) = False Then Exit SubCall KillPlayer(FindPlayer(Func))txtChat.Text = vbNullStringCase "/home:" & Func:If IsPlaying(Func) = False Then Exit SubCall PlayerWarp(FindPlayer(Func), START_MAP, START_X, START_Y)txtChat.Text = vbNullStringCase "/boot:" & Func:If IsPlaying(Func) = False Then Exit SubIf Map(GetPlayerMap(Func)).BootMap = 0 Then Exit SubCall 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now