MySQL Query - Advanced scripters - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MySQL Query - Advanced scripters (
/showthread.php?tid=250414)
MySQL Query - Advanced scripters -
DerrydBrincat - 23.04.2011
Sup guys. I have a phone contacts kinda thing I'm working on. Basically, you add a contact, and then you can view all your contacts. I'm just wondering what the correct code is to do view all the contacts you have. The table setup is like: id, belongs_to, contact_name, contact_number.
Re: MySQL Query - Advanced scripters -
Biesmen - 23.04.2011
GStylez MYSQL plugin:
Top of the script:
pawn Код:
new
id[MAX_PLAYERS],
belongsto[MAX_PLAYERS],
contactname[MAX_PLAYERS],
contactnumber[MAX_PLAYERS];
Somewhere else:
pawn Код:
new query[128], playername[MAX_PLAYER_NAME], result[128];
GetPlayerName(playerid, playername, sizeof(playername));
format(query, sizeof(query), "SELECT * FROM `yourtable` WHERE `belongs_to` = '%s'", playername); // I assume belongs_to is the field of the guy who's typing the command to view his contact list.
mysql_query(query);
mysql_store_result();
if(mysql_fetch_row_format(result))
{
sscanf(result, "is[24]s[24]i", id[playerid], belongsto[playerid], contactname[playerid], contactnumber[playerid]);
}
mysql_free_result();
not tested.
Re: MySQL Query - Advanced scripters -
DerrydBrincat - 23.04.2011
ddddddd
Re: MySQL Query - Advanced scripters -
Alby Fire - 23.04.2011
pawn Код:
new
query[128];
while(samp_mysql_fetch_row(query)) {
//Data to get
}
Re: MySQL Query - Advanced scripters -
DerrydBrincat - 23.04.2011
Worked. Love you <3
Re: MySQL Query - Advanced scripters -
Biesmen - 23.04.2011
I'm not familair with that plugin.
But you could try what Alby told you.
Edit: Saw your reply too late.
Re: MySQL Query - Advanced scripters -
DerrydBrincat - 23.04.2011
Btw, when I add this into my script and compile, PAWNO tells me theres shit load of errors, for e.g., 'string already defined', when string is correctly defined in different commands, and not defined globally.
Re: MySQL Query - Advanced scripters - Max_Coldheart - 23.04.2011
Quote:
Originally Posted by DerrydBrincat
ddddddd
|
A cunt raising his postcount
Re: MySQL Query - Advanced scripters -
Vince - 23.04.2011
Quote:
Originally Posted by Max_Coldheart
A cunt raising his postcount
|
And what does that make you then? Right. Don't post if you have nothing useful to say.
@OP: I recommend using sscanf to split lines instead of split of explode. This is much faster and much easier to work with.