Does anybody know how to do a code such as this?
#4

There is a function called SetPlayerWantedLevel. Use it like so:

Код:
if(!strcmp(cmdtext,"/setwantedlevel",true))
{
	new tmp[64],tmp2[64],id,level,Index; //if you get "array size is too small" error, change the 64 cell size to 128 or 256

	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xffffffaa,"You are not authorised to use that command.");

	tmp = strtok(cmdtext,Index);
	tmp2 = strtok(cmdtext,Index);
	if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid,0xffffffaa,"USAGE: /setwantedlevel id level");

	id = strval(tmp);
        if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xffffffaa,"Player is not connected");

	level = strval(tmp2);
         if(level<0 || level>6) return SendClientMessage(playerid,0xffffffaa,"INVALID LEVEL [0-6]");
	SetPlayerWantedLevel(id,level);

	return 1;
}
EDIT: You can use either of the above solutions. Grim_'s code is shorter and nice.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)