Liberty Unleashed
Scripting => Script Help => Topic started by: Motley on August 01, 2016, 03:35:44 pm
-
I'm not familiar with sq-lite but i really do not understand why it never updates.
function onUpdatePlayerAccount(player, statDB) {
// format the update query
local szquery = format( "UPDATE Stats SET Auto_Login=" + Auto_Login[ player.ID ] + ", Kills=" + Kills[ player.ID ] + ", Deaths=" + Deaths[ player.ID ] + ", Money=" + Money[ player.ID ] + ", Bank=" + Bank[ player.ID ] + ", Skin='" + player.Skin + ", Wanted_Level='" + player.WantedLevel + ", Health='" + player.Health + ", Armour='" + player.Armour + "' WHERE Name='" + player.Name + "'" );
// execute the query
::sqlite_query( statDB, szquery );
MessagePlayer("Done", player);//just a random test
}
Any guidance is appreciated.
Also I do not receive errors
-
function onUpdatePlayerAccount(player, statDB) {
local szquery = "UPDATE Stats SET Auto_Login=" + Auto_Login[ player.ID ] + ", Kills=" + Kills[ player.ID ] + ", Deaths=" + Deaths[ player.ID ] + ", Money=" + Money[ player.ID ] + ", Bank=" + Bank[ player.ID ] + ", Skin=" + player.Skin + ", Wanted_Level=" + player.WantedLevel + ", Health=" + player.Health + ", Armour=" + player.Armour + " WHERE Name='" + player.Name + "'";
sqlite_query( statDB, szquery );
MessagePlayer("Done", player);
}
-
Works! Thank you!!
Are you able to describe what I did wrong? I see you removed th brackets making it more of a string, I would of never thought of doing so. :D
-
Format is only useful if you need replace or add something to a string, e.g:
"Around %i of my schoolmates were to %s"
- %i: integer
- %s: string
- %f: float
so: format("Around %i of my schoolmates were to %s", 30, "the party");
%i will be replaced with the integer 30 and %s with the string "the party"
You had a starting ' without finish it. For update a string you need to complete it, so: " Auto_Login='"+Auto_Login[player.ID]+"' ". In integers you don't need any '.
-
Thanks an awesome example I really was not expecting all of that kuddos :D ;)