CMD:setkills(playerid,params[]) {
if(PlayerInfo[playerid][Level] >= 5) {
new tmp[128], tmp2[128], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
if(isnull(tmp) || isnull(tmp2) || !IsNumeric(tmp2)) return SendClientMessage(playerid, red, "USAGE: /setkills [playerid] [kills]");
new player1 = strval(tmp), Kills = strval(tmp2), string[128];
if(PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
CMDMessageToAdmins(playerid,"SetKills");
format(string, sizeof(string), "You have set \"%s's\" kills to '%d' ", pName(player1), Kills); SendClientMessage(playerid,blue,string);
if(player1 != playerid) { format(string,sizeof(string),"Administrator \"%s\" has set your kills to '%d'", pName(playerid), Kills); SendClientMessage(player1,blue,string); }
return PlayerInfo[player1, Kills);
} else return SendClientMessage(playerid,red,"ERROR: Player is not connected");
} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
return SetPlayerScore(player1, score);
return PlayerInfo[player1, Kills);
CMD:setkills(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] == 1337)
{
new giveplayerid, kills, string[128];
if(sscanf(params, "ud", giveplayerid, kills) return SendClientMessage(playerid, -1, "USAGE: /setkills [playerid] [amount]")
if(IsPlayerConnected(giveplayerid))
{
new PName[64];
GetPlayerName(playerid, PName, sizeof(PName));
PlayerInfo[giveplayerid][Kills] = amount;
format(string, sizeof(string), "Your kills have been set to %d", amount);
SendClientMessage(giveplayerid, -1, string);
format(string, sizeof(string), "You have set %s's kills to %d", PName, amount);
SendClientMessage(playerid, -1, string);
}
}
else
{
SendClientMessage(playerid, -1, "You are not authorized to use this command!");
return 1;
}
return 1;
}
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
*/
If you use sscanf as well...
pawn Код:
|