Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/setadmin", true) == 0)
{
new string[128];
new tmp[256];
new giveplayerid;
if (IsPlayerAdmin(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, 0xE70000FF, "USAGE: /setadmin [playerid] [level]");
SendClientMessage(playerid, 0xE70000FF, "FUNCTION: Player will be an admin.");
return 1;
}
giveplayerid = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
new level = strval(tmp);
new level1 = 0;
new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME]; //for sound
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, player, sizeof(player));
PlayerInfo[giveplayerid][AdminLevel] = level;
new pname[128]; // The name length
new file[128]; // The file length
GetPlayerName(playerid, pname, sizeof(pname)); // This get's the player name with the name length
format(file, sizeof(file), savefolder,pname); // Formatting file
if(!dini_Exists(file)) { // If the file exist
}
else { // if not
dini_IntSet(file, "Level", PlayerInfo[playerid][AdminLevel]);
}
printf("Admin %s made %s a level %d admin.", player, giveplayer, level);
//id = GetPlayerID(player);
id1 = GetPlayerIdFromName(giveplayer);
SetTimer("MyTimer",10000,0); // Stop Sound
PlayerPlaySound(id1,1057,0.0,0.0,0.0);
PlayerPlaySound(id1,1097,0.0,0.0,0.0);
if (PlayerInfo[playerid][AdminLevel] == 9) {
SendClientMessage(playerid, 0x00DB00FF, "YOU ARE NOW A STAFF MANAGER OF THE SERVER(Level 9)");
}else {
SendClientMessage(giveplayerid, 0x00DB00FF,"------------------------------------------------------------------------------");
format(string, sizeof(string), "CONGRATS ! YOU ARE NOW AN ADMINISTRATOR LEVEL %d THANKS TO %s.", level, player);
SendClientMessage(giveplayerid, 0x00DB00FF, string);
SendClientMessage(giveplayerid, 0x00DB00FF, "------------------------------------------------------------------------------");
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 an active player.", giveplayerid);
SendClientMessage(playerid, 0xE60000FF, string);
}
}
else
{
SendClientMessage(playerid, 0xE70000FF, "Only the owner can promote!");
}
return 1;
}