[Tutorial] Making /KickAll, /MuteAll & /UnMuteAll Commands.
#8

Quote:
Originally Posted by J4Rr3x
View Post
1. Why loop with MAX_PLAYERS?
From 0.3.7 we have GetPlayerPoolSize that get the highest playerid in use on the server.
2. You haven't defined "red" color.
3. PNAME is a blank variable because you haven't assigned nothing with GetPlayerName
4. You can use opposite condition instead of use a lots of brackets
5. "Level" variable in pInfo enum is never used
6. I don't understand this condition "i != ServerInfo[MaxAdminLevel]"
7. For a concept of order and code reading, uses a line for each instruction.

This is the correct script:
pawn Code:
CMD:kickall(playerid, params[]) {
    if(PlayerInfo[playerid][eLevel] < 5 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, red, "-Error You ain't high enough level to use this command");
    for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++) {
        PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
        Kick(i);
    }
    new szString[128];
    format(szString, sizeof szString, "Administrator '%s' has kicked all players", GetPlayerNameEx(playerid));
    SendClientMessage(playerid, COLOR_LIGHTBLUE, szString);
    return 1;
}
CMD:muteall(playerid, params[]) {
    if(PlayerInfo[playerid][eLevel] < 5 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, red, "-Error You ain't high enough level to use this command");
    for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++) {
        if(IsPlayerConnected(i) && (i != playerid)) {
            PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
            PlayerInfo[i][Muted] = 1;
            PlayerInfo[i][MuteWarnings] = 0;
        }
    }
    new szString[128];
    format(szString, sizeof szString, "Administrator '%s' has muted all players", GetPlayerNameEx(playerid));
    SendClientMessage(playerid, COLOR_LIGHTBLUE, szString);
    return 1;
}
CMD:unmuteall(playerid, params[]) {
    if(PlayerInfo[playerid][eLevel] < 5 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, red, "-Error You ain't high enough level to use this command");
    for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++) {
        if(IsPlayerConnected(i) && (i != playerid)) {
            PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
            PlayerInfo[i][Muted] = PlayerInfo[i][MuteWarnings] = 0;
        }
    }
    new szString[128];
    format(szString, sizeof szString, "Administrator '%s' has unmuted all players", GetPlayerNameEx(playerid));
    SendClientMessage(playerid, COLOR_LIGHTBLUE, szString);
    return 1;
}
GetPlayerNameEx(playerid) {
    new szName[MAX_PLAYER_NAME + 1];
    GetPlayerName(playerid, szName, sizeof szName);
    return szName;
}
No, Level, is definitely used, see in every command, if player info, level = 5 , so .. anyways, it's okay as i dont see much problems to correct, Red? i dont need to define colors as you (target whatever who) are going to change it, and you didnt appointed any other thing, completly a useless reply.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)