03.01.2013, 18:12
Try This
pawn Код:
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/makeadmin", true) == 0)
{
new string[128];
new tmp[256];
tmp = strtok(cmdtext, idx);
new ReturnUser;
new giveplayerid;
new player[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
giveplayerid = ReturnUser(tmp);
if (IsPlayerAdmin(playerid))
{
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /makeadmin [playerid] [level]");
SendClientMessage(playerid, COLOUR_ORANGE, "FUNCTION: Player will obtain admin.");
return 1;
}
tmp = strtok(cmdtext, idx);
new level = strval(tmp);
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, player, sizeof(player));
PlayerInfo[giveplayerid][AdminLevel] = level;
printf("Admin %s made %s a level %d admin.", player, giveplayer, level);
format(string, sizeof(string), "You are now an administrator level %d given by %s.", level, player);
SendClientMessage(giveplayerid, 0x00C2ECFF, string);
format(string, sizeof(string), "You have given %s level %d admin.", giveplayer,PlayerInfo[giveplayerid][AdminLevel]);
SendClientMessage(playerid, 0x00C2ECFF, string);
}
else if(giveplayerid == INVALID_PLAYER_ID)
{
format(string, sizeof(string), "%i is not currently on the server.", giveplayerid);
SendClientMessage(playerid, 0xE60000FF, string);
}
}
else
{
SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin, or an owner!");
}
return 1;
}
return 0;
}