3ventic Posted February 23, 2012 Posted February 23, 2012 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.
karlis Posted March 5, 2012 Posted March 5, 2012 fileWrite is totally unrelated and SERVERSIDE function, while the 1st one is clientside function. get rid of fileWrite. and use /debugscript 3 next time. [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
Castillo Posted March 5, 2012 Posted March 5, 2012 You're wrong karlis, file functions are client side too now. https://wiki.multitheftauto.com/wiki/FileWrite fileWrite Client and Server functionWrites 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. Education is the most powerful weapon which you can use to change the world.
karlis Posted March 5, 2012 Posted March 5, 2012 ah true, i didnt pay attention, just saw orange on the syntax checker... sorry [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
Castillo Posted March 5, 2012 Posted March 5, 2012 Yes, that should be fixed, it happened to me too . San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
3ventic Posted March 9, 2012 Author Posted March 9, 2012 Everything else works fine, except that it doesn't print out decimals. Is there something like C++'s std::setprecision() in lua?
Castillo Posted March 9, 2012 Posted March 9, 2012 distance = getElementDistanceFromCentreOfMassToBaseOfModel(vehicle) str = getVehicleName(vehicle).." : "..distance.."\n" outputChatBox(tostring(str)) That'll output the right value. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
karlis Posted March 9, 2012 Posted March 9, 2012 Is there something like C++'s std::setprecision() in lua? afaik any lua number is signed, has double precision and long size. [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
3ventic Posted March 10, 2012 Author Posted March 10, 2012 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".
karlis Posted March 10, 2012 Posted March 10, 2012 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. [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
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