I have a function that gets the information of all the cars that has been bought for ingame money and it can spawn the cars when the resource is started but when a player disconnects and the vehicle data is changed when the player reconnects he is not able to see the changes to the car as I looked over other scripts they only using server side.
This is the only function that gets the vehicles data from the database but it only does when the resource starts
function spawnAllCars()
local query = mysql:query("SELECT * FROM vehicles")
local rows = mysql:fetch_assoc(query)
if rows then
while true do
local veh = nil
local rows = mysql:fetch_assoc(query)
if not rows then break end
if tonumber(rows["locX"]) ~= 0 and tonumber(rows["locY"]) ~= 0 and tonumber(rows["locZ"]) ~= 0 and tonumber(rows["rotX"]) ~= 0 and tonumber(rows["rotY"]) ~= 0 and tonumber(rows["rotZ"]) ~= 0 then
local veh = createVehicle(tonumber(rows["modelID"]), rows["locX"], rows["locY"], rows["locZ"], rows["rotX"], rows["rotY"], rows["rotZ"])
else
local veh = createVehicle(tonumber(rows["modelID"]), rows["spawnLocX"], rows["spawnLocY"], rows["spawnLocZ"], rows["spawnRotX"], rows["spawnRotY"], rows["spawnRotZ"])
end
setVehColor(veh, rows["color1"], rows["color2"], rows["color3"], rows["color4"])
setElementHealth(veh, rows["damage"])
setElementInterior(veh, tonumber(rows["interior"]))
setElementDimension(veh, tonumber(rows["dimension"]))
table.insert(vehTable, {["id"] = rows["id"], ["health"] = rows["damage"]})
end
end
end
addEventHandler("onResourceStart", getResourceRootElement(), spawnAllCars)
Do I need to add something in client side or just need to change something in this?