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 i = 0; i != MAX_FACTIONS; i ++) 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(string, sizeof(string),
"Faction ID\tName\tOnline\n\
%sFaction ID: %i\t%s\tN/A\n\
", string, i, FactionData[i][factionName]);
}
Dialog_Show(playerid, FactionsList, DIALOG_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 i = 0; i != MAX_FACTIONS; i ++) 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(string, sizeof(string),
"Faction ID\tName\tOnline\n\
%sFaction ID: %i\t%s\tN/A\n\
", string, i, FactionData[i][factionName]);
}
Dialog_Show(playerid, FactionsList, DIALOG_STYLE_TABLIST_HEADERS, "AVAILABLE FACTIONS", string, "CANCEL", "");
return 1;
}
to
PHP код:
stock ViewFactions(playerid)
{
new string[1040], string1[1040];
for (new i = 0; i != MAX_FACTIONS; i ++)
{
//format(string, sizeof(string), "Faction ID\tFaction Name\tCurrently Online\n\%sFaction (%i) | %s\n", string, i, FactionData[i][factionName]);
format(string, sizeof(string),"Faction ID: %i\t%s\tN/A\n", i, FactionData[i][factionName]);
strcat(string1, string, sizeof(string1));
}
format(string, sizeof(string), "Faction ID\tFaction Name\tCurrently Online\n%s", string1);
ShowPlayerDialog(playerid, 6542, DIALOG_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 i = 0; i != MAX_FACTIONS; i ++) 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(string, sizeof(string),
"Faction ID\tName\tOnline\n\
%sFaction ID: %i\t%s\tN/A\n\
", string, i, FactionData[i][factionName]);
}
Dialog_Show(playerid, FactionsList, DIALOG_STYLE_TABLIST_HEADERS, "AVAILABLE FACTIONS", string, "CANCEL", "");
return 1;
}
to
PHP код:
stock ViewFactions(playerid)
{
new string[1040], string1[1040];
for (new i = 0; i != MAX_FACTIONS; i ++)
{
//format(string, sizeof(string), "Faction ID\tFaction Name\tCurrently Online\n\%sFaction (%i) | %s\n", string, i, FactionData[i][factionName]);
format(string, sizeof(string),"Faction ID: %i\t%s\tN/A\n", i, FactionData[i][factionName]);
strcat(string1, string, sizeof(string1));
}
format(string, sizeof(string), "Faction ID\tFaction Name\tCurrently Online\n%s", string1);
ShowPlayerDialog(playerid, 6542, DIALOG_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=0; i<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=0; i<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.