Jump to content

Problems with SQLite.


Baseplate

Recommended Posts

Posted
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.

Posted

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.

Posted
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.

Posted

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.

  • Moderators
Posted

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 ?).

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...