19.05.2012, 01:05
If you use sscanf as well...
EDIT: messed up my usage message lol (forgot player) - also forgot to actually use the type variable fail
pawn Код:
CMD:set(playerid, params[])
{
//Check if they're admin
if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xCC0000AA, "You aren't an admin!"); //replace with your admin stuff
//We create 3 variable to store our params in
new target, type[10], amount;
//We use sscanf to do it (it returns 1 if nothing is found so we send a usage message if nothing is found)
if(sscanf(params, "rs[10]i", target, type, amount)) return SendClientMessage(playerid, 0xCC0000AA, "USAGE: /set [player] [kills/deaths] [amount]");
//We compare what they typed for the type parameter with "Kills"
if(!strcmp(type, "Kills", true)) //it returns 0 if they're the same...true = ignore case
{
PlayerInfo[target][Kills] = amount; //We set their kills to the amount parameter
//Send them some messages or whatever
}
else if(!strcmp(type, "Deaths", true)) //same as above but for deaths
{
PlayerInfo[target][Deaths] = amount;
//Send them a message or whatever you want to do
}
return 1;
}
/*
Sscanf params used:
r - for playerid/player name
s[stringsize] - for strings
i - for integers
*/