CMD:admins(playerid, params[])
{
new count = 0;
SendClientMessage(playerid, COLOR_YELLOW, "Online Administrators:");
foreach (new i : Player) if (PlayerData[i][pAdmin] > 0 && PlayerData[i][pAdminHide] < 1)
{
if (PlayerData[i][pAdminDuty])
SendClientMessageEx(playerid, COLOR_NICEBLUE, "* %s (Level: %d) - (Status)", ReturnName(i, 0), PlayerData[i][pAdmin]);
else
SendClientMessageEx(playerid, COLOR_NICEBLUE, "* %s (Level: %d) - (Status)", ReturnName(i, 0), PlayerData[i][pAdmin]);
count++;
}
if (!count) {
SendClientMessage(playerid, COLOR_WHITE, "There is no admins currently online");
}
return 1;
}
CMD:admins(playerid, params[]) { new count = 0; SendClientMessage(playerid, COLOR_YELLOW, "Online Administrators:"); foreach (new i : Player) if (PlayerData[i][pAdmin] > 0 && PlayerData[i][pAdminHide] < 1) { if (PlayerData[i][pAdminDuty]) SendClientMessageEx(playerid, COLOR_NICEBLUE, "* %s (Level: %d) - (Status)", ReturnName(i, 0), PlayerData[i][pAdmin]); else SendClientMessageEx(playerid, COLOR_NICEBLUE, "* %s (Level: %d) - (Status)", ReturnName(i, 0), PlayerData[i][pAdmin]); count++; } if (!count) { SendClientMessage(playerid, COLOR_WHITE, "There is no admins currently online"); } return 1; }
Код:
CMD:admins(playerid, params[]) { new count = 0; SendClientMessage(playerid, COLOR_YELLOW, "Online Administrators:"); foreach (new i : Player) if (PlayerData[i][pAdmin] > 0 && PlayerData[i][pAdminHide] < 1) { if (PlayerData[i][pAdminDuty]) SendClientMessageEx(playerid, COLOR_NICEBLUE, "* %s (Level: %d) - (Status)", ReturnName(i, 0), PlayerData[i][pAdmin]); else SendClientMessageEx(playerid, COLOR_NICEBLUE, "* %s (Level: %d) - (Status)", ReturnName(i, 0), PlayerData[i][pAdmin]); count++; } if (!count) { SendClientMessage(playerid, COLOR_WHITE, "There is no admins currently online"); } return 1; } I'll overlook this code later on today and I will make you a new one which will be better and functional. |
// DEVELOPMENT SCRIPT
// ** INCLUDES
#include <a_samp>
#include <sscanf>
#include <zcmd>
// ** DEFINES
// *** GENERAL
#define MAX_ADMIN_LEVELS 5
// *** FUNCTIONS
#define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
// *** DIALOGS
#define DIALOG_OK 0
// ** VARIABLES
// *** PER-PLAYER VARIABLES
new pAdminLevel[MAX_PLAYERS],
pStatus[MAX_PLAYERS];
// ** MAIN
main()
{
print("Loaded \"admin_statuses.amx\".");
}
// ** CALLBACKS
public OnGameModeInit()
{
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
pAdminLevel[playerid] = RandomBetween(1, MAX_ADMIN_LEVELS);
return 1;
}
// ** COMMANDS
CMD:admins(playerid, params[])
{
ShowAdminsListDialog(playerid);
return 1;
}
CMD:status(playerid, params[])
{
if(isnull(params) || !IsNumeric(params)) return SendClientMessage(playerid, -1, "Usage: /status (1, 2, 3).");
new value = strval(params);
if(value <= 0 || value >= 4) return SendClientMessage(playerid, -1, "You have entered an invalid status value.");
pStatus[playerid] = value - 1;
new string[144];
format(string, sizeof(string), "You have changed your status to %s.", GetPlayerStatus(playerid));
SendClientMessage(playerid, -1, string);
return 1;
}
// ** FUNCTIONS
stock IsNumeric(const string[]) return !sscanf(string, "{d}");
stock GetPlayerStatus(playerid)
{
new string[10];
switch(pStatus[playerid])
{
case 0: strcat(string, "Available");
case 1: strcat(string, "Busy");
case 2: strcat(string, "Away");
default: strcat(string, "Unknown");
}
return string;
}
stock ShowAdminsListDialog(playerid)
{
new string[256], temp[128], name[MAX_PLAYER_NAME], admins_online;
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i ++)
{
if(!IsPlayerConnected(i)) continue;
if(!pAdminLevel[i]) continue;
GetPlayerName(i, name, MAX_PLAYER_NAME);
format(temp, sizeof(temp), "\n%s\t%d\t%s", name, pAdminLevel[i], GetPlayerStatus(i));
strcat(string, temp);
admins_online ++;
}
if(!admins_online)
{
return ShowPlayerDialog(playerid, DIALOG_OK, DIALOG_STYLE_MSGBOX, "Admin List", "No administrators are online.", "Close", "");
}
else
{
strins(string, "Name\tLevel\tStatus", 0);
return ShowPlayerDialog(playerid, DIALOG_OK, DIALOG_STYLE_TABLIST_HEADERS, "Admin List", string, "Close", "");
}
}
stock RandomBetween(minimum, maximum)
{
new selected = random(maximum - minimum) + minimum;
return selected;
}
Here's a brief example, please adapt it to your script as it won't do you any good to just copy and paste it in to your gamemode.
pawn Код:
|
I'm actually learning from these codes, although. and for an example how do I do that in "Admin list" it will count how much administrators online or hidden? like " Administrators online (X) hidden (Y)
|
And how do I do this? I mentioned already that it's a little be difficult to me.
|