Save data MySQ - 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: Save data MySQ (
/showthread.php?tid=471029)
Save data MySQ -
DexX39 - 20.10.2013
Hello everyone,
I need a little help to save data.
I have a "players" (id_player, username, password, etc) table and "messages" (id_message, text, date, etc) table.
Players can write multiple messages.
I want to know how to save data on a MySQL database.
And how to script level.
With foreign key.
Especially side script :/
Thank you for your help
Re: Save data MySQ -
iGetty - 20.10.2013
To save:
pawn Код:
stock SaveSQL(playerid)
{
new name[24], query[512];
GetPlayerName(playerid, name, sizeof(name));
format(query, sizeof(query), "UPDATE `players` SET `row`=1 WHERE `username`='%s'",
name);
mysql_query(query);
return 1;
}
Then simply, add on what you need to the line, for new items add a comma, EG:
pawn Код:
UPDATE `players` SET `level`=%d, `age`=%d WHERE `username`='%s'", level, age, name);