Jump to content

getElementDistanceFromCentreOfMassToBaseOfModel problem


Recommended Posts

I have understood that getElementDistanceFromCentreOfMassToBaseOfModel(element) is supposed to return it's center's distance from the bottom of it, but when I try to use it on vehicles, it only returns 0. When I use it on local player, it returns 1.

Here's the part of the code that I use. Vehicle is the, well, vehicle.

distance = getElementDistanceFromCentreOfMassToBaseOfModel(vehicle) 
    str = getVehicleName(vehicle).." : "..distance.."\n" 
    outputChatBox(tostring(fileWrite( fp, str))) 

The outputChatBox is only for debugging purposes. I want to get the center of mass's distance from the bottom of the car using a command.

Any help? Oh and before you ask, the script is client-side.

Link to post
  • 2 weeks later...
Is there something like C++'s std::setprecision() in lua?

afaik any lua number is signed, has double precision and long size.

I doubt all vehicles have 0 as their distance from center of mass to base of model, it should print the decimals then.

distance = getElementDistanceFromCentreOfMassToBaseOfModel(vehicle) 
str = getVehicleName(vehicle).." : "..distance.."\n" 

That'll output the right value.

Nope. It outputs "[vehicle name] : 0".

Link to post

i can say for a fact lack of float is not the case.

EDIT: just tested it

Executing client-side command: getElementDistanceFromCentreOfMassToBaseOfModel(getPedOccupiedVehicle(localPlayer))

Command results: 0.81000000238419 [number]

it does work.

EDIT2: i got the problem... the vehicle needs to be streamed in.

Link to post

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