How to create a /setkills and /setdeaths command?
#3

If you use sscanf as well...


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
*/
EDIT: messed up my usage message lol (forgot player) - also forgot to actually use the type variable fail
Reply


Messages In This Thread
How to create a /setkills and /setdeaths command? - by OleKristian95 - 19.05.2012, 00:54
Re: How to create a /setkills and /setdeaths command? - by Paramount - 19.05.2012, 01:04
Re: How to create a /setkills and /setdeaths command? - by [ABK]Antonio - 19.05.2012, 01:05
Re: How to create a /setkills and /setdeaths command? - by Paramount - 19.05.2012, 01:08
Re: How to create a /setkills and /setdeaths command? - by OleKristian95 - 19.05.2012, 01:09

Forum Jump:


Users browsing this thread: 1 Guest(s)