Mirage Source http://www.miragesource.net/forums/ |
|
[MS4] Kill Command http://www.miragesource.net/forums/viewtopic.php?f=183&t=4322 |
Page 1 of 39 |
Author: | DarkC [ Mon Sep 15, 2008 1:59 am ] |
Post subject: | [MS4] Kill Command |
Ok...This code is for MS4, and what is does is if a admin with level 4 or higher access types "/kill (playernamehere)" they die, and get warped back to the starting area. I love MS4, it made making this code easier than it would have been in last MS. Anyway... Difficulty: 1/5 ::Client Side:: In modGameLogic under the following code: Code: ' // Commands // ' Help If Mid$(MyText, 1, 5) = "/help" Then Call AddText("Social Commands:", HelpColor) Call AddText("'msghere = Broadcast Message", HelpColor) Call AddText("-msghere = Emote Message", HelpColor) Call AddText("!namehere msghere = Player Message", HelpColor) Call AddText("Available Commands: /help, /info, /who, /fps, /inv, /stats, /train, /trade, /party, /join, /leave", HelpColor) MyText = vbNullString frmMirage.txtMyChat.Text = vbNullString Exit Sub End If Add this: Code: ' Kill player If Mid$(MyText, 1, 5) = "/kill" Then If Len(MyText) > 6 Then MyText = Mid(MyText, 6, Len(MyText) - 5) Call SendData(CKillPlayer & SEP_CHAR & MyText & END_CHAR) End If MyText = "" Exit Sub End If Then in modEnumerations under the following code: Code: CGetClasses = 1 Add this: Code: CKillPlayer ::Server Side:: In modHandleData at the bottom, but before "End Sub" and "End Select" add the following code: Code: ' :::::::::::::::::::::::: ' :: Kill Player Packet :: ' :::::::::::::::::::::::: Case CKillPlayer ' Prevent hacking... If GetPlayerAccess(Index) < ADMIN_CREATOR Then Call HackingAttempt(Index, "Admin Cloning") Exit Sub End If n = FindPlayer(Parse(1)) If n <> Index Then If n > 0 Then 'Sends messages out Call PlayerMsg(n, "You have been killed by an admin.", BrightRed) Call GlobalMsg(GetPlayerName(n) & " has been killed by an admin.", BrightRed) 'Warp to starting map Call PlayerWarp(n, START_MAP, START_X, START_Y) Call SetPlayerPK(Index, NO) Else Call PlayerMsg(Index, "Player is not online.", White) End If Else Call PlayerMsg(Index, "You cannot kill yourself!", White) End If Exit Sub Then in modEnumerations under the following code: Code: CGetClasses = 1 Add this: Code: CKillPlayer All done! I tested this out, and it worked perfectly. If you find any problems or errors, I'll be more than happy to try to resolve them for you. *update* If you want it in button format use the code below. Just change the "Txtchar.Text" part to whatever text box name you want it to get the name of the player you want to kill. Add this code rather than the "/kill" code above. Make sure you add ALL the other code in the tutorial above, you have to add everything else and it'll work. Code: Private Sub cmdkill_Click()
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then Call SendData(CKillPlayer & SEP_CHAR & Txtchar.Text & END_CHAR) End If End Sub |
Author: | DarkC [ Mon Sep 15, 2008 2:39 am ] |
Post subject: | Re: [MS4] Kill Command |
Why would it need to be elaborated any? It sends the player right to the starting area, X, and Y. Just like how I want it, people can specify another map, X, and Y if they wanted of course... |
Author: | DarkC [ Mon Sep 15, 2008 3:42 am ] |
Post subject: | Re: [MS4] Kill Command |
DFA wrote: maybe based on race...class...faction....err level? PK status or not... Oh, I thought you meant something else. My mistake. This is just a simple version of the code, I might post variations of it like based on level and PK status like you suggested. |
Author: | Robin [ Mon Sep 15, 2008 11:51 am ] |
Post subject: | Re: [MS4] Kill Command |
Nice. Glad to see people writing up tutorials again. |
Author: | Nean [ Mon Sep 15, 2008 11:03 pm ] |
Post subject: | Re: [MS4] Kill Command |
Robin wrote: Nice. Glad to see people writing up tutorials again. As am I. Great job, DarkC. I'll be sure to use this. |
Author: | DarkC [ Mon Sep 15, 2008 11:13 pm ] |
Post subject: | Re: [MS4] Kill Command |
Thanks, I'm glad you find it useful. |
Author: | skillzalot [ Tue Sep 16, 2008 12:39 am ] |
Post subject: | Re: [MS4] Kill Command |
Another nice tutorial |
Author: | Nean [ Tue Sep 16, 2008 12:44 am ] |
Post subject: | Re: [MS4] Kill Command |
So, lets say I wanted to add this to a button macro, and then type the users name in a textbox, called txtchar, and then push the kill button, and it will kill the char... How would I go about this. (If that makes sense) |
Author: | DarkC [ Tue Sep 16, 2008 12:57 am ] |
Post subject: | Re: [MS4] Kill Command |
Nean wrote: So, lets say I wanted to add this to a button macro, and then type the users name in a textbox, called txtchar, and then push the kill button, and it will kill the char... How would I go about this. (If that makes sense) Basically you want it like Elysium Diamond has their Warp Me To command in the Admin Panel? If you want it like that, I'll try to figure out a way to do that tonight. |
Author: | Nean [ Tue Sep 16, 2008 1:09 am ] |
Post subject: | Re: [MS4] Kill Command |
DarkC wrote: Nean wrote: So, lets say I wanted to add this to a button macro, and then type the users name in a textbox, called txtchar, and then push the kill button, and it will kill the char... How would I go about this. (If that makes sense) Basically you want it like Elysium Diamond has their Warp Me To command in the Admin Panel? If you want it like that, I'll try to figure out a way to do that tonight. If it helps, this is what I'm trying to do, only with your /kill command Code: Private Sub cmdkick_Click()
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then Call SendKick(Trim(Txtchar.Text)) End If End Sub |
Author: | DarkC [ Tue Sep 16, 2008 1:22 am ] |
Post subject: | Re: [MS4] Kill Command |
You should be able to do this...Someone correct me if I'm wrong, as to I haven't tested this out, sense I'm working on something else at the moment. But I'm pretty sure this'll work... Code: Private Sub cmdkill_Click() If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then Call SendData(CKillPlayer & SEP_CHAR & MyText & END_CHAR) End If End Sub Then you just need to add the CKillPlayer into the modEnumerations of course, and add all the code in my tutorial to the server. Then it should work...Tell me if it does. =D |
Author: | Nean [ Tue Sep 16, 2008 1:28 am ] |
Post subject: | Re: [MS4] Kill Command |
DarkC wrote: You should be able to do this...Someone correct me if I'm wrong, as to I haven't tested this out, sense I'm working on something else at the moment. But I'm pretty sure this'll work... Code: Private Sub cmdkill_Click() If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then Call SendData(CKillPlayer & SEP_CHAR & MyText & END_CHAR) End If End Sub Then you just need to add the CKillPlayer into the modEnumerations of course, and add all the code in my tutorial to the server. Then it should work...Tell me if it does. =D It says "You cannot kill yourself" It's targeting me, because theres no way to make it link to the textbox. Thats all I need to know, is how to make it link to the textbox, rather than mytext. EDIT: This worked: Code: Private Sub cmdkill_Click()
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then Call SendData(CKillPlayer & SEP_CHAR & Txtchar.Text & END_CHAR) End If End Sub |
Author: | DarkC [ Tue Sep 16, 2008 1:30 am ] |
Post subject: | Re: [MS4] Kill Command |
Oopsie, meant to put that in there. Just forgot to. xD |
Author: | Nean [ Tue Sep 16, 2008 1:33 am ] |
Post subject: | Re: [MS4] Kill Command |
DarkC wrote: Oopsie, meant to put that in there. Just forgot to. xD Regardless, your idea lead to me getting it. So thanks! |
Author: | DarkC [ Tue Sep 16, 2008 1:35 am ] |
Post subject: | Re: [MS4] Kill Command |
No problem, thanks for showing interest. =D I updated the first post with the button code for in the future if someone wants it that way. |
Author: | Nean [ Thu Sep 18, 2008 2:56 am ] |
Post subject: | Re: [MS4] Kill Command |
I found an error with this code. When you type /kill (playername), the text doesn't submit through, though the command executes. Along with the error, I found a fix. Replace the old /kill code with this. Code: ' Kill player If Mid$(MyText, 1, 5) = "/kill" Then If Len(MyText) > 6 Then MyText = Mid(MyText, 6, Len(MyText) - 5) Call SendData(CKillPlayer & SEP_CHAR & MyText & END_CHAR) End If MyText = vbNullString frmMirage.txtMyChat.Text = vbNullString Exit Sub End If *bows*. I'm so 1337 |
Author: | Rian [ Thu Sep 18, 2008 3:09 am ] |
Post subject: | Re: [MS4] Kill Command |
Code: ' Kill player If Mid$(MyText, 1, 5) = "/kill" Then If Len(MyText) > 6 Then MyText = Mid(MyText, 6, Len(MyText) - 5) Call SendData(CKillPlayer & SEP_CHAR & MyText & END_CHAR) MyText = vbNullString End If Exit Sub End If Should work too |
Author: | Nean [ Thu Sep 18, 2008 3:29 am ] |
Post subject: | Re: [MS4] Kill Command |
I've never gotten the point of VbNullString, anyone care to explain? |
Author: | Rian [ Thu Sep 18, 2008 3:58 am ] |
Post subject: | Re: [MS4] Kill Command |
Ask Lea about the technical stuff. From what I understand though, vbNullString is faster than using "". They also seem completely interchangeable. |
Author: | Lea [ Thu Sep 18, 2008 4:21 am ] |
Post subject: | Re: [MS4] Kill Command |
vbNullString is a constant provided by VB6 that represents a null (empty) string. |
Author: | Nean [ Thu Sep 18, 2008 4:26 am ] |
Post subject: | Re: [MS4] Kill Command |
Lea wrote: vbNullString is a constant provided by VB6 that represents a null (empty) string. I see, thanks. So basically in that code its saying: Mytext = Nothing? |
Author: | Lea [ Thu Sep 18, 2008 4:26 am ] |
Post subject: | Re: [MS4] Kill Command |
yup |
Author: | Jacob [ Thu Sep 18, 2008 5:55 pm ] |
Post subject: | Re: [MS4] Kill Command |
This tutorial is out of date now if you are using v3.51. http://web.miragesource.com/forums/viewtopic.php?f=124&t=4353 Code: ' Kill player
Case "/kill" If GetPlayerAccess(MyIndex) >= ADMIN_CREATOR Then If UBound(Command) >= 1 Then SendData CKillPlayer & SEP_CHAR & Command(1) & END_CHAR End If End If End If |
Author: | Nean [ Mon Sep 22, 2008 7:32 pm ] |
Post subject: | Re: [MS4] Kill Command |
This tutorial is out of date! Lucky for you wankers (hehe), I remade it for the newest version. YAY. =[ Server Under: Code: ' :: Quit game packet :: Add: Code: ' :::::::::::::::::::::::: ' :: Kill Player Packet :: ' :::::::::::::::::::::::: Sub HandleKillPlayer(ByVal Index As Long, ByRef Parse() As String) Dim N ' Prevent hacking... If GetPlayerAccess(Index) < ADMIN_CREATOR Then Call HackingAttempt(Index, "Admin Cloning") Exit Sub End If N = FindPlayer(Parse(1)) If N <> Index Then If N > 0 Then 'Sends messages out Call PlayerMsg(N, "You have been killed by an admin.", BrightRed) Call GlobalMsg(GetPlayerName(N) & " has been killed by an admin.", BrightRed) 'Warp to starting map Call PlayerWarp(N, START_MAP, START_X, START_Y) Call SetPlayerPK(Index, NO) Else Call PlayerMsg(Index, "Player is not online.", White) End If Else Call PlayerMsg(Index, "You cannot kill yourself!", White) End If End Sub Then find: Code: HandleKickPlayer Index, Parse Add this under that: Code: Case CkillPlayer HandleKillPlayer Index, Parse Remember, this is just the newest change. The client hasn't changed. |
Author: | Jacob [ Mon Sep 22, 2008 7:39 pm ] |
Post subject: | Re: [MS4] Kill Command |
Code: Dim N Make sure to give your variables a type. If you don't then they are considered 'Variants' and are very slow. Code: dim n as long
|
Page 1 of 39 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |