SA-MP Forums Archive
Problem with DIALOG STYLE TABLIST HEADER - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with DIALOG STYLE TABLIST HEADER (/showthread.php?tid=607536)



Problem with DIALOG STYLE TABLIST HEADER - DemME - 21.05.2016

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:



Re: Problem with DIALOG STYLE TABLIST HEADER - DemME - 21.05.2016

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


Re: Problem with DIALOG STYLE TABLIST HEADER - Dayrion - 21.05.2016

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.


Re: Problem with DIALOG STYLE TABLIST HEADER - izeatfishz - 21.05.2016

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.


Re: Problem with DIALOG STYLE TABLIST HEADER - DemME - 21.05.2016

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


Re: Problem with DIALOG STYLE TABLIST HEADER - Dayrion - 21.05.2016

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++;




Re: Problem with DIALOG STYLE TABLIST HEADER - DemME - 22.05.2016

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.