[BUG] vehicle.SetHandlingData()

Started by NicusorN5, Feb 24, 2017, 05:23 PM

Previous topic - Next topic

NicusorN5

Description
Function vehicle.SetHandlingData() is not working with custom vehicles .

Reproducible
Always

What you were doing when the bug happened
Using the X button to boost the car . Code :
function onKeyDown( player, key )
{
local vehicle = player.Vehicle;
if (key == x)
{
if (vehicle != null) {
local Nos = ReadIniInteger("NOS.ini","NOS",vehicle.ID.tostring());
        if (Nos == null) Nos = 0;
if (Nos > 0)
{
vehicle.SetHandlingData(14, vehicle.GetHandlingData(14) + 100.0);
vehicle.SetHandlingData(13,vehicle.GetHandlingData(13)+100);
vehicle.Lights = true
Nos--;
WriteIniInteger("NOS.ini","NOS",player.Vehicle.ID.tostring(),Nos);
}
else MessagePlayer("[#ff0000]You don't have any more NO2!",player);

}
}

What you think caused the bug
XML settings ?

MatheuS

Should be your code that is in trouble, here usually works this function in mod vehicles.
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

NicusorN5

100 % no idea what the hell I'm doing

KAKAN

ReadIniInteger("NOS.ini","NOS",vehicle.ID.tostring());
Um, sry, what?
oh no

MatheuS

Quote from: KAKAN on Feb 25, 2017, 01:32 PMReadIniInteger("NOS.ini","NOS",vehicle.ID.tostring());
Um, sry, what?

He's using .tostring() to save numbers. loooool

To save numbers you must use .tointeger() or .tofloat(). (Only use .tofloat for non-integer numbers. eg.: 0.5).

Replace these lines:
local Nos = ReadIniInteger("NOS.ini","NOS",vehicle.ID.tostring());// old linelocal Nos = ReadIniInteger("NOS.ini","NOS",vehicle.ID.tointeger());// new line
WriteIniInteger("NOS.ini","NOS",player.Vehicle.ID.tostring(),Nos); //old lineWriteIniInteger("NOS.ini","NOS",player.Vehicle.ID.tointeger(),Nos); // new line
Sorry for my English
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

KAKAN

And I don't think its a good idea to do that every freak'ng second. Depending on the file size, it may get terribly slow.... Instead, if you still love INI, take an array, store the data in it, and update/save it to the INI while the server closes. Load the data from the INI to the array when the server starts :) That'd be more efficient :D
oh no

NicusorN5

Read it's freacking Read INI INT

it's return type it's int and its :  ReadIniInteger(string,string,string)

KAKAN

oh no

PunkNoodle

Are you using an old server version? This bug was fixed in some of the server updates, make sure you got the latest server.exe.

NicusorN5

Lol , I'm using the lastest version , but still not working :( ...

Murdock

Haven't tested, but as far I know this bug is still listed in the list of bugs & suggestions

PunkNoodle

@Murdock
Quote from: Stormeus on Jul 20, 2016, 05:19 AMAn update for VC:MP 0.4 (04rel004) servers has been released.
  • Added support for setting vehicle handling rules for custom vehicles. This functionality is complemented by a client update to implement this for clients.

rww

Quote from: ...happymint_ on Feb 27, 2017, 03:13 AM@Murdock
Quote from: Stormeus on Jul 20, 2016, 05:19 AMAn update for VC:MP 0.4 (04rel004) servers has been released.
  • Added support for setting vehicle handling rules for custom vehicles. This functionality is complemented by a client update to implement this for clients.

But it doesn't work. I tested this on LCS-DM month ago.
Join to Irrelevant Club Discord: https://discord.gg/MsPPZ5uV4X

Murdock

Quote from: rww on Feb 27, 2017, 07:42 PMBut it doesn't work. I tested this on LCS-DM month ago.

Didn't see it work on DDRP either, that's probably why it's still on the bugs list

NicusorN5

I used vehicle.RelativeSpeed *= 1.1 . Spamming X will make the car fly lol.

Any other solution?