PDA

View Full Version : setadmin command


AhmedMohamed
20/03/2014, 11:32 PM
Hello All , what is wrong in that command?
it doesn't give me any errors but it give me USAGE: /setadmin [playerid] [admin level ] when i type it in the game with the id and level.

CMD:setadmin(playerid,params[])
{
if(PlayerInfo[playerid][Level] >= 8 || IsPlayerAdmin(playerid))
{
new id, alevel, string[128];
if(sscanf(params, "ui",id, alevel))return SendClientMessage(playerid, red, "USAGE:{FFFFFF} /setadmin [playerid] [admin level] (Max Admin Level : 8)");
if(alevel > ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid, red, "ERROR: Invaild Admin Level. (Admin Levels from 0 to 8)");
if(alevel == PlayerInfo[id][Level]) return SendClientMessage(playerid,red,"ERROR: Player is already on this Admin level");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,red,"ERROR: Player Not Connected");
if(PlayerInfo[id][LoggedIn] >= 0) return SendClientMessage(playerid,red,"ERROR: Player must logged in to set his level");
PlayerInfo[id][Level] = alevel;
SaveToFile("AdminLog",string);
format(string, sizeof(string), "Adminstrator %s has Set your Admin Level To %d", GetPlayerNameEx(playerid), alevel);
SendClientMessage(id,-1,string);
format(string, sizeof(string), "You just Set %s(%d) Admin Level To %d", GetPlayerNameEx(id), id, alevel);
SendClientMessage(playerid,-1,string);
} else return SendClientMessage(playerid, grey, "ERROR: You're not authorized to use that command");
return 1;
}


sorry for my bad english

ChromeMenu
21/03/2014, 12:43 AM
CMD:setadmin(playerid,params[])
{
if(PlayerInfo[playerid][Level] >= 8 || IsPlayerAdmin(playerid))
{
new id, alevel, string[128];
if(sscanf(params, "ui",id, alevel))return SendClientMessage(playerid, red, "USAGE:{FFFFFF} /setadmin [playerid] [admin level] (Max Admin Level : 8)");
if(alevel > ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid, red, "ERROR: Invaild Admin Level. (Admin Levels from 0 to 8)");
if(alevel == PlayerInfo[id][Level]) return SendClientMessage(playerid,red,"ERROR: Player is already on this Admin level");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,red,"ERROR: Player Not Connected");
if(PlayerInfo[id][LoggedIn] >= 0) return SendClientMessage(playerid,red,"ERROR: Player must logged in to set his level");
PlayerInfo[id][Level] = alevel;
SaveToFile("AdminLog",string);
format(string, sizeof(string), "Adminstrator %s has Set your Admin Level To %d", GetPlayerNameEx(playerid), alevel);
SendClientMessage(id,-1,string);
format(string, sizeof(string), "You just Set %s(%d) Admin Level To %d", GetPlayerNameEx(id), id, alevel);
SendClientMessage(playerid,-1,string);
} else return SendClientMessage(playerid, grey, "ERROR: You're not authorized to use that command");
return 1;
}


Try this

AhmedMohamed
21/03/2014, 12:47 AM
where is it?

AhmedMohamed
21/03/2014, 02:19 AM
bump

Unte99
21/03/2014, 02:39 AM
You should check how it's done:

http://wiki.sa-mp.com/wiki/Fast_Commands

ACI
21/03/2014, 02:56 AM
Try replacing this:

if(sscanf(params, "ui",id, alevel))return SendClientMessage(playerid, red, "USAGE:{FFFFFF} /setadmin [playerid] [admin level] (Max Admin Level : 8)");

with this:

if(!sscanf(params, "ui",id, alevel))return SendClientMessage(playerid, red, "USAGE:{FFFFFF} /setadmin [playerid] [admin level] (Max Admin Level : 8)");

AhmedMohamed
21/03/2014, 03:25 AM
REP+ ACI