03.02.2012, 12:36
About indentation and check about the local variable "string" shadows a variable at a preceding level delete the "new string[ value_here ];" from the lines 7, 101, 379
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/makeadmin", true) == 0) {
new string[128];
new tmp[256];
new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
new giveplayerid;
if (IsPlayerAdmin(playerid)) {
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, 0x00C2ECFF, "USAGE: /makeadmin [playerid] [level]");
SendClientMessage(playerid, 0x00C2ECFF, "FUNCTION: Player will be an admin.");
return 1;
}
giveplayerid = ReturnUser(tmp);
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 thanks to %s.", level, player);
SendClientMessage(giveplayerid, 0x00C2ECFF, string);
format(string, sizeof(string), "You have given %s level %d admin.", giveplayer,PlayerInfo[giveplayerid][AdminLevel]);
}
else if(giveplayerid == INVALID_PLAYER_ID) {
format(string, sizeof(string), "%i is not an active player.", giveplayerid);
SendClientMessage(playerid, 0xE60000FF, string);
}
}
else {
SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin!");
}
return 1;
}
if (strcmp(cmd, "/admins", true) == 0) {
if(IsPlayerConnected(playerid)) {
SendClientMessage(playerid, 0xE60000FF, " ");
SendClientMessage(playerid, 0xE60000FF, "Online Admins: ");
for(new i = 0; i < MAX_PLAYERS; i++) {
if(IsPlayerConnected(i)) {
if(PlayerInfo[i][pAdmin] >= 1 && PlayerInfo[i][pAdmin] < 1341) {
new admtext[64];
if(PlayerInfo[i][pAdmin] == 1337) { admtext = "Lead Admin"; }
else if(PlayerInfo[i][pAdmin] == 4) { admtext = "High Admin"; }
else if(PlayerInfo[i][pAdmin] == 3) { admtext = "Normal Admin"; }
else if(PlayerInfo[i][pAdmin] == 2) { admtext = "Low Admin"; }
else if(PlayerInfo[i][pAdmin] == 1) { admtext = "Moderator"; }
else { admtext = "Moderator"; }
GetPlayerName(i, sendername, sizeof(sendername));
if(AdminDuty[i] == 0) {
format(string, 256, "%s ( %s )", sendername, admtext);
SendClientMessage(playerid, 0xE60000FF, string);
}
else {
format(string, 256, "%s ( %s )", sendername, admtext);
SendClientMessage(playerid, 0xE60000FF, string);
}
}
}
}
}
return 1;
}
return 0;
}