SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 27/11/2011, 03:53 AM   #1
Meta
Gangsta
 
Meta's Avatar
 
Join Date: Feb 2010
Posts: 624
Reputation: 47
Exclamation cMd v0.1a (command processor)

~~~ cMd v0.1a ~~~

Hello guys!
Today, I release some very small command processor, like almost everyone else did

It's very fast and REALLY SMALL (some test returned a time of 3ms! Please test yourself xD)

Usage (also included to the include )

- Use "do_cMd;" in "OnPlayerCommandText" to call the command like that:
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    // code ...
    do_cMd;
    // code ...
}

- Define Commands like that (PLEASE USE LOWERCASE LETTERS):
pawn Code:
cMd:command_name;
{
    // code ...
}
... as a standalone function like public or stock.

- playerid and params[] are available in every command, params[] includes the command's parameters you can split with sscanf

(Optional: you can use the variable "cMd" after "do_cMd;" to check if a command was called. It should return 1 then.)

Changelog:
[v0.1a]:
  • Made commands non-casesensitive. Please define commands with lowercase names
[v0.1]:
  • First release

Here you go: Download.
Pastebin

Greetz


PS: Critics and comments are welcome

Last edited by Meta; 27/11/2011 at 02:39 PM.
Meta is offline   Reply With Quote
Old 27/11/2011, 04:39 AM   #2
Kar
Banned
 
Join Date: May 2010
Location: Black Asylum
Posts: 2,938
Reputation: 538
Default Re: cMd (command processor)

pawn Code:
format(cmdtext, 128, "cMd_%s"

looks good but here ^, your using publics right, the max length of a public is like what.. 39? or something.. so no need for 128
Kar is offline   Reply With Quote
Old 27/11/2011, 05:35 AM   #3
Meta
Gangsta
 
Meta's Avatar
 
Join Date: Feb 2010
Posts: 624
Reputation: 47
Default AW: Re: cMd (command processor)

Quote:
Originally Posted by Kar View Post
pawn Code:
format(cmdtext, 128, "cMd_%s"

looks good but here ^, your using publics right, the max length of a public is like what.. 39? or something.. so no need for 128
it's 32, yes
I'll change it

EDIT: Please someone test the speed ... I really got 2-4 milliseconds (GetTickCount)
Meta is offline   Reply With Quote
Old 27/11/2011, 05:50 AM   #4
[Nikk]
High-roller
 
[Nikk]'s Avatar
 
Join Date: Jun 2011
Location: Argentina.
Posts: 1,471
Reputation: 63
Default Respuesta: cMd (command processor)

Very nice.
__________________


[Nikk] is offline   Reply With Quote
Old 27/11/2011, 09:35 AM   #5
wups
High-roller
 
wups's Avatar
 
Join Date: Apr 2010
Posts: 1,216
Reputation: 141
Default Re: cMd (command processor)

change
if(!strlen(cMdtMp[1]))
to
if(isnull(cMdtMp[1]))

or even
if(sscanf(cmdtext[1], "sS(' ')", cMdtMp[0], cMdtMp[1]))
THE CORRECT CODE WOULD BE:

pawn Code:
#define do_cMd; \
new cMdtMp[2][128], cMd;  \
sscanf(cmdtext[1], "sS(' ')", cMdtMp[0], cMdtMp[1]) format(cmdtext, 32, "cMd_%s", cMdtMp[0]);\
if(funcidx(cmdtext) != -1) { if(!cMd) { cMd = 1; CallLocalFunction(cmdtext, "ds", playerid, cMdtMp[1]); } }
Not sure how default string is defined in sscanf.
However, if you don't use optional string in sscanf, then cMdtMp[0] will also be empty if there were no params.
Cheers.

Edit: You should make it NON case sensitive.

Last edited by wups; 27/11/2011 at 11:17 AM.
wups is offline   Reply With Quote
Old 27/11/2011, 09:44 AM   #6
Danny
High-roller
 
Danny's Avatar
 
Join Date: Jul 2010
Location: In a galaxy far far away, near the Netherlands
Posts: 1,097
Reputation: 2128
Default Re: cMd (command processor)

It looks very good, but do you have some proof to support your 3ms-story? This sounds amazing!
__________________
I hate reputation-askers, so DON'T ASK, JUST EARN!

come into my life, it's a man made paradise

http://www.buzzfeed.com/norbertobric...omp-stomp-clap
Danny is offline   Reply With Quote
Old 27/11/2011, 09:46 AM   #7
Max_Coldheart
Guest
 
Posts: n/a
Default Re: cMd (command processor)

I have been waiting for a command processor from you Meta! Good job

(if it really is 3 ms, I'm gonna use it )
  Reply With Quote
Old 27/11/2011, 10:00 AM   #8
Nenad
Huge Clucker
 
Nenad's Avatar
 
Join Date: Jul 2010
Location: Srpski Brod, Bosna i Hercegovina
Posts: 289
Reputation: 33
Default Re: cMd (command processor)

show us your benchmark results ... why would anyone use it if you don't show us your test results ... i recommend you to use this benchmarking http://forum.sa-mp.com/showthread.php?t=218491
__________________
Nenad is offline   Reply With Quote
Old 27/11/2011, 10:08 AM   #9
TheArcher
High-roller
 
TheArcher's Avatar
 
Join Date: Dec 2009
Location: Home
Posts: 2,334
Reputation: 251
Default Re: cMd (command processor)

Quote:
Originally Posted by Nenad View Post
show us your benchmark results ... why would anyone use it if you don't show us your test results ... i recommend you to use this benchmarking http://forum.sa-mp.com/showthread.php?t=218491
That was i wanted to say
__________________
TheArcher is offline   Reply With Quote
Old 27/11/2011, 10:18 AM   #10
[S]trong
Guest
 
Posts: n/a
Default Re: cMd (command processor)

I see where you get the speed, but where is the case sensitive?
  Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] mcmd - Command processor! MrDeath537 Includes 37 05/03/2011 12:07 PM
[HowTo] Fast command processor: DCMD (0.3 Ready) DracoBlue Help Archive 8 28/11/2010 11:13 AM
fast command processor [mad]MLK Help Archive 1 22/08/2009 01:32 AM


All times are GMT. The time now is 05:24 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.