Mirage Source

Free ORPG making software.
It is currently Sat Apr 27, 2024 9:39 pm

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  [ 1605 posts ]  Go to page 1, 2, 3, 4, 5 ... 65  Next
Author Message
PostPosted: Thu Sep 18, 2008 5:52 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
MS4
v3.51

Adding new /commands like /kill or /mute have changed. They are now structured like the packet system.
Reference: http://web.miragesource.com/forums/viewtopic.php?f=120&t=4331#p52200

HandleKeyPresses

Find
Code:
If Left$(MyText, 1) = "/" Then
            Command = Split(MyText, " ")


It will first get the text that you have typed in and will split it wherever a space is.
Example:
You type in "/info Admin".
The split function will then create the following array.
Command(0) = "/info"
Command(1) = "Admin"

So now we have to select what the command was and do something with it.
After
Code:
Select Case Command(0)

You'll have all the select statements.

Example
Code:
Case "/info"
                    ' Checks to make sure we have more than one string in the array
                    If UBound(Command) >= 1 Then
                        Call SendData(CPlayerInfoRequest & SEP_CHAR & Command(1) & END_CHAR)
                    End If


As you can see we have to add
Code:
 If UBound(Command) >= 1 Then

This will be our error checking, since we know that we have to have the "/Command' and an additional piece of info, we have to make sure our array contains the right amount of elements.
If you know you need 4 pieces of info for your command you would have to do something like
Code:
 If UBound(Command) >= 5 Then

1 for your command and 4 additional pieces of info.

Then you can access the strings in your command with
Code:
Command(NumberYouNeed)


Little thing on Val() to convert to a numerical value. It would be better to use the correct conversion.
For example if you know your string needs to be a long then you would do:
Code:
CLng(Command(1))


Clng() - Converts to a long
CInt() - Converts to an integer
Cbyte() - Converts to a byte

Now before we convert we want to make sure we have a valid number first.

A good check would be
Code:
If IsNumeric(Command(1)) Then
     SendSetAccess Command(2), CLng(Command(1))
End If


MAKE SURE TO CHECK ISNUMERIC BEFORE CONVERTING OTHERWISE YOU WILL GET ERRORS IF SOMEONE TYPES IN ANYTHING BESIDES A NUMBER.

I think that's it. If I'm missing something or didn't explain things well please let me know.


Last edited by Jacob on Fri Sep 19, 2008 3:26 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Adding new /commands
PostPosted: Thu Sep 18, 2008 6:26 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
Wow. Now things are complicated again. It's gonna take some time to get used to this again.

_________________
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: Adding new /commands
PostPosted: Thu Sep 18, 2008 6:31 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
It's a lot easier this way. You don't have to do letter counting or anything.

Let's say you have your "/mute player" command.

So you add
Code:
Case "/mute"
                    If UBound(Command) >= 1 Then
                        sendMutePlayer MyIndex, CLng(Command(1))
                    End If


Code:
If UBound(Command) >= 1 Then

That makes sure you have the command and the player to mute.

Code:
sendMutePlayer MyIndex, CLng(Command(1))

Psuedo code - dunno what your function is

And that's it to add the /command.


Top
 Profile  
 
 Post subject: Re: Adding new /commands
PostPosted: Thu Sep 18, 2008 6:48 pm 
Offline
Persistant Poster
User avatar

Joined: Fri Aug 15, 2008 3:11 pm
Posts: 633
so
all you do is really replace
sendMutePlayer MyIndex, CLng(Command(1))
correct?

_________________
╔╗╔═╦═╦══╦═══╗
║║║║║║║╔╗║╔═╗║
║║║║║║║╚╝║║║║║
║╚╣║║║║╔╗║╚═╝║
╚═╩╩═╩╩╝╚╩═══╝


╔╦═╦╦════╦═══╗
║║║║╠═╗╔═╣╔══╝
║║║║║║║║╚═╗
║║║║║║║║╔═╝
╚═╩═╝╚╝╚╝ ?


Top
 Profile  
 
 Post subject: Re: Adding new /commands
PostPosted: Thu Sep 18, 2008 6:50 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
doomteam1 wrote:
so
all you do is really replace
sendMutePlayer MyIndex, CLng(Command(1))
correct?


And add in the
Code:
If UBound(Command) >= 1 Then

_________________
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: Adding new /commands
PostPosted: Thu Sep 18, 2008 6:53 pm 
Offline
Persistant Poster
User avatar

Joined: Fri Aug 15, 2008 3:11 pm
Posts: 633
Code:
 sendMutePlayer MyIndex, CLng(Command(1))


