M4ST3RX Posted July 1, 2018 Share Posted July 1, 2018 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? Link to comment
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