enum pInfo { pPass, pCash, pAdmin, pSkin, pKills, pDeaths } new PlayerInfo[MAX_PLAYERS][pInfo]; CMDetadmin(playerid, params[]) { new pID, value; if(!IsPlayerAdmin(playerid)) return 0; else if(sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, -1, "Usage: /setadmin (id) (level)"); else if(value < 0 || value > 5) return SendClientMessage(playerid, -1, "Only levels 0-5"); else if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Player Is Not Currently Connected"); else { new string[128], string1[128], target[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME]; GetPlayerName(playerid, pName, sizeof(pName)); GetPlayerName(pID, target, sizeof(target)); format(string, sizeof(string), "You have set %s Admin level to %i", target, value); SendClientMessage(playerid, -1, string); format(string, sizeof(string), "Your Admin level has been set to %i by %s", value, pName); SendClientMessage(pID, -1, string1); PlayerInfo[pID][pAdmin] = value; } return 1; } |
CMD:admins(playerid) {
new string[128+MAX_PLAYER_NAME], plName[MAX_PLAYER_NAME];
foreach(Player, i) {
if(PlayerInfo[i][pAdmin] != 0) {
GetPlayerName(i, plName, sizeof plName);
format(string, sizeof string, "%sAdmin: %s(%d)\n", string, plName, i);
}
ShowPlayerDialog(playerid, DIALOG_ID, DIALOG_STYLE_MSGBOX, "Admins Online", string, "Okay, "");
}
return 1;
}
CMD:admins(playerid) {
new string[256], tempstring[56], plName[MAX_PLAYER_NAME];
foreach(Player, i) {
if(PlayerInfo[i][pAdmin] != 0) {
GetPlayerName(i, plName, sizeof plName);
format(tempstring, sizeof tempstring, "Admin: %s(%d), Rank:%d\n", plName, i, PlayerInfo[i][pAdmin]);
strcat(string, tempstring, sizeof(string));
}
ShowPlayerDialog(playerid, DIALOG_ID, DIALOG_STYLE_MSGBOX, "Admins Online", string, "Okay, "");
}
return 1;
}
This will work:
PHP Code:
|
You've just copied my code and added strcat. I've nothing wrong with that, but, I really don't see the point. Also, you haven't read ******' tutorial about using 256 sized strings.
|
CMD:admins(playerid, params[])
{
#pragma unused params
//..
new string[41*12], name[24], sformat[41], admins; // string[41*12] = max 12 admins show in dialog.
//..
for(new i; i != MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin] >= 1)
{
GetPlayerName(i, name, sizeof(name));
format(sformat, sizeof(sformat), "* %s Level %d.\n", name, PlayerInfo[i][pAdmin]);
strcat(string, sformat);
admins = admins+1;
}
}
}
if(admins < 1)
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, "Info admins", "There are no administrators connected.", "accept", "exit");
else if(admins >= 1)
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MGSBOX, "Info admins", string, "accept", "exit");
return true;
}
new string[41*12]; // (12)
format(string, sizeof string, "%sAdmin: %s(%d)\n", string, plName, i);
My code would show all the admins that are online.
pawn Code:
|
CMD:admins(playerid, params[])
{
#pragma unused params
//..
new string[41*12], name[24], sformat[41], admins; // string[41*12] = max 12 admins show in dialog.
//..
for(new i; i != MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin] >= 1)
{
GetPlayerName(i, name, sizeof(name));
format(sformat, sizeof(sformat), "* %s Level %d.\n", name, PlayerInfo[i][pAdmin]);
strcat(string, sformat);
admins = admins+1;
}
}
}
if(admins < 1)
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, "Info admins", "There are no administrators connected.", "Close", "");
else if(admins >= 1)
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MGSBOX, "Info admins", string, "Close", "");
return true;
}