SA-MP Forums Archive
/setadmin bug - 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: /setadmin bug (/showthread.php?tid=141676)



/setadmin bug - Naxix - 14.04.2010

Hi, i made a /setadmin cmd, but when i use it /setadmin 0 0-5 it sets my admin level to 65535??
You should only be able to use it form 0-5, and not any other level.

Code:
Код:
dcmd_setadmin(playerid,params[])
{
	new pid,level;
	if(admin[playerid] < 5 && !IsPlayerAdmin(playerid)) return 0;
	else if(sscanf(params,"uu",pid,level)) return SendClientMessage(playerid,COLOUR_RED,"Usage: /setadmin [id] [Admin Level]");
	else if(pid == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOUR_RED,"Inactive player id");
	else
	{
	  new string[40],name[MAX_PLAYER_NAME],string2[52];
	  GetPlayerName(pid,name,sizeof(name));
	  admin[pid] = level;
	  format(string,sizeof(string),"Your admin level was set to %i by %s",level,playerid);
	  SendClientMessage(pid,COLOUR_LIGHTBLUE,string);
	  format(string2,sizeof(string2),"%s's admin level was set to %i",name,level);
		SendClientMessage(playerid,COLOUR_YELLOW,string2);
	  return 1;
	}
}



Re: /setadmin bug - woot - 14.04.2010

In the sscanf line it should be "ud" and not "uu". u = searches for a part of name / direct ID, d for a decimal value, and the adminlevel is a decimal value obviously!


Re: /setadmin bug - Naxix - 14.04.2010

Thanks!