TAKE DATA FROM SQL - 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: TAKE DATA FROM SQL (
/showthread.php?tid=123163)
TAKE DATA FROM SQL -
Zafire2008 - 24.01.2010
Hey i have a sql database i want to take this:
Db is "Evo" ... table is "users" ... take "nick" where name is "jose"
and the "nick" show ir on and sendformatedtext
Any help :S? i need how to use and show data from sql
Re: TAKE DATA FROM SQL -
Miguel - 24.01.2010
Use sscanf (normal or 2.0, doesn't matter) and some variables. Here's an example:
pawn Code:
enum playeri
{
name[24],
cash,
age
}
pawn Code:
new pinfo[MAX_PLAYERS][playeri];
pawn Code:
LoadData(playerid)
{
MySQLCheck();
new
pName[24],
query[61],
line[100];
GetPlayerName(playerid, pName, 24);
mysql_real_escape_string(pName, pName);
format(query, sizeof(query), "SELECT * FROM `users` WHERE nick='%s'", pName); // we check and get the gata from that name
mysql_query(query);
mysql_store_result(); // we store the result.
mysql_fetch_row_format(line, "."); // we set a delimiter
sscanf(line, "p.sdd", pinfo[playerid][name], pinfo[playerid][cash], pinfo[playerid][age]); // this will get the first 3 fields into pinfo[playerid][playeri]
mysql_free_result();
}
Re: TAKE DATA FROM SQL -
Zafire2008 - 25.01.2010
ok thx.. if i want to take Cash from table and show it on sendplayerformattedtext?
Re: TAKE DATA FROM SQL -
Zafire2008 - 25.01.2010
help please
Re: TAKE DATA FROM SQL -
Zafire2008 - 25.01.2010
how i can useee LoadData for give me for example information abaout "Cash" and send it on a formatted text? :S
![confused](images/smilies/confused.gif)
:S:S