30.08.2014, 17:37
PHP код:
CMD:makeadmin(playerid, params[])
{
new targetid, level;
if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, -1, "/makeadmin [playerid/partofname] [level]");
if(!(-1 < level < 1000000)) return SendClientMessage(playerid, -1, "The max admin level is 999999!");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player is not currently online!");
new alevel[20], astr[128], sendername[MAX_PLAYER_NAME];
if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 99999)
{
switch(level)
{
case 0:
{
GetPlayerName(playerid, sendername, sizeof(sendername));
format(astr, sizeof(astr), "You have been demoted by Admin %s", sendername);
SendClientMessage(targetid, -1, astr);
GetPlayerName(targetid, sendername, sizeof(sendername));
format(astr, sizeof(astr), "You have demoted %s of their Admin rank.", sendername);
SendClientMessage(playerid, -1, astr);
PlayerInfo[targetid][pAdmin] = level;
return 1;
}
case 1: alevel = "Moderator";
case 2: alevel = "Junior Admin";
case 3: alevel = "General Admin";
case 4: alevel = "Senior Admin";
case 5: alevel = "Lead Admin";
case 6: alevel = "Head Admin";
case 1337: alevel = "Executive Admin";
case 9999: alevel = "Co-Owner";
case 99999: alevel = "Owner";
case 999999: alevel = "GOD!";
default: return SendClientMessage(playerid, -1, "You have entered an invalid level. (0 - 6, 1337, 9999, 99999, or 999999)");
}
GetPlayerName(playerid, sendername, sizeof(sendername));
format(astr, sizeof(astr), "You have been made into a %s by Admin %s!", alevel, sendername);
SendClientMessage(targetid, -1, astr);
GetPlayerName(targetid, sendername, sizeof(sendername));
format(astr, sizeof(astr), "You have made %s into a %s!", sendername, alevel);
SendClientMessage(playerid, -1, astr);
PlayerInfo[targetid][pAdmin] = level;
}
else
{
SendClientMessage(playerid, -1, "You do not meet the admin requirements to use this command!");
}
return 1;
}
pawn Код:
Is this line unnecessary:
if(!(-1 < level < 1000000)) return SendClientMessage(playerid, -1, "The max admin level is 999999!");
because of how default is used in the case statement? default:
return SendClientMessage(playerid, -1, "You have entered an invalid level. (0 - 6, 1337, 9999, 99999, or 999999)"); I was starting to wonder about this.