Problem with DIALOG STYLE TABLIST HEADER
#1

Hey, so I've got this stock that shows the available factions:

PHP код:
stock ViewFactions(playerid)
{
    new 
string[1040];
    for (new 
0!= MAX_FACTIONS++) if (FactionData[i][factionExists]) {
         
//format(string, sizeof(string), "Faction ID\tFaction Name\tCurrently Online\n\%sFaction (%i) | %s\n", string, i, FactionData[i][factionName]);
         
format(stringsizeof(string),
        
"Faction ID\tName\tOnline\n\
        %sFaction ID: %i\t%s\tN/A\n\
           "
stringiFactionData[i][factionName]);
    }
    
Dialog_Show(playeridFactionsListDIALOG_STYLE_TABLIST_HEADERS"AVAILABLE FACTIONS"string"CANCEL""");
    return 
1;

And I'd like to do it like in LSRP:


but the problem that occurs and happens it like this:
Reply
#2

I'm looking how to calculate how much online in each faction..
Reply
#3

Here we go :
PHP код:
stock ViewFactions(playerid)
{
    new 
string[1040];
    for (new 
0!= MAX_FACTIONS++) if (FactionData[i][factionExists]) {
         
//format(string, sizeof(string), "Faction ID\tFaction Name\tCurrently Online\n\%sFaction (%i) | %s\n", string, i, FactionData[i][factionName]);
         
format(stringsizeof(string),
        
"Faction ID\tName\tOnline\n\
        %sFaction ID: %i\t%s\tN/A\n\
           "
stringiFactionData[i][factionName]);
    }
    
Dialog_Show(playeridFactionsListDIALOG_STYLE_TABLIST_HEADERS"AVAILABLE FACTIONS"string"CANCEL""");
    return 
1;

to

PHP код:
stock ViewFactions(playerid)
{
    new 
string[1040], string1[1040];
    for (new 
0!= MAX_FACTIONS++)
    {
         
//format(string, sizeof(string), "Faction ID\tFaction Name\tCurrently Online\n\%sFaction (%i) | %s\n", string, i, FactionData[i][factionName]);
        
format(stringsizeof(string),"Faction ID: %i\t%s\tN/A\n"iFactionData[i][factionName]);
        
strcat(string1stringsizeof(string1));
    }
    
format(stringsizeof(string), "Faction ID\tFaction Name\tCurrently Online\n%s"string1);
    
ShowPlayerDialog(playerid6542DIALOG_STYLE_TABLIST_HEADERS"AVAILABLE FACTIONS"string"CANCEL""");
    return 
1;

You need Formate all of your strings (lines of your table) in one with strcat. Why after the for (...), put a new format? Because if you put in the loop, it will add like this:
ID Name N/A
0 LSPD N/A
ID Name N/A
1 LFDP N/A [...]

If you have any questions, post them here.
I hope I helped you.
Reply
#4

Because LSRP doesn't use that dialog, it was made before it was introduced, they just add spaces with \n or manually adding them in.
Reply
#5

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
Here we go :
PHP код:
stock ViewFactions(playerid)
{
    new 
string[1040];
    for (new 
0!= MAX_FACTIONS++) if (FactionData[i][factionExists]) {
         
//format(string, sizeof(string), "Faction ID\tFaction Name\tCurrently Online\n\%sFaction (%i) | %s\n", string, i, FactionData[i][factionName]);
         
format(stringsizeof(string),
        
"Faction ID\tName\tOnline\n\
        %sFaction ID: %i\t%s\tN/A\n\
           "
stringiFactionData[i][factionName]);
    }
    
Dialog_Show(playeridFactionsListDIALOG_STYLE_TABLIST_HEADERS"AVAILABLE FACTIONS"string"CANCEL""");
    return 
1;

to

PHP код:
stock ViewFactions(playerid)
{
    new 
string[1040], string1[1040];
    for (new 
0!= MAX_FACTIONS++)
    {
         
//format(string, sizeof(string), "Faction ID\tFaction Name\tCurrently Online\n\%sFaction (%i) | %s\n", string, i, FactionData[i][factionName]);
        
format(stringsizeof(string),"Faction ID: %i\t%s\tN/A\n"iFactionData[i][factionName]);
        
strcat(string1stringsizeof(string1));
    }
    
format(stringsizeof(string), "Faction ID\tFaction Name\tCurrently Online\n%s"string1);
    
ShowPlayerDialog(playerid6542DIALOG_STYLE_TABLIST_HEADERS"AVAILABLE FACTIONS"string"CANCEL""");
    return 
1;

You need Formate all of your strings (lines of your table) in one with strcat. Why after the for (...), put a new format? Because if you put in the loop, it will add like this:
ID Name N/A
0 LSPD N/A
ID Name N/A
1 LFDP N/A [...]

If you have any questions, post them here.
I hope I helped you.
Yes, it is mate, thank you. but you could please tell me how do I count the online members on each faction, in print it in the dialog? where the N/A is
Reply
#6

Hm. You need to do a loop which is counting every players with the same faction. Like this :
PHP код:
new count=0;
for(new 
i=0i<MAX_PLAYER; ++)
{
    if(
PlayerInfo[playerid][Faction] != Factionid) continue;
    
counter++;

Reply
#7

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
Hm. You need to do a loop which is counting every players with the same faction. Like this :
PHP код:
new count=0;
for(new 
i=0i<MAX_PLAYER; ++)
{
    if(
PlayerInfo[playerid][Faction] != Factionid) continue;
    
counter++;

I should've to put it in each faction, or to double the factionID thingy? give me an example still didn't got how to use it properly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)