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 Код:
// 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;
}