02.02.2014, 03:05
strcmp is not a command processor, it's a function to check equality between two strings. What the strcmp command method does is compares what the player has typed at OnPlayerCommandText and check if there's a match for that command;
With that being said, zcmds and sscanf make that check faster and more efficent. You still need to compare if what the player types matches what you want for them to take from the inventory with strcmp.
In a command it could look like this:
With that being said, zcmds and sscanf make that check faster and more efficent. You still need to compare if what the player types matches what you want for them to take from the inventory with strcmp.
pawn Код:
new item[32];
sscanf(params, "s[32]",item);
if(strcmp(item,"Keys",true) == 0)
{
//player has typed "Keys" as first parameter of the command
}
else if(strcmp(item,"Phone",true) == 0)
{
//...
}
pawn Код:
CMD:take(playerid, params[])
{
new item[32];
if(sscanf(params,"s[32]",item))
return SendClientMessage(playerid,0xFF0000FF,"ERROR: Unknown syntax (/take <item> is the correct).");
if(strcmp(item,"Keys",true) == 0)
{
//..
}
else if(strcmp(item,"Phone",true) == 0)
{
//..
}
//.....
return 1;
}