SA-MP Forums Archive
Query help - 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: Query help (/showthread.php?tid=435104)



Query help - zDevon - 05.05.2013

I'm trying to retrieve all the names of players within a certain faction via MySQL and place them in a list dialog. Here's what I have:

pawn Код:
new name[32],res[32],str1[800],query[256],fid=editingfaction[playerid];
format(query,sizeof(query),"SELECT * FROM users WHERE Faction = '%i'",fid);
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query,"|")) {
    mysql_fetch_field_row(res, "AccountName");
    format(name,sizeof(name),"%s\n",res);
    strcat(str1,name,800);
}
mysql_free_result();
ShowPlayerDialog(playerid,DIALOG_FACTIONMEMBERS,DIALOG_STYLE_LIST,"Faction management",str1,"Select","Back");
And it works - sometimes. In some instances it will return all players in the faction, and others only display one or two random names that are in it. I can't figure out the source of these inconsistencies, any help?


Re: Query help - kamzaf - 05.05.2013

ShowPlayerDialog should be after strcat and before mysql_free_result.


Re: Query help - zDevon - 05.05.2013

Same results :/


Re: Query help - zDevon - 06.05.2013

Bump. Kamzaf's solution fixed it but it started happening again shortly after.