SA-MP Forums Archive
Help with /makeadmin command. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with /makeadmin command. (/showthread.php?tid=199261)



Help with /makeadmin command. - [BFT]eagles22 - 14.12.2010

Hello, i have attempted to make a /makeadmin command, however when i try to use it, no matter what id i use, it always gives me a message saying i have promoted myself to level 0 and takes my admin privelages away. I am not sure what is causing the problem.

Here is the command script.

dcmd_makeadmin(playerid, params[])
{
if(Player[playerid][level] == 4 || IsPlayerAdmin(playerid)) {}
new pID,alevel;
if(Player[playerid][level] < 4){
return SendClientMessage(playerid, COLOR_RED, "You must be admin level 4 to do this!");
}
else if(!strlen(params)){
return SendClientMessage (playerid,COLOR_RED,"USAGE: /makeadmin [playerid] [adminlevel]");
}
else if(!IsPlayerConnected(pID)){
return SendClientMessage (playerid,COLOR_RED,"Nobody is connected with this ID!");
}
else
{
new string[128],string2[128],aname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
Player[pID][level] = alevel;
GetPlayerName(playerid,aname,sizeof(aname));
GetPlayerName(pID,name,sizeof(name));
format(string,sizeof(string),"You have set the admin level of %s to %d",name,alevel);
format(string2,sizeof(string2),"ServerOwner %s has set your admin level to %d",aname,alevel);
SendClientMessage(playerid,COLOR_GREEN,string);
SendClientMessage(pID,COLOR_GREEN,string2);
return 1;
}
}


Re: Help with /makeadmin command. - blackwave - 15.12.2010

You haven't defined the id which the level will be give for ( I mean params ). Try this code:
pawn Код:
dcmd_makeadmin(playerid, params[])
{
if(Player[playerid][level] == 4 || IsPlayerAdmin(playerid)) {}
new pID,alevel;
new tmp[256], tmp2[256], Index;     tmp = strtok(params,Index), tmp2 = strtok(params,Index);
pID = strval(tmp);
alevel = strval(tmp2);
if(Player[playerid][level] < 4){
return SendClientMessage(playerid, COLOR_RED, "You must be admin level 4 to do this!");
}
else if(!strlen(tmp) || !strlen(tmp2)){
return SendClientMessage (playerid,COLOR_RED,"USAGE: /makeadmin [playerid] [adminlevel]");
}
else if(!IsPlayerConnected(pID)){
return SendClientMessage (playerid,COLOR_RED,"Nobody is connected with this ID!");
}
else
{
new string[128],string2[128],aname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
Player[pID][level] = alevel;
GetPlayerName(playerid,aname,sizeof(aname));
GetPlayerName(pID,name,sizeof(name));
format(string,sizeof(string),"You have set the admin level of %s to %d",name,alevel);
format(string2,sizeof(string2),"ServerOwner %s has set your admin level to %d",aname,alevel);
SendClientMessage(playerid,COLOR_GREEN,string);
SendClientMessage(pID,COLOR_GREEN,string2);
return 1;
}
}
May work


Re: Help with /makeadmin command. - [BFT]eagles22 - 15.12.2010

okay, now when i use that if the id is not valid it bring up the message saying that it isn't valid, but if i try to make my friend an admin i get the message saying i have promoted myself to admin.


Re: Help with /makeadmin command. - XePloiT - 15.12.2010

try this... with sscanf...
pawn Код:
dcmd_makeadmin(playerid, params[])
{
if(Player[playerid][level] < 4 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"Must be admin level 4");
new pID,alevel;
if(sscanf(params,"ii",pID,alevel)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /makeadmin id level");
if(!IsPlayerConnected(pID)) return SendClientMessage (playerid,COLOR_RED,"Nobody is connected with this ID!");
new string[128],string2[128],aname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
Player[pID][level] = alevel;
GetPlayerName(playerid,aname,sizeof(aname));
GetPlayerName(pID,name,sizeof(name));
format(string,sizeof(string),"You have set the admin level of %s to %d",name,alevel);
format(string2,sizeof(string2),"ServerOwner %s has set your admin level to %d",aname,alevel);
SendClientMessage(playerid,COLOR_GREEN,string);
SendClientMessage(pID,COLOR_GREEN,string2);
return 1;
}



Re: Help with /makeadmin command. - [BFT]eagles22 - 21.12.2010

XePloit that did work, thanks a lot.