SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 04/04/2014, 05:31 PM   #1
Mr.Hardy
Huge Clucker
 
Mr.Hardy's Avatar
 
Join Date: Dec 2011
Location: Brazil (SC)
Posts: 442
Reputation: 61
Default h_Cmd | Command processor

h_Cmd


The h_Cmd has the primary purpose of processing commands with ease and still delete the famous use of sscanf in commands. It is based on CallLocalFunction and function Split (split by delimiters).


Attention:
I'm not good in english, are used the help of translator..

Functions
pawn Code:
SPLIT<number> //Used to get a string from a command argument.
SPLIT_INT<number> //Used to get a number from a command argument.
SPLIT_FLOAT<number> //Used to get a float from a command argument.
TOTAL_SPLIT<> //Returns the total of arguments placed in command .. Example: "/x [arg1] [arg2] [arg3]" returns the value 3.
forward OnPlayerExecuteCommand(playerid, cmdtext[], bool:sucess); //Callback designed to block or detect if the command does not exist.

Learn
pawn Code:
h_Cmd("/gta")
{
    SendClientMessage(playerid, -1, "I'm testing");
    return true;
}

h_Cmd("/telepos")
{
    if(TOTAL_SPLIT<> != 3) //TOTAL_SPLIT<> Returns the total amount of arguments in the example here is 3.
    {
        SendClientMessage(playerid, -1, "Uso: /telepos [X] [Y] [Z]");
        return true;
    }
    SetPlayerPos(playerid, SPLIT_FLOAT<1>, SPLIT_FLOAT<2>, SPLIT_FLOAT<3>); //SPLIT_FLOAT<number> returns the total amount of arguments in the example here is 3..
    return true;
}

h_Cmd("/ann")
{
    if(!TOTAL_SPLIT<>) //TOTAL_SPLIT<> returns the number of arguments after the command
    {
        SendClientMessage(playerid, -1, "Uso: /ann [Announce]");
        return true;
    }
    new string[144];
    format(string, 144, "ANNOUNCE: %s",SPLIT<1>); //SPLIT<number> get the number 1 used in the command argument. Ex: /ann [Argument 1].. Returns in string.
    SendClientMessageToAll(-1, string);
    return true;
}

h_Cmd("/number")
{
    if(!TOTAL_SPLIT<>) //TOTAL_SPLIT<> returns the number of arguments after the command
    {
        SendClientMessage(playerid, -1, "Uso: /number [your number]");
        return true;
    }
    new string[144];
    format(string, 144, "MY NUMBER: %d",SPLIT_INT<1>); //SPLIT_INT<number> get the number 1 used in the command argument. Ex: /number [Argument 1].. Returns in number.
    SendClientMessageToAll(-1, string);
    return true;
}

public OnPlayerExecuteCommand(playerid, cmdtext[], bool:sucess)
{
    if(sucess == false) return SendClientMessage(playerid, 0xFFFF00FF, "[INFO] UNKNOWN COMMAND"); //Example
    if(!strcmp(cmdtext, "/gta", true))//Example to block command
    {
        SendClientMessage(playerid, -1, "COMMAND INHIBIT");
        return false;
    }
    return true;
}

Important
  1. Like all other systems of the command processors, the h_Cmd will lock the controls created in OnPlayerCommandText(); in the script you are using is include.

Installation
  1. Enter the include after the include "a_samp".

Download Include
Changelog
  • 0.1 Initial release.

Credits
Attention:
Not give permission for any alleged or posting on another forum of this forum.
__________________


