Jump to content

SetVehicleHandling problem


thund3rbird23

Recommended Posts

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

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

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 by thund3rbird23
Link to comment
  • Scripting Moderators
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

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