staff command is wrongfully coded, shows only 1 admin instead of more...
#9

Start using foreach, makes loop writing much easier and efficent.
You may use server administrator rank names other places also, so you can define it globally.
You can also store players name into array, so you don't have to use GetPlayerName every time you want to use it.
Define dialog ID's with name, so in the future you will understand also, what have you written together or start using easyDialog, so everything related with dialogs can be in one place.
Every command doesn't need check if player is logged in.
Example code of checking if player is logged in or not, it depends what command processor you are using.
PHP Code:
public OnPlayerCommandReceived(playeridcmd[], params[], flags){
    if(!
PlayerInfo[playerid][LoggedIn])return SendClientMessage(playerid, -1"You must be logged in!"), 0;
    return 
1;

PHP Code:
#include <YSI_Data\y_iterate>   //iterating through arrays
enum{
    
DIALOG_STAFF
};
static const 
aRankNames[][40]={
    
"",
    
"{FFFF00}Moderator",
    
"{008000}Administrator",
    
"{3366FF}Manager",
    
"{FF0000}RCON Admin"
};
getAdminRank(pid){
    if(
IsPlayerAdmin(pid)) return (sizeof(aRankNames) - 1);
    return 
PlayerInfo[pid][AdminLevel];
}
getNameWithID(pid){
    new 
s[32];
    
format(s32"%s[%d]"PlayerData[pid][Name], pid);
    return 
s;
}
CMD:staff(pid){
    new 
rank,
        
bs[500];
    foreach(new 
Player){
        if(!(
rank=getAdminRank(i)))continue;
        
format(bssizeof(bs), "%s%s | %s\n"bsgetNameWithID(i), aRankNames[rank]);
    }
    if(!
strlen(bs))
        return 
SendClientMessage(pid, -1"No staff online!");
    
ShowPlayerDialog(pidDIALOG_STAFFDIALOG_STYLE_MSGBOX"Server staff"bs"Okay""");
    return 
1;

Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)