21.01.2011, 20:46
(
Последний раз редактировалось SlashPT; 23.01.2011 в 18:02.
)
Introduction:
Hello there
Today im posting [FeK]Drakins system and made with my help (DarK TeaM PT).
This Commands system has support for multiple params without needing other systems like sscanf,strtok,etc...
Accesibility:
#Multi Params:
It works with multiple params wich makes an easier use...
@Example:
#Command:
/health 0 100
So from the params '1' it will take all the 'spaces' and it will make the divisions, all in the commands system, wich makes easier to use.
making finally this
#Accesibility with the CMD's:
As ZCMD, all the commands are created out of ANY public, like it ise a stock function
Making easier to use!
Speed:
#How it works:
fCommand uses the same base as zcmd.
It uses basicly CallLocalFunctions that will make the CallBack work, without needing strcmp for compare the command,in the callback case if it doesn't exists it will just return false, making this, one Speed-Up
#Comparations
Unfortunately i didn't test's with other commands processors than the fastest: Zcmd
By DarK TeaM PT
So it wasn't necessary other verifications
Codes:
#Code
Or Click me for download!
Credits:
Commands System FeK Squad it's created by:
# [FeK]DraKiNs
# DarK TeaM PT
Thanking all the Team [FeK]Squad and DracoBlue
Hello there
Today im posting [FeK]Drakins system and made with my help (DarK TeaM PT).
This Commands system has support for multiple params without needing other systems like sscanf,strtok,etc...
Accesibility:
#Multi Params:
It works with multiple params wich makes an easier use...
@Example:
#Command:
/health 0 100
Код:
/health = iParams[0] 0 = iParams[1] 100 = iParams[2]
making finally this
pawn Код:
fcmd(health,playerid)
{
if(!iParams[1][0] || !iParams[2][0])
return SendClientMessage(playerid,0xF60000AA,"Usage: {FFFFFF}/health [PlayerID] [0-100]");
SetPlayerHealth(strval(iParams[1]),strval(iParams[2]));
return true;
}
As ZCMD, all the commands are created out of ANY public, like it ise a stock function
pawn Код:
fcmd(command,playerid)
{
return true;
}
Speed:
#How it works:
fCommand uses the same base as zcmd.
It uses basicly CallLocalFunctions that will make the CallBack work, without needing strcmp for compare the command,in the callback case if it doesn't exists it will just return false, making this, one Speed-Up
#Comparations
Unfortunately i didn't test's with other commands processors than the fastest: Zcmd
By DarK TeaM PT
Код:
# ZCMD - 52
# FCMD - 25
So it wasn't necessary other verifications
Codes:
#Code
pawn Код:
#define fcmd(%1,%2) \
forward fcmd_%1(%2); \
public fcmd_%1(%2)
#define MaxFrequence (066)
#define MaxParameter (064)
#define MaxFunctions (032)
#define MaxLenString (128)
new
sIndex = 0,
iLenPart = 0,
iPosPart = 0,
iStrMid = 0,
iLenght = 0,
cmds[ MaxFunctions ]
;
public OnFilterScriptInit()
{
OnPlayerCommandText(0,"/me Hoje me sinto bem");
return true;
}
public OnPlayerCommandText(playerid,cmdtext[])
{
//Here you can write cmds witout params!
return DelimiterCommand(playerid,cmdtext);
}
new iParams[ MaxFrequence ][ MaxParameter ],iTotalParams[MaxLenString];
stock
DelimiterCommand(playerid,sStringSource[])
{
iLenght = strlen(sStringSource);
sIndex = 0;
iLenPart = 0;
iPosPart = 0;
iStrMid = 0;
for(new aIndex = 1; aIndex < MaxFrequence; ++aIndex) iParams[aIndex][0] = '\0';
iTotalParams[0] = '\0';
while(sIndex <= iLenght)
{
if(sStringSource[sIndex] == ' ' && sStringSource[sIndex - 1] != ' ' || sIndex == iLenght)
{
iStrMid = strmid(iParams[iPosPart], sStringSource, iLenPart, sIndex, 128);
iParams[iPosPart][iStrMid] = 0,iLenPart = (sIndex + 1), ++iPosPart;
if(iPosPart == 1)
format(iTotalParams,MaxLenString, "%s",sStringSource[sIndex]);
}
++sIndex;
}
format(cmds, sizeof cmds,"fcmd_%s",iParams[0][1]);
return CallLocalFunction(cmds,"i",playerid);
}
//iTotalParams = All Params in One String
//iParams[id] = Only one Parameter
fcmd(me,playerid)
{
new Name[24],zFormat[MaxLenString];
GetPlayerName(playerid,Name,24);
format(zFormat,MaxLenString,"Player: %s | Say: %s",Name,iTotalParams);
SendClientMessageToAll(0xFFFFFF,zFormat);
return true;
}
fcmd(ban,playerid)
{
new Name[24],zFormat[MaxLenString];
GetPlayerName(playerid,Name,24);
format(zFormat,MaxLenString,"Player: %s | Say: %s",Name,iTotalParams);
SendClientMessageToAll(0xFFFFFF,zFormat);
return true;
}
Credits:
Commands System FeK Squad it's created by:
# [FeK]DraKiNs
# DarK TeaM PT
Thanking all the Team [FeK]Squad and DracoBlue