31.07.2016, 08:25
Hello! I'm struggling on how I should approach this.
So basically my initial approach to get total members of a specific faction is simply loop through my rows and
keep adding 1 if `factionid` value appears same on different users. That way I can simply get total people with that one specific faction id. (I'm not entirely sure how I can do this in pawno if someone can help me)
Also, I'd like to get people who are "online" from that faction.
And when a user does /factions.
I have a MySQL table called `accounts` which has field `factionid`. So I'm trying to loop through all the faction ID and keep adding one if the value of `factionid` repeats. Faction ID value is integer.
For instance
John_White is in `factionID` = 12
Also
Ben_White is in `factionID` = 12
So that's two people in faction ID 12. Faction ID also represents `factionname` so when a user does /factions
I'd like to Print faction name and people online and total members in that one faction.
It shows them ex: "Faction Name" | "2/10"
2 is online users from that faction and 10 is out of total members.
I so far got /factions which returns me all the faction name in the database. Now I need to add the remaining which is showing total members in that faction and online users for that faction.
Here is my MYSQL table structure.
This is my `faction` table.
This is my `accounts` table.
Also factionid and factionname they're both same for both tables `accounts` and `faction`
So basically my initial approach to get total members of a specific faction is simply loop through my rows and
keep adding 1 if `factionid` value appears same on different users. That way I can simply get total people with that one specific faction id. (I'm not entirely sure how I can do this in pawno if someone can help me)
Also, I'd like to get people who are "online" from that faction.
And when a user does /factions.
I have a MySQL table called `accounts` which has field `factionid`. So I'm trying to loop through all the faction ID and keep adding one if the value of `factionid` repeats. Faction ID value is integer.
For instance
John_White is in `factionID` = 12
Also
Ben_White is in `factionID` = 12
So that's two people in faction ID 12. Faction ID also represents `factionname` so when a user does /factions
I'd like to Print faction name and people online and total members in that one faction.
It shows them ex: "Faction Name" | "2/10"
2 is online users from that faction and 10 is out of total members.
I so far got /factions which returns me all the faction name in the database. Now I need to add the remaining which is showing total members in that faction and online users for that faction.
PHP код:
CMD:factions(playerid,params[])
{
mysql_tquery(mysql, "SELECT * FROM `Factions` LIMIT "#MAX_FACTIONS"", "LoadFactionsIG", "i",playerid);
mysql_tquery(mysql, "SELECT * FROM `accounts` LIMIT "#MAX_FACTIONS"", "LoadFactionsIG", "i",playerid);
return 1;
}
forward LoadFactionsIG(playerid);
public LoadFactionsIG(playerid)
{
if(playerid == INVALID_PLAYER_ID) return 1;
new rows,fields,str[160];
cache_get_data(rows,fields,mysql);
if(!rows) return 1;
new fracName[32];
for (new i; i < rows; i++)
{
cache_get_field_content_int(i, "factionid");
cache_get_field_content(i, "Name",fracName,mysql);
format(str, sizeof(str), "%s%s \n",str,fracName);
}
ShowPlayerDialog(playerid, 10, DIALOG_STYLE_MSGBOX, "Factions", str, "OK","");
return 1;
}
This is my `faction` table.
This is my `accounts` table.
Also factionid and factionname they're both same for both tables `accounts` and `faction`