Baseplate Posted April 10, 2014 Posted April 10, 2014 local connection = dbConnect( "sqlite", "data.db" ) function saveThings() local x, y, z = getElementPosition(source) local accountName = getAccountName(getPlayerAccount(source)) dbExec(connection, "UPDATE players SET skin=?, x=?, y=?, z=?, int=?, dim=?, wanted=?, money=?, occupation=?, team=?, nick=?, wp=? WHERE account=?", tostring(getElementModel(source)), tostring(x), tostring(y), tostring(z), tostring(getElementInterior(source)), tostring(getElementDimension(source)), tostring(getPlayerWantedLevel(source)), tostring(getPlayerMoney(source)), tostring(getElementData(source, "Occupation")), tostring(getTeamName(getPlayerTeam(source))), tostring(getPlayerName(source)), tostring(getElementData(source, "wantedPoints")), accountName) dbExec(connection, "UPDATE weapons SET playerWeaponAmmo0=?, playerWeaponAmmo1=?, playerWeaponAmmo2=?, playerWeaponAmmo3=?, playerWeaponAmmo4=?, playerWeaponAmmo5=?, playerWeaponAmmo6=?, playerWeaponAmmo7=?, playerWeaponAmmo8=?, playerWeaponAmmo9=?, playerWeaponAmmo10=?, playerWeaponAmmo11=?, playerWeaponAmmo10=?, pistolstat=?, silencedstat=?, desertstat=?, shotgunstat=?, sawnoffstat=?, spazstat=?, microstat=?, mp5stat=?, akstat=?, m4stat=?, sniperstat=? WHERE account=?", getPedTotalAmmo(source, 0), getPedTotalAmmo(source, 1), getPedTotalAmmo(source, 2), getPedTotalAmmo(source, 3), getPedTotalAmmo(source, 4), getPedTotalAmmo(source, 5), getPedTotalAmmo(source, 6), getPedTotalAmmo(source, 7), getPedTotalAmmo(source, 8 ) , getPedTotalAmmo(source, 9), getPedTotalAmmo(source, 10), getPedTotalAmmo(source, 11), getPedTotalAmmo(source, 12), getPedStat(source,69), getPedStat(source,70), getPedStat(source,71), getPedStat(source,72), getPedStat(source,73), getPedStat(source,74), getPedStat(source,75), getPedStat(source,76), getPedStat(source,77), getPedStat(source,78), getPedStat(source,79), accountName) end addEventHandler("onPlayerLogout", root, saveThings) addEventHandler("onPlayerQuit", root, saveThings) It doesn't update or do anything on player's quit or logout.
Arnold-1 Posted April 10, 2014 Posted April 10, 2014 did you try using dbQuery with dbPoll instead? Ingame Name: Arnold If you need my help, contact me on Skype @bshr.ara NOTE:DO NOT ASK ME FOR SCRIPTS, ASK ME FOR HELP
Baseplate Posted April 10, 2014 Author Posted April 10, 2014 No, besides I wouldn't do it with UPDATE statement.
Noki Posted April 10, 2014 Posted April 10, 2014 Has the connection even been created? Try checking if it was created, and if it was, then execute your code.
Gtagasje Posted April 10, 2014 Posted April 10, 2014 I had this problem too when I tried updating stuff when a player logged out or quit the server. The way I fixed is was by just deleting the row and inserting it again instead of updating it, this seemed to work. You might want to consider trying this if you can't find a different solution. Yes, this is infact a signature.
Baseplate Posted April 10, 2014 Author Posted April 10, 2014 I had this problem too when I tried updating stuff when a player logged out or quit the server. The way I fixed is was by just deleting the row and inserting it again instead of updating it, this seemed to work. You might want to consider trying this if you can't find a different solution. I'll consider giving this a try, will reply later with the result.
Gallardo9944 Posted April 10, 2014 Posted April 10, 2014 It should be fine, but is there anything in debug? If not, try dbQuery and dbFree, it will return an error if it exists. Also, try using ` symbols and ?? instead of ? symbols. That might help for strings which contain different special stuff in. Code Debugger - Minimalistic MTA debug line replacement
Moderators Citizen Posted April 11, 2014 Moderators Posted April 11, 2014 You wrote playerWeaponAmmo10 insead of playerWeaponAmmo13: playerWeaponAmmo10=?, playerWeaponAmmo11=?, playerWeaponAmmo10=? And I just wanted to know why you are saving the ammos of the weapons the player has in each slot but not the weapon id itself ?? (How can you know wich sniper he has for example ?). The rEvolution is coming ...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now