Jump to content

[HELP] Vehicle speed


Recommended Posts

Hello,

I have a speedo that displays your vehicle's speed. I use getElementSpeed useful function to get the vehicle's speed in km/h.
I also have a handling editor (hedit) But something's not right. The maximum velocity that I set in the handling editor is not the same as on the speedo. I set maximum velocity to 100 in hedit, but on the speedo it appears to be ~120.
I made a speed limit script too. When you press a key, your vehicle's speed is locked to your current speed. The script modifies the vehicle's handling, but before doing it, it saves the current one, so it can be reversed by pressing the speed limit key again. The same problem appears: I limit the speed at x, but the speedo says it's faster. The speed locking and unlocking is working, but not at the correct speeed. Or is it the speedo's fault? What could be the problem? I have no idea.

Thanks for reading!

--SPEEDO obtain speed
local vehicleSpeed = math.floor(getElementSpeed(currentVehicle, 1))

--SPEED LIMIT ON
local originalSpeed = getVehicleHandlingProperty(vehicle, "maxVelocity") 
setElementData(vehicle, "vehicleSpeedLimit", aspeed) -- aspeed is the vehicle's speed that I obtained from client side
setElementData(vehicle, "vehicleOriginalSpeed", originalSpeed)
setVehicleHandling(vehicle, "maxVelocity", aspeed)

 

Link to comment

Hello and welcome to the Forums!

I just tested a little bit the maxVelocity handling on most of the sport cars (don't know if it will be the same on the other vehicles) and found out that setting the maxVelocity to 85.5 locks the max speed to exactly 100km/h.

It turns out that maxVelocity is not exactly the same as km/h value.
So yeah, hope this helps!

Edited by SpecT
  • Like 1
Link to comment

I have no idea. I made some research, setting 85.5 for max velocity in the handling results in 100 km/h indeed. To maximum 200 km/h the handling must be 168.5. What's the logic in this? At low speed there are no differences, setting 10 in handling results in 10 km/h. But why are they different at higher speeds? And what's the logic in it, because I don't see any, just random numbers. 🤨

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