Need some help with three options +rep
#5

Quote:
Originally Posted by Kevln
Посмотреть сообщение
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;
}
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)
Reply


Messages In This Thread
Need some help with three options +rep - by DemME - 27.10.2015, 22:12
Re: Need some help with three options +rep - by Scottylad - 27.10.2015, 23:37
Re: Need some help with three options +rep - by DemME - 27.10.2015, 23:45
Re: Need some help with three options +rep - by Kevln - 28.10.2015, 00:10
Re: Need some help with three options +rep - by DemME - 28.10.2015, 02:29
Re: Need some help with three options +rep - by Kevln - 28.10.2015, 03:01
Re: Need some help with three options +rep - by DemME - 28.10.2015, 03:19
Re: Need some help with three options +rep - by Kevln - 28.10.2015, 04:03

Forum Jump:


Users browsing this thread: 1 Guest(s)