[Include] h_Cmd | Command processor
#1

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 Код:
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 Код:
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.
Reply


Messages In This Thread
h_Cmd | Command processor - by Mr.Hardy - 04.04.2014, 17:31
Re: h_Cmd | Command processor - by UnknownOwner - 04.04.2014, 17:36
Re: h_Cmd | Command processor - by FailerZ - 04.04.2014, 17:42
Re: h_Cmd | Command processor - by iZN - 04.04.2014, 17:54
Re: h_Cmd | Command processor - by Mr.Hardy - 04.04.2014, 18:19
Re: h_Cmd | Command processor - by Pottus - 04.04.2014, 22:31
Re: h_Cmd | Command processor - by Mr.Hardy - 04.04.2014, 22:43
Re: h_Cmd | Command processor - by Niko_boy - 05.04.2014, 04:35
Re: h_Cmd | Command processor - by PT - 05.04.2014, 10:16
Re: h_Cmd | Command processor - by Pottus - 05.04.2014, 13:47

Forum Jump:


Users browsing this thread: 1 Guest(s)