25.01.2013, 09:11
Guess this would be most compact way
pawn Код:
CMD:duty(playerid, params[], help)
{
#pragma unused help
#pragma unused params
if(PlayerInfo[playerid][pLevel] < 5) return SendClientMessage(playerid, COLOR_RED, "You need to be admin to use this!");
new string[256],pname[24];
GetPlayerName(playerid, pname, 24);
mysql_real_escape_string(pname,pname);
if(PlayerInfo[playerid][pDuty] == 0) { PlayerInfo[playerid][pDuty] = 1; }
else { PlayerInfo[playerid][pDuty] = 1; }
format(string,sizeof(string),"{COLOR_ORANGE}Admin {COL_WHITE}%s {COLOR_ORANGE}is now %s duty",GetName(playerid),PlayerInfo[playerid][pDuty] ? ("on") : ("off"));
SendClientMessageToAll(-1, string);
format(string, sizeof(string), "UPDATE `playerdata` SET `duty` = '%d' WHERE `user_name` = '%s'",PlayerInfo[playerid][pDuty],pname);
mysql_query(string);
return 1;
}