08.09.2013, 09:06
pawn Код:
CMD:makeadmin(playerid, params[])
{
new level, targetid, string[200], str[200];
if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, -1, "[SERVER]: This player is {FF0000}NOT {FFFFFF}Connected!");
if(sscanf(params, "ui", targetid, level))return SendClientMessage(playerid, -1, "[USAGE]: /makeadmin {FF0000}[Playerid] [Level]");
if(level < 0 || level > 5)return SendClientMessage(playerid, -1, "[SERVER]: {FF0000}Invalid Admin Level (0-5)!");
if(pInfo[targetid][Adminlevel] < level)
{
format(string, sizeof(string), "[ADMIN]: Administrator %s(ID:%d) has promoted %s(ID:%d) to Admin level %d!", GetName(playerid), playerid, GetName(targetid), targetid, level);
SendClientMessageToAll(-1, string);
pInfo[targetid][Adminlevel] = level;
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player's Data");
INI_WriteInt(file, "AdminLevel", pInfo[targetid][Adminlevel]);
INI_Close(file);
}
if(pInfo[targetid][Adminlevel] > level)
{
format(str, sizeof(str), "[ADMIN]: Administrator %s(ID:%d) has demoted %s(ID:%d) to Admin level %d!", GetName(playerid), playerid, GetName(targetid), targetid, level);
SendClientMessageToAll(-1, str);
pInfo[targetid][Adminlevel] = level;
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player's Data");
INI_WriteInt(file, "AdminLevel", pInfo[targetid][Adminlevel]);
INI_Close(file);
}
return 1;
}