Dispositivos:
- Nokia Lumia 825
- Gran Duos ( primeira geração )
- iPhone 5S
- iPhone 5C
- iPhone 6
- iPad 2G (wi-fi 2012)
- Sony Playstation 2
- Sony Playstation 3 (Assassin's Creed: Brotherhood | FIFA 11 | Uncharted 3)
- Xbox One (GTA V | FIFA 14 | Battlefield 4 | Titanfall | Watch Dogs | FIFA 15 | Battlefield 5 | UFC | Need For Speed: Rivals | Dragon Age: Inquisition)

Last edited by Mr.Hardy; 04/04/2014 at 06:15 PM.
Mr.Hardy is offline   Reply With Quote
Old 04/04/2014, 05:36 PM   #2
UnknownOwner
Banned
 
Join Date: Jan 2014
Posts: 368
Reputation: 38
Default Re: h_Cmd | Command processor

Nice. Hope to see more releases from you.
Going to test it and report you any bug, if found.
UnknownOwner is offline   Reply With Quote
Old 04/04/2014, 05:42 PM   #3
FailerZ
Huge Clucker
 
FailerZ's Avatar
 
Join Date: Oct 2013
Posts: 243
Reputation: 43
Default Re: h_Cmd | Command processor

Nice, I will test it
__________________
My old work:
[FilterScript]Digital Health & Armour [DHA]
[FilterScript]Labels Creator [LC]
[FilterScript]Debug Mode [D-Mode]
[FilterScript]Advance Fish System [AFS]
FailerZ is offline   Reply With Quote
Old 04/04/2014, 05:54 PM   #4
iZN
High-roller
 
Join Date: Jun 2010
Posts: 2,369
Reputation: 569
Default Re: h_Cmd | Command processor

Mind doing some test with ZCMD and y_cmds? Also, using split function is very slow as compared to sscanf, try to use sscanf and see the results.
__________________
iZN is offline   Reply With Quote
Old 04/04/2014, 06:19 PM   #5
Mr.Hardy
Huge Clucker
 
Mr.Hardy's Avatar
 
Join Date: Dec 2011
Location: Brazil (SC)
Posts: 442
Reputation: 61
Default Re: h_Cmd | Command processor

Quote:
Originally Posted by UnknownOwner View Post
Nice. Hope to see more releases from you.
Going to test it and report you any bug, if found.
Thank you, but there are other releases in the Portuguese area will translate soon

Quote:
Originally Posted by FailerZ View Post
Nice, I will test it
Thanks "bro"

Quote:
Originally Posted by iZN View Post
Mind doing some test with ZCMD and y_cmds? Also, using split function is very slow as compared to sscanf, try to use sscanf and see the results.
Its introduction has already warned that the use is not required .. I'm still optimizing is more include any claim of bug is acceptable at this time ...
__________________


Dispositivos:
- Nokia Lumia 825
- Gran Duos ( primeira geração )
- iPhone 5S
- iPhone 5C
- iPhone 6
- iPad 2G (wi-fi 2012)
- Sony Playstation 2
- Sony Playstation 3 (Assassin's Creed: Brotherhood | FIFA 11 | Uncharted 3)
- Xbox One (GTA V | FIFA 14 | Battlefield 4 | Titanfall | Watch Dogs | FIFA 15 | Battlefield 5 | UFC | Need For Speed: Rivals | Dragon Age: Inquisition)
Mr.Hardy is offline   Reply With Quote
Old 04/04/2014, 10:31 PM   #6
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,883
Reputation: 1321
Default Re: h_Cmd | Command processor

I really don't see the need for more command processors on top of that this offers nothing better than what is already available.
Pottus is offline   Reply With Quote
Old 04/04/2014, 10:43 PM   #7
Mr.Hardy
Huge Clucker
 
Mr.Hardy's Avatar
 
Join Date: Dec 2011
Location: Brazil (SC)
Posts: 442
Reputation: 61
Default Re: h_Cmd | Command processor

Quote:
Originally Posted by [uL]Pottus View Post
I really don't see the need for more command processors on top of that this offers nothing better than what is already available.
I believe that there will always be an evolution... this system has a facility to create commands with arguments..
__________________


Dispositivos:
- Nokia Lumia 825
- Gran Duos ( primeira geração )
- iPhone 5S
- iPhone 5C
- iPhone 6
- iPad 2G (wi-fi 2012)
- Sony Playstation 2
- Sony Playstation 3 (Assassin's Creed: Brotherhood | FIFA 11 | Uncharted 3)
- Xbox One (GTA V | FIFA 14 | Battlefield 4 | Titanfall | Watch Dogs | FIFA 15 | Battlefield 5 | UFC | Need For Speed: Rivals | Dragon Age: Inquisition)
Mr.Hardy is offline   Reply With Quote
Old 05/04/2014, 04:35 AM   #8
Niko_boy
High-roller
 
Niko_boy's Avatar
 
Join Date: Aug 2010
Location: Somewhere i belong
Posts: 1,336
Reputation: 138
Default Re: h_Cmd | Command processor

This maybe a somehow good. But i dont think so sscanf can be compete due to its unique features example: optional parameter / combined arguments / and more..
However this is a basic implementation of some of functionality.

And yes some comparison will be helpful.
__________________
nope[IMG]http://*******/1r0SOkH_[/IMG]
•••[CLOSED]LCS•Freeroam•DM•Stunts•••AutoArena [0.3z][No SkinShot][sixtytiger.com]Want a decent Attack Defend Gamemode?
N/A176.31.229.148:7830Get This! Attack-Defend(v2.3.1)
Niko_boy is offline   Reply With Quote
Old 05/04/2014, 10:16 AM   #9
PT
Godfather
 
PT's Avatar
 
Join Date: Nov 2012
Location: Europe
Posts: 7,180
Reputation: 803
Default Re: h_Cmd | Command processor

Using sscanf and y_cmd its much faster than use this

Anyway nice work.
PT is offline   Reply With Quote
Old 05/04/2014, 01:47 PM   #10
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,883
Reputation: 1321
Default Re: h_Cmd | Command processor

Quote:
Originally Posted by PT View Post
Using sscanf and y_cmd its much faster than use this

Anyway nice work.
It's faster that way but in his defense it's pointless to even measure command processing speed because you'll never have more than a few commands per second even on a large server speed measurements don't even come close to real world practice.
Pottus is offline   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
command processor? RiChArD_A Scripting Help 3 23/01/2013 04:41 PM
Best Command Processor? Finn707 Scripting Help 17 20/10/2012 02:59 PM
Best command processor? Face9000 Scripting Help 14 20/01/2012 07:13 AM
[Include] cMd (command processor) Meta Includes 26 30/11/2011 01:50 AM


All times are GMT. The time now is 01:04 PM.


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