/setadmin bug
#1

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;
	}
}
Reply
#2

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!
Reply
#3

Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)