Players Faction Online
#1

How Can I create a command /fazioni that opens a ShowPlayerDialog with options, if I select an option it shows the online players of the faction, for example: I select police, shows Members online: [number]; and under it there are a name_surname of the players.
Reply
#2

Whenever you make someone a police member, use a variable to store the members and then print it in the dialog.
Something like this:
PHP код:
new PoliceMembers;
PoliceMembers ++; // Where you set someone to join the police
new string[56];
format(stringsizeof(string), "Police members: %d"PoliceMembers); 
Reply
#3

Can you give me a full code?
Reply
#4

Maybe something like this?

pawn Код:
stock GetFacCount(fid)
{
    new count;
    foreach(Player, i) {
     if(pInfo[i][pFaction] == fid) count++;
     return count; }
    return 0;
}
Untested.
Reply
#5

Quote:
Originally Posted by Abagail
Посмотреть сообщение
Maybe something like this?

pawn Код:
stock GetFacCount(fid)
{
    new count;
    foreach(Player, i) {
     if(pInfo[i][pFaction] == fid) count++;
     return count; }
    return 0;
}
Untested.
Yes, to show the number of connected members of that faction. although it would be good to add IsPlayerConnected.

Other example.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/polices", cmdtext, true, 10) == 0)
    {
        new string[32], name[24];
        SendClientMessage(playerid, -1, "Active members.");
        foreach(Player,i)
        {
            if(IsPlayerConnected(i))
            {
                if(PlayerInfo[i][Faction] == FACTIONID)
                {
                    GetPlayerName(i, name, 24), format(string, sizeof(string), "%s", name);
                    if(strlen(string) > 0) SendClientMessage(playerid, -1, string);
                }
            }
        }
        return 1;
    }
    return 0;
}
Reply
#6

I want that it opens a menu (ShowPlayerDialog) with options, if i select an option for example Police it shows me the members online: [number] and under the names
Reply
#7

Quote:
Originally Posted by Steveproxy5
Посмотреть сообщение
I want that it opens a menu (ShowPlayerDialog) with options, if i select an option for example Police it shows me the members online: [number] and under the names
So?

pawn Код:
#define ONLINE_FACTS 3246

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case ONLINE_FACTS:
        {
            if(response)
            {
                new string[16], name[24], count;
                switch(listitem)
                {
                    case 0:
                    {
                        foreach(Player, i)
                        {
                            if(PlayerInfo[i][Faction] == listitem+1 /*or FACTIONID */ && IsPlayerConnected(i)) count++;
                        }
                        format(string, sizeof(string), "---- %d members actives. ----", count);
                        SendClientMessage(playerid, -1, string);
                        foreach(Player,i)
                        {
                            if(PlayerInfo[i][Faction] == listitem+1 /*or FACTIONID */ && IsPlayerConnected(i))
                            {
                                GetPlayerName(i, name, 24), format(string, sizeof(string), "%d. %s", i, name);
                                if(strlen(string) > 0) SendClientMessage(playerid, -1, string);
                            }
                        }
                    }
                    //
                }
            }
        }
    }
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/fazioni", cmdtext, true, 10) == 0)
    {
        ShowPlayerDialog(playerid, ONLINE_FACTS, DIALOG_STYLE_LIST, "Online members of factions", "Polices\n", "See", "Back");
        return 1;
    }
    return 0;
}
Reply
#8

IT DOESN'T WORK, HELP ME
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)