The one is saying what word it is correct?
after 0 right
like
sendMuteplayer blah(command(1)
sendMuteServer blah(command(2)

or what?
cause i dont get the number

_________________
╔╗╔═╦═╦══╦═══╗
║║║║║║║╔╗║╔═╗║
║║║║║║║╚╝║║║║║
║╚╣║║║║╔╗║╚═╝║
╚═╩╩═╩╩╝╚╩═══╝


╔╦═╦╦════╦═══╗
║║║║╠═╗╔═╣╔══╝
║║║║║║║║╚═╗
║║║║║║║║╔═╝
╚═╩═╝╚╝╚╝ ?


Top
 Profile  
 
 Post subject: Re: Adding new /commands
PostPosted: Thu Sep 18, 2008 7:17 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
This makes things a lot better.

However, all command handling should be in the server. You could send a packet like:

Code:
packet = "commands" & SEP_CHAR & Command(0)

If UBound(Command) > 0 Then
    packet = packet & SEP_CHAR & UBound(Command(0))
    For i = 1 To UBound(Command)
        packet = packet & SEP_CHAR & Command(i)
    Next i
Else
    packet = packet & SEP_CHAR & 0
End If

    packet = packet & END_CHAR


Server would do:

Code:
Select Case Parse$(1)
    If Val(Parse$(2)) = 0 Then
        Case "/help"
        'seperate the commands that are only single
    End If

    If Val(Parse$(2)) = 1 Then
        'seperate the commands that have a second parameter
        Case "/mute"
    End If
End Select


Something like that...thoughts?

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
 Post subject: Re: Adding new /commands
PostPosted: Thu Sep 18, 2008 9:33 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
GIAKEN wrote:
This makes things a lot better.

However, all command handling should be in the server. You could send a packet like:

Code:
packet = "commands" & SEP_CHAR & Command(0)

If UBound(Command) > 0 Then
    packet = packet & SEP_CHAR & UBound(Command(0))
    For i = 1 To UBound(Command)
        packet = packet & SEP_CHAR & Command(i)
    Next i
Else
    packet = packet & SEP_CHAR & 0
End If

    packet = packet & END_CHAR


Server would do:

Code:
Select Case Parse$(1)
    If Val(Parse$(2)) = 0 Then
        Case "/help"
        'seperate the commands that are only single
    End If

    If Val(Parse$(2)) = 1 Then
        'seperate the commands that have a second parameter
        Case "/mute"
    End If
End Select


Something like that...thoughts?


I could go for a banana right now.

_________________
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: Adding new /commands
PostPosted: Thu Sep 18, 2008 11:20 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
Robin wrote:
GIAKEN wrote:
This makes things a lot better.

However, all command handling should be in the server. You could send a packet like:

Code:
packet = "commands" & SEP_CHAR & Command(0)

If UBound(Command) > 0 Then
    packet = packet & SEP_CHAR & UBound(Command(0))
    For i = 1 To UBound(Command)
        packet = packet & SEP_CHAR & Command(i)
    Next i
Else
    packet = packet & SEP_CHAR & 0
End If

    packet = packet & END_CHAR


Server would do:

Code:
Select Case Parse$(1)
    If Val(Parse$(2)) = 0 Then
        Case "/help"
        'seperate the commands that are only single
    End If

    If Val(Parse$(2)) = 1 Then
        'seperate the commands that have a second parameter
        Case "/mute"
    End If
End Select


Something like that...thoughts?


I could go for a banana right now.


Tarantulas lay their eggs in bananas.

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
 Post subject: Re: Adding new /commands
PostPosted: Fri Sep 19, 2008 12:35 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
Personally I would leave them client side.

If you do the proper checks server side it wouldn't matter what they have access to on the client.


Top
 Profile  
 
PostPosted: Tue Sep 23, 2008 1:50 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
Added a little bit about checking IsNumeric before using the conversion. This will protect you against RTEs.


Top
 Profile  
 
PostPosted: Wed Dec 01, 2021 7:32 am 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 489757
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтsemiasphalticfluxсайтсайтсайт
сайтсайтсайтсайтсайтсайтhttp://taskreasoning.ruсайтсайтсайтинфосайтсайтtuchkasсайтсайт


Top
 Profile  
 
PostPosted: Sun Dec 26, 2021 1:57 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 489757
Vrin


Top
 Profile  
 
PostPosted: Sun Dec 26, 2021 1:58 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 489757
37.6


Top
 Profile  
 
PostPosted: Sun Dec 26, 2021 2:00 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 489757
Bett


Top
 Profile  
 
PostPosted: Sun Dec 26, 2021 2:01 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 489757
Bett


Top
 Profile  
 
PostPosted: Sun Dec 26, 2021 2:02 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 489757
Rael


Top
 Profile  
 
PostPosted: Sun Dec 26, 2021 2:03 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 489757
Colu


Top
 Profile  
 
PostPosted: Sun Dec 26, 2021 2:04 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 489757
Bana


Top
 Profile  
 
PostPosted: Sun Dec 26, 2021 2:05 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 489757
Henr


Top
 Profile  
 
PostPosted: Sun Dec 26, 2021 2:06 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 489757
BNIA


Top
 Profile  
 
PostPosted: Sun Dec 26, 2021 2:07 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 489757
Medi


Top
 Profile  
 
PostPosted: Sun Dec 26, 2021 2:09 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 489757
Brot


Top
 Profile  
 
PostPosted: Sun Dec 26, 2021 2:10 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 489757
Orie


Top
 Profile  
 
PostPosted: Sun Dec 26, 2021 2:11 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 489757
Enns


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 32 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:  
Powered by phpBB® Forum Software © phpBB Group