Mirage Source

Free ORPG making software.
It is currently Sat Apr 27, 2024 5:26 am

All times are UTC


Forum rules


Make sure your tutorials are kept up to date with the latest MS4 releases.



Post new topic Reply to topic  [ 961 posts ]  Go to page 1, 2, 3, 4, 5 ... 39  Next
Author Message
 Post subject: [MS4] Kill Command
PostPosted: Mon Sep 15, 2008 1:59 am 
Offline
Regular
User avatar

Joined: Tue Jun 17, 2008 12:39 pm
Posts: 55
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


Last edited by DarkC on Tue Sep 16, 2008 1:35 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Mon Sep 15, 2008 2:39 am 
Offline
Regular
User avatar

Joined: Tue Jun 17, 2008 12:39 pm
Posts: 55
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...


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Mon Sep 15, 2008 3:42 am 
Offline
Regular
User avatar

Joined: Tue Jun 17, 2008 12:39 pm
Posts: 55
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.


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Mon Sep 15, 2008 11:51 am 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
Nice. Glad to see people writing up tutorials again.

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Mon Sep 15, 2008 11:03 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
Robin wrote:
Nice. Glad to see people writing up tutorials again.


As am I. Great job, DarkC. I'll be sure to use this.

_________________
Image
GIAKEN wrote:
Since I'm into men, not women

GIAKEN wrote:
I can't take these huge penises anymore! All that's left is shame! And blood


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Mon Sep 15, 2008 11:13 pm 
Offline
Regular
User avatar

Joined: Tue Jun 17, 2008 12:39 pm
Posts: 55
Thanks, I'm glad you find it useful.


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Tue Sep 16, 2008 12:39 am 
Offline
Regular

Joined: Sat Sep 13, 2008 1:41 am
Posts: 97
Another nice tutorial


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Tue Sep 16, 2008 12:44 am 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
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)

_________________
Image
GIAKEN wrote:
Since I'm into men, not women

GIAKEN wrote:
I can't take these huge penises anymore! All that's left is shame! And blood


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Tue Sep 16, 2008 12:57 am 
Offline
Regular
User avatar

Joined: Tue Jun 17, 2008 12:39 pm
Posts: 55
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.


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Tue Sep 16, 2008 1:09 am 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
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

_________________
Image
GIAKEN wrote:
Since I'm into men, not women

GIAKEN wrote:
I can't take these huge penises anymore! All that's left is shame! And blood


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Tue Sep 16, 2008 1:22 am 
Offline
Regular
User avatar

Joined: Tue Jun 17, 2008 12:39 pm
Posts: 55
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


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Tue Sep 16, 2008 1:28 am 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
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

_________________
Image
GIAKEN wrote:
Since I'm into men, not women

GIAKEN wrote:
I can't take these huge penises anymore! All that's left is shame! And blood


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Tue Sep 16, 2008 1:30 am 
Offline
Regular
User avatar

Joined: Tue Jun 17, 2008 12:39 pm
Posts: 55
Oopsie, meant to put that in there. Just forgot to. xD


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Tue Sep 16, 2008 1:33 am 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
DarkC wrote:
Oopsie, meant to put that in there. Just forgot to. xD


Regardless, your idea lead to me getting it. So thanks!

_________________
Image
GIAKEN wrote:
Since I'm into men, not women

GIAKEN wrote:
I can't take these huge penises anymore! All that's left is shame! And blood


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Tue Sep 16, 2008 1:35 am 
Offline
Regular
User avatar

Joined: Tue Jun 17, 2008 12:39 pm
Posts: 55
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.


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Thu Sep 18, 2008 2:56 am 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
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

_________________
Image
GIAKEN wrote:
Since I'm into men, not women

GIAKEN wrote:
I can't take these huge penises anymore! All that's left is shame! And blood


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Thu Sep 18, 2008 3:09 am 
Offline
Persistant Poster
User avatar

Joined: Tue May 30, 2006 2:07 am
Posts: 836
Location: Nashville, Tennessee, USA
Google Talk: rs.ruggles@gmail.com
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

_________________
I'm on Facebook! Google Plus My Youtube Channel My Steam Profile

Image


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Thu Sep 18, 2008 3:29 am 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
I've never gotten the point of VbNullString, anyone care to explain?

_________________
Image
GIAKEN wrote:
Since I'm into men, not women

GIAKEN wrote:
I can't take these huge penises anymore! All that's left is shame! And blood


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Thu Sep 18, 2008 3:58 am 
Offline
Persistant Poster
User avatar

Joined: Tue May 30, 2006 2:07 am
Posts: 836
Location: Nashville, Tennessee, USA
Google Talk: rs.ruggles@gmail.com
Ask Lea about the technical stuff. From what I understand though, vbNullString is faster than using "". They also seem completely interchangeable.

_________________
I'm on Facebook! Google Plus My Youtube Channel My Steam Profile

Image


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Thu Sep 18, 2008 4:21 am 
Offline
Community Leader
User avatar

Joined: Sun May 28, 2006 10:29 pm
Posts: 1762
Location: Salt Lake City, UT, USA
Google Talk: Darunada@gmail.com
vbNullString is a constant provided by VB6 that represents a null (empty) string.

_________________
I'm on Facebook! Google Plus LinkedIn My Youtube Channel Send me an email Call me with Skype Check me out on Bitbucket Yup, I'm an EVE Online player!
Why not try my app, ColorEye, on your Android devlce?
Do you like social gaming? Fight it out in Battle Juice!

I am a professional software developer in Salt Lake City, UT.


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Thu Sep 18, 2008 4:26 am 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
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?

_________________
Image
GIAKEN wrote:
Since I'm into men, not women

GIAKEN wrote:
I can't take these huge penises anymore! All that's left is shame! And blood


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Thu Sep 18, 2008 4:26 am 
Offline
Community Leader
User avatar

Joined: Sun May 28, 2006 10:29 pm
Posts: 1762
Location: Salt Lake City, UT, USA
Google Talk: Darunada@gmail.com
yup

_________________
I'm on Facebook! Google Plus LinkedIn My Youtube Channel Send me an email Call me with Skype Check me out on Bitbucket Yup, I'm an EVE Online player!
Why not try my app, ColorEye, on your Android devlce?
Do you like social gaming? Fight it out in Battle Juice!

I am a professional software developer in Salt Lake City, UT.


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Thu Sep 18, 2008 5:55 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
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


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Mon Sep 22, 2008 7:32 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
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.

_________________
Image
GIAKEN wrote:
Since I'm into men, not women

GIAKEN wrote:
I can't take these huge penises anymore! All that's left is shame! And blood


Top
 Profile  
 
 Post subject: Re: [MS4] Kill Command
PostPosted: Mon Sep 22, 2008 7:39 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 961 posts ]  Go to page 1, 2, 3, 4, 5 ... 39  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 29 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group