CMD:setlevel(playerid, params[])
{
new tmp[128], tmp2[128], index;
tmp = strtok(params, index), tmp2 = strtok(params, index);
new giveplayerid, level;
giveplayerid = strval(tmp), level = strval(tmp2);
if(PlayerInfo[playerid][AdminLevel] > 4 || IsPlayerAdmin(playerid)) {
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "Usage: /setlevel [PlayerID/PartOfName] [Level]");
if(isnull(tmp)) return SendClientMessage(playerid, COLOR_RED, "Usage: /setlevel [PlayerID/PartOfName] [Level]");
if(isnull(tmp2)) return SendClientMessage(playerid, COLOR_RED, "Usage: /setlevel [PlayerID/PartOfName] [Level]");
if(level == PlayerInfo[giveplayerid][AdminLevel]) return SendClientMessage(playerid, COLOR_RED, "Player is already this level");
if(level < 0 || level > 5) return SendClientMessage(playerid, COLOR_RED, "Invalid level");
if(IsPlayerConnected(giveplayerid)) {
new string[128], playername[MAX_PLAYER_NAME], giveplayername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof playername); GetPlayerName(giveplayerid, giveplayername, sizeof giveplayername);
format(string, sizeof string, "Administrator %s has set your admin level to %d", playername, level);
SendClientMessage(giveplayerid, COLOR_BLUE, string);
format(string, sizeof string, "You have set %s admin level to %d", giveplayername, level);
SendClientMessage(playerid, COLOR_BLUE, string);
PlayerInfo[giveplayerid][AdminLevel] = level;
}
else return SendClientMessage(playerid, COLOR_RED, "Player not Connected");
}
else return SendClientMessage(playerid, COLOR_RED, "You are not an administrator with the required level");
return 1;
}
Originally Posted by Joe Torran C
Huh? Sorry im new to doing this, I dont normally do it this way
|
Originally Posted by Joe Torran C
My own way is sscanf but it all went wrong,
For example using rcon aswell as admin level, And we agreed to do it this way so.. |
CMD:setlevel(playerid, params[])
{
if(!(PlayerInfo[playerid][AdminLevel] > 4 || IsPlayerAdmin(playerid)))
return SendClientMessage(playerid, COLOR_RED, "You are not an administrator with the required level");
new id, level;
if(sscanf(params, "ui", id, level))
return SendClientMessage(playerid, COLOR_RED, "Usage: /setlevel [PlayerID/PartOfName] [Level]");
else if(!IsPlayerConnected(id))
return SendClientMessage(playerid, COLOR_RED, "Player not Connected");
else if(0 > level || level > 5)
return SendClientMessage(playerid, COLOR_RED, "Invalid level");
else if(level == PlayerInfo[id][AdminLevel])
return SendClientMessage(playerid, COLOR_RED, "Player is already this level");
new string[70];
GetPlayerName(playerid, string, MAX_PLAYER_NAME);
format(string, sizeof string, "Administrator %s has set your admin level to %d", string, level);
SendClientMessage(id, COLOR_BLUE, string), GetPlayerName(id, string, MAX_PLAYER_NAME);
format(string, sizeof string, "You have set %s admin level to %d", string, level);
SendClientMessage(playerid, COLOR_BLUE, string);
PlayerInfo[id][AdminLevel] = level;
return 1;
}