thund3rbird23 Posted September 13, 2019 Share Posted September 13, 2019 I want to add values to the current handling. How can I do that? This gives me an error: "attempt to perform arithmetic on local 'handling' (a table value)" local handling = getVehicleHandling(vehicle) setVehicleHandling(vehicle, "engineAcceleration", handling + 0.4) setVehicleHandling(vehicle, "maxVelocity", handling + 19) Link to comment
thund3rbird23 Posted September 13, 2019 Author Share Posted September 13, 2019 I need to use tables. I don't know how to do that... because I wants to get data from database as JSON: local tunings = fromJSON(data.tunings) if tunings == nil then return elseif tunings[1] == 2 then local handling = getVehicleHandling(vehicle) setVehicleHandling(vehicle, "engineAcceleration", handling + 0.4) setVehicleHandling(vehicle, "maxVelocity", handling + 19) end So in the tunings table have this value:[ [ 2, 4, 4, 4 ] ] as you see if the tunings table first value is 2 then I want to add some values to the current handling. How can I do that? Link to comment
Moderators IIYAMA Posted September 13, 2019 Moderators Share Posted September 13, 2019 20 minutes ago, thund3rbird23 said: How can I do that? setVehicleHandling(vehicle, "engineAcceleration", handling.engineAcceleration + 0.4) setVehicleHandling(vehicle, "maxVelocity", handling.maxVelocity + 19) 1 Link to comment
thund3rbird23 Posted September 13, 2019 Author Share Posted September 13, 2019 (edited) mistake , sorry Edited September 13, 2019 by thund3rbird23 Link to comment
thund3rbird23 Posted September 14, 2019 Author Share Posted September 14, 2019 (edited) It doesn't seem to work. I stored steeringLock for all vehicles and I want to set to attach to the vehicles when they are loaded. I did print the vehicle id and the steeringLock from the database and it's correct: print("Load vehicle [" .. vehicleID .. "] for characterId: " .. data.owner) print(data.steeringLock) Quote INFO: Load vehicle [52] for characterId: 1 INFO: 60 then I did setElementData to the vehicles but nothing changes. Keeps the default steeringLock for the vehicles.... setElementData(vehicle, "vehicle.steeringLock", data.steeringLock) setVehicleHandling(vehicle, "steeringLock", data.steeringLock) Or set the handling when players enter the vehicle. Edited September 14, 2019 by thund3rbird23 Link to comment
Scripting Moderators ds1-e Posted September 14, 2019 Scripting Moderators Share Posted September 14, 2019 3 hours ago, thund3rbird23 said: It doesn't seem to work. I stored steeringLock for all vehicles and I want to set to attach to the vehicles when they are loaded. I did print the vehicle id and the steeringLock from the database and it's correct: print("Load vehicle [" .. vehicleID .. "] for characterId: " .. data.owner) print(data.steeringLock) then I did setElementData to the vehicles but nothing changes. Keeps the default steeringLock for the vehicles.... setElementData(vehicle, "vehicle.steeringLock", data.steeringLock) setVehicleHandling(vehicle, "steeringLock", data.steeringLock) Or set the handling when players enter the vehicle. What's purpose for elementdata here? Can you send full code? Maybe mistake is somewhere else. 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