Jump to content

SQLite Problem


xyzii

Recommended Posts

So I'm making a vehicle system with SQL, it's finished but the thing is that when I buy the vehicle, move and hide it then spawn it, it does what it's supposed to do, but the second time I do it, it doesn't work anymore. To clarify, my account name is addaccount. I believe it has something to do with the Affected rows: 0.

 

2016-12-17 23:35:22.292: [script] SUCCESS: Affected rows:0 [Query:UPDATE addaccount SET veh='Buccaneer', x=2140.720703, y=-1117.307617, z=24.937660, rot=264.001465, bp=5000, ups='asd', plate='90QK LL8', hp=1000, fuel=0, lock=0, r=255, g=255, b=255 WHERE num='75834']

 

Here's the code of the hide function

	function hideVehicle(player)
    if (isGuestAccount(player.account)) then return end
    if (not isElement(vehs[player])) then return end
    local num = vehs[player]:getData("num")
    local veh = vehs[player].name
    local xe, ye, ze = getElementPosition(vehs[player])
    local xr, yr, rot = getElementRotation(vehs[player])
    local r, g, b = getVehicleColor(vehs[player], true)
    local lock = getElementData(vehs[player], "lock")
    local ups = getVehicleUpgrades(vehs[player])
    outputChatBox(num..veh..xe..ye..ze..rot..r..g..b..lock)
    
    local query = "UPDATE "..player.account.name.." SET veh=?, x=?, y=?, z=?, rot=?, bp=?, ups=?, plate=?, hp=?, fuel=?, lock=?, r=?, g=?, b=? WHERE num=?"
    dbExec(con, query, veh, xe, ye, ze, rot, 5000, "asd", vehs[player].plateText, vehs[player].health, vehs[player]:getData("fuel"), lock, r, g, b, num)
    
    destroyElement(vehs[player]) 
    vehs[player] = nil
    return true
end
addCommandHandler("hide", hideVehicle)
	
Edited by xyzii
Link to comment

Then the only thing that's left is the table itself. Did you try using a graphical viewer to check if records have the field num as it's supposed to? 

But since you don't change this field and the first time it's working then we can delete this from the list.

Still see if the table has the correct values that you get from the script. 

Note: It is usually good practice to surround table and column names with backticks (`) in case they contain spaces or SQL keywords (and therefore cause syntax errors). This is especially true when using variables for table and column names, as potential problems may not be apparent when the script is first written.

Some vehicle have spaces in their name, and the plate can have spaces too.

Other than this i'm out of ideas

Link to comment

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