06.04.2014, 12:30
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.. :/
I just don't see it!
.
Код:
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;
}
.

