make admin command crash player
#1

Hey, I made a command to make someone admin, problem is, when I use the command the player who needs to get admin will crash.. :/

Код:
YCMD:makeadmin(playerid, params[], help)
{
	if(help) return SCM(playerid, COLOR_GREY, "Not supported");

	if(IsPlayerConnected(playerid))
	{
		new string[256], para1, level, playerlevel;
		if(sscanf(params, "ud", para1, level))
		{
			SCM(playerid, COLOR_GRAD, "USAGE: /makeadmin [playerid/PartOfName] [level(1-6)]");
			return 1;
		}
		playerlevel = PlayerInfo[para1][pAdmin];
		if(PlayerInfo[playerid][pAdmin] >= 6 || IsPlayerAdmin(playerid))
		{
			if(IsPlayerConnected(para1))
			{
				if(para1 != INVALID_PLAYER_ID)
				{
					if(level == playerlevel)
					{
						SCM(playerid, COLOR_GREY, "Player is already that level");
						return 1;
					}
					if(level < 0 || level > 6) return SCM(playerid, COLOR_GREY,"Only levels 0-6 are allowed.");
					new Float:X, Float:Y, Float:Z;
					GetPlayerPos(para1, X,Y,Z);
					format(string, sizeof(string), "Admin %s has set you as Admin Level %d.",GetPlayerNameEx(playerid), level);
					SCM(para1, COLOR_BLUE, string);
					format(string, sizeof(string),"[INFO] Admin %s has set %s's Admin Level to %d.", GetPlayerNameEx(playerid), GetPlayerNameEx(para1), level);
					ABroadCast(COLOR_YELLOW, string, 5);
					if(level > PlayerInfo[para1][pAdmin])
					{
						PlayerPlaySound(para1, 1056, X, Y, Z);
						format(string, sizeof(string), "You have set %s as Admin Level %d.", GetPlayerNameEx(para1), level);
						SCM(playerid, COLOR_BLUE, string);
						PlayerInfo[para1][pAdmin] = level;
						if(playerlevel == 0 && level >= 1)
						{
							admins ++;
						}
					}
					else
					{
						PlayerPlaySound(para1, 1055, X, Y, Z);
						format(string, sizeof(string), "You have set %s as Admin Level %d.", GetPlayerNameEx(para1), level);
						SCM(playerid, COLOR_BLUE, string);
						PlayerInfo[para1][pAdmin] = level;
					}
				}
			}
		}
		else
		{
			SCM(playerid, COLOR_GRAD1, "You cannot use this command.");
			return 1;
		}
	}
	return 1;
}
I just don't see it! .
Reply
#2

use this
and also include
Sscanf.inc
Zcmd.inc


PHP код:
CMD:makeadmin(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid))return 0//This command only works for rcon
    
if(sscanf(params,"ui",ID,levels)) return SendClientMessage(playerid,0xFF9900AA"USAGE: /setadmin [ID] [Level 1-4]");//it will show this if you dont use the format properly
    
if(levels 4) return SendClientMessage(playerid,0xFF0000FF,"LEVELS AVAILABLE 1-4!");//Available levels
    
if(!IsPlayerConnected(ID))return SendClientMessage(playerid,red,"That user is not connected.");//Detect if the id/partofname is connected
    
if(PlayerData[ID][AdminLevel] == levels) return SendClientMessage(playerid,0xFF0000FF"ERROR: That person is already this admin level!");//Detect if the guy is already the level you setted
    
GetPlayerName(playerid,NamMAX_PLAYER_NAME);//define the playerid name
    
GetPlayerName(ID,pname,MAX_PLAYER_NAME);//define the other person name
    
if(levels == 0)
    {
        
format(strsizeof(str),"%s has your Admin level to %d on the server. *cry *cry",Nam,levels);
        
SendClientMessage(ID,0xFF9900AA,str);
        
format(strsizeof(str),"You had set %s Admin level to %d!",pname,levels);
        
SendClientMessage(playerid,0xFF9900AA,str);
        
PlayerData[ID][AdminLevel] = levels;//this sets the player level
        
return 1;
    }
    
format(strsizeof(str),"%s has your Admin level to %d on the server.",Nam,levels);
    
SendClientMessage(ID,0xFF9900AA,str);
    
format(strsizeof(str),"You had set %s Admin level to %d!",pname,levels);
    
SendClientMessage(playerid,0xFF9900AA,str);
    
PlayerData[ID][AdminLevel] = levels;
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)