Jump to content

getElementDistanceFromCentreOfMassToBaseOfModel problem


3ventic

Recommended Posts

Posted

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.

  • 2 weeks later...
Posted

You're wrong karlis, file functions are client side too now.

https://wiki.multitheftauto.com/wiki/FileWrite

fileWrite Client and Server function

Writes one or more strings to a the given file, starting at the current read/write position. Advances the position over the number of bytes that were written.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Yes, that should be fixed, it happened to me too ;).

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Everything else works fine, except that it doesn't print out decimals. Is there something like C++'s std::setprecision() in lua?

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

That'll output the right value.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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" 
outputChatBox(tostring">tostring(str)) 

That'll output the right value.

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

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