CMD:staff(playerid, params[]) { #pragma unused params if(PlayerInfo[playerid][LoggedIn] == true) { new string[192]; new admrank[32]; new count; new pname[MAX_PLAYER_NAME]; for(new i; i<MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(IsPlayerAdmin(i)) { admrank = "{FF0000}RCON Admin"; } else { switch(PlayerInfo[i][AdminLevel]) { case 1: admrank = "{FFFF00}Moderator"; case 2: admrank = "{008000}Administrator"; case 3: admrank = "{3366FF}Manager"; } GetPlayerName(i, pname, sizeof(pname)); format(string, sizeof(string), "{FFFFFF}%s (ID: %d) | Level: %d | Rank: %s", pname, i, PlayerInfo[i][AdminLevel], admrank); ++count; } } } if(!count) format(string, sizeof(string), "{FF0000}There are currently no staff online."); ShowPlayerDialog(playerid, DIALOGID0+2, DIALOG_STYLE_MSGBOX, "{FFFFFF}Server staff currently online:", string, "Okay", ""); return 1; } else return SendClientMessage(playerid, COLOR_RED, "ERROR: Account must be registered in order to use commands."); }
CMD:staff(playerid, params[])
{
#pragma unused params
if(PlayerInfo[playerid][LoggedIn] == true)
{
new string[192];
new string2[192]
new admrank[32];
new count;
new pname[MAX_PLAYER_NAME];
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GetPlayerName(i, pname, sizeof(pname));
if(IsPlayerAdmin(i))
{
admrank = "{FF0000}RCON Admin";
format(string2, sizeof(string2), "{FFFFFF}%s (ID: %d) | Level: %d | Rank: %s", pname, i, PlayerInfo[i][AdminLevel], admrank);
strcat(string, string2);
++count;
}
else if(PlayerInfo[i][AdminLevel] > 0)
{
switch(PlayerInfo[i][AdminLevel])
{
case 1: admrank = "{FFFF00}Moderator";
case 2: admrank = "{008000}Administrator";
case 3: admrank = "{3366FF}Manager";
}
format(string2, sizeof(string2), "{FFFFFF}%s (ID: %d) | Level: %d | Rank: %s", pname, i, PlayerInfo[i][AdminLevel], admrank);
strcat(string, string2);
++count;
}
}
}
if(!count)
format(string, sizeof(string), "{FF0000}There are currently no staff online.");
ShowPlayerDialog(playerid, DIALOGID0+2, DIALOG_STYLE_MSGBOX, "{FFFFFF}Server staff currently online:", string, "Okay", "");
return 1;
} else return SendClientMessage(playerid, COLOR_RED, "ERROR: Account must be registered in order to use commands.");
}
if (IsPlayerAdmin(i))
{
admrank = "{FF0000}RCON Admin";
}
else
{
switch (PlayerInfo[i][AdminLevel])
{
case 1:
admrank = "{FFFF00}Moderator";
case 2:
admrank = "{008000}Administrator";
case 3:
admrank = "{3366FF}Manager";
}
GetPlayerName(i, pname, sizeof(pname));
format(string, sizeof(string), "{FFFFFF}%s (ID: %d) | Level: %d | Rank: %s", pname, i, PlayerInfo[i][AdminLevel], admrank);
++count;
}
format(string, sizeof (string), "%s ...", string, ...);
if (IsPlayerAdmin(i))
{
GetPlayerName(i, pname, sizeof(pname));
format(string, sizeof(string), "%s{FFFFFF}%s (ID: %d) {FF0000}RCON Admin\n", string, pname, i);
++count;
// If RCON:
// - get name
// - re-format text
// - increase counter
}
else
{
switch (PlayerInfo[i][AdminLevel])
{
// If the player is not admin, skip the current player and go to the next so..
// the code below will not have any effect (will not be executed at all) to non admins
case 0: continue; // <--'
case 1: admrank = "{FFFF00}Moderator";
case 2: admrank = "{008000}Administrator";
case 3: admrank = "{3366FF}Manager";
}
GetPlayerName(i, pname, sizeof(pname));
format(string, sizeof(string), "%s{FFFFFF}%s (ID: %d) | Level: %d | Rank: %s\n", string, pname, i, PlayerInfo[i][AdminLevel], admrank);
++count;
// If admin:
// - get name
// - re-format text
// - increase counter
// If NOT admin:
// - skip it - continue to the next player
}
CMD:staff(playerid, params[])
{
#pragma unused params
if(PlayerInfo[playerid][LoggedIn] == true)
{
new string[192];
new admrank[32];
new count;
new pname[MAX_PLAYER_NAME];
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerAdmin(i))
{
admrank = "{FF0000}RCON Admin";
}
else
{
switch(PlayerInfo[i][AdminLevel])
{
case 1: admrank = "{FFFF00}Moderator";
case 2: admrank = "{008000}Administrator";
case 3: admrank = "{3366FF}Manager";
default: continue;
}
++count;
}
GetPlayerName(i, pname, sizeof(pname));
format(string, sizeof(string), "{FFFFFF}%s (ID: %d) | Level: %d | Rank: %s", pname, i, PlayerInfo[i][AdminLevel], admrank);
SendClientMessage(playerid, -1, string); }
}
if(!count)
format(string, sizeof(string), "{FF0000}There are currently no staff online.");
ShowPlayerDialog(playerid, DIALOGID0+2, DIALOG_STYLE_MSGBOX, "{FFFFFF}Server staff currently online:", string, "Okay", "");
return 1;
} else return SendClientMessage(playerid, COLOR_RED, "ERROR: Account must be registered in order to use commands.");
}
This is your code:
pawn Code:
- If the player is not RCON admin, it gets the name even if the level is 0 and it uses as rank the previous value (if any). - `string` is overwritten every time. Using: pawn Code:
- Not new lines. The correct steps are shown below: pawn Code:
|
CMD:staff(playerid, params[])
{
#pragma unused params
if(PlayerInfo[playerid][LoggedIn] == true)
{
new string[192];
new admrank[32];
new count;
new pname[MAX_PLAYER_NAME];
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if (IsPlayerAdmin(i))
{
GetPlayerName(i, pname, sizeof(pname));
format(string, sizeof(string), "%s{FFFFFF}%s (ID: %d) {FF0000}RCON Admin\n", string, pname, i);
++count;
}
else
{
switch(PlayerInfo[i][AdminLevel])
{
case 0: continue;
case 1: admrank = "{FFFF00}Moderator";
case 2: admrank = "{008000}Administrator";
case 3: admrank = "{3366FF}Manager";
}
GetPlayerName(i, pname, sizeof(pname));
format(string, sizeof(string), "%s{FFFFFF}%s (ID: %d) | Level: %d | Rank: %s\n", string, pname, i, PlayerInfo[i][AdminLevel], admrank);
++count;
}
}
}
if(count == 0) return format(string, sizeof(string), "{FF0000}There are currently no staff online.");
ShowPlayerDialog(playerid, DIALOGID0+2, DIALOG_STYLE_MSGBOX, "{FFFFFF}Server staff currently online:", string, "Okay", "");
return 1;
} else return SendClientMessage(playerid, COLOR_RED, "ERROR: Account must be registered in order to use commands.");
}
if(count == 0) return format(string, sizeof(string), "{FF0000}There are currently no staff online.");
{FFFFFF}Server staff currently online:
{FFFFFF}Christopher (ID: 2) | Level: 2 | Rank: {008000}Administrator
{FFFFFF}George (ID: 3) {FF0000}RCON Admin
{FFFFFF}John (ID: 5) | Level: 1 | Rank: {FFFF00}Moderator
{FFFFFF}Robert (ID: 9) | Level: 3 | Rank: {3366FF}Manager
format(string, sizeof (string), "Infernus\n");
format(string, sizeof (string), "Banshee\n");
print(string);
// First method:
format(string, sizeof (string), "Infernus\n");
format(string, sizeof (string), "%sBanshee\n", string);
print(string);
// Second method:
format(tmp, sizeof (tmp), "Infernus\n");
strcat(string, tmp); // string now is "Infernus\n"
format(tmp, sizeof (tmp), "Banshee\n");
strcat(string, tmp); // string now is "Infernus\nBanshee\n"
print(string);
public OnPlayerCommandReceived(playerid, cmd[], params[], flags){
if(!PlayerInfo[playerid][LoggedIn])return SendClientMessage(playerid, -1, "You must be logged in!"), 0;
return 1;
}
#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(s, 32, "%s[%d]", PlayerData[pid][Name], pid);
return s;
}
CMD:staff(pid){
new rank,
bs[500];
foreach(new i : Player){
if(!(rank=getAdminRank(i)))continue;
format(bs, sizeof(bs), "%s%s | %s\n", bs, getNameWithID(i), aRankNames[rank]);
}
if(!strlen(bs))
return SendClientMessage(pid, -1, "No staff online!");
ShowPlayerDialog(pid, DIALOG_STAFF, DIALOG_STYLE_MSGBOX, "Server staff", bs, "Okay", "");
return 1;
}