How do you detect if the player is an admin in your script?
|
CMD:makeadmin(playerid, params[])
{
new id,
level;
if(gPlayerInfo[playerid][PLAYER_LEVEL] < 5)
return SendClientMessage(playerid, -1, "You need to be Level 10 to use this command!");
if(sscanf(params, "ui", id, level))
return SendClientMessage(playerid, -1, "Usage: /makeadmin <playerid> <level>");
if(id == playerid)
return SendClientMessage(playerid, -1, "ERROR:{00CED1} You cannot set your own Admin Level!");
if(!IsPlayerConnected(id))
return SendClientMessage(playerid, -1, "ERROR:{00CED1} Player is not connected!");
if ( level < 0 || level > 5 )
return SendClientMessage(playerid, -1, "ERROR:{00CED1} Invalid Admin level");
gPlayerInfo[id][PLAYER_LEVEL] = level;
new pName[MAX_PLAYER_NAME], str[128], pName1[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(id, pName1, sizeof(pName1));
format(str, sizeof(str), "Administrator %s has changed %s's Admin level to %i",pName, pName1, level);
SendClientMessageToAll(-1, str);
return 1;
}
CMD:makeadmin(playerid, params[])
{
if(PlayerInfo[ playerid ][ PLAYER_LEVEL] < 5) return SendClientMessage(playerid, -1, "ERROR: You are not high enough level bla bla");//If his level is less than 5 he can't use this command
//Change the line above to be suiable
new level, aname[MAX_PLAYER_NAME];//Variables to be used further on
new targetid;//This variable will be assigned to the dude who's level will be changed
if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, -1, "ERROR: /makeadmin (playerid/name) (level)");
if (level > 5 || level < 0) return SendClientMessage(playerid, -1, "ERROR:INVALID level");//This will limit the levels from 1 to 5,(editable)
if(!IsPlayerConnected( targetid )) return SendClientMessage(playerid, -1, "ERROR:INVALID player");//This will be called incase the player isn't connected
new string1[130], tname[MAX_PLAYER_NAME], string2[130];//String to send
PlayerInfo[targetid][ PLAYER_LEVEL ] = level;//This part will set his level
GetPlayerName(playerid, aname, sizeof(aname));
GetPlayerName(targetid, tname, sizeof(tname));
format(string2, sizeof(string1), "Admin %s has set %s's level to %i", aname, tname, level);//This will be sent to all players
SendClientMessageToAll(Yellow, string2);
return 1;
}
Well depends on your registration system make the following code suitable to it.
pawn Код:
|
I can only see that you changed his Admin Variable and changed some Variable names.....
|
Yes exactly,if you just read the post properly i noted that he should make it suitable to his system, also the command was an example not a 'ready to use' i used it to explain because this is scripting help forums not scripting requests.
|