Help with UpdateVehicleDamageStatus -
Sc0tt - 22.01.2016
Hi guys,
I need your help with the function
UpdateVehicleDamageStatus, i want to do a real reparation system with repairing only hood, or trunk, or doors, etc ...
To do that, i'm using it :
https://sampwiki.blast.hk/wiki/DamageStatus
But it's not working. Indeed, when i call my command "/fix" with the parameter "hood" for example :
PHP код:
if(!strcmp(what, "hood", true))
{
new bonnet, boot, driver_door, passenger_door;
decode_doors(doors, bonnet, boot, driver_door, passenger_door);
doors = encode_doors(0, boot, driver_door, passenger_door);
}
The hood doesn't fix, except if it's the only part which is broken.
What can i do to solve this problem ?
Thank you in advance for your assistance.
Re: Help with UpdateVehicleDamageStatus -
Crayder - 22.01.2016
You forgot the bonnet parameter in the encode_doors function...
Re: Help with UpdateVehicleDamageStatus -
Sc0tt - 22.01.2016
Quote:
Originally Posted by Crayder
You forgot the bonnet parameter in the encode_doors function...
|
Please men ...
PHP код:
encode_doors(bonnet, boot, driver_door, passenger_door) // 4 parameters
{
return bonnet | (boot << 8) | (driver_door << 16) | (passenger_door << 24);
}
PHP код:
if(!strcmp(what, "hood", true))
{
new bonnet, boot, driver_door, passenger_door;
decode_doors(doors, bonnet, boot, driver_door, passenger_door);
doors = encode_doors(0, boot, driver_door, passenger_door); // 4 parameters too, bonnet = 0
}
Other ideas please ?
Re: Help with UpdateVehicleDamageStatus -
Sc0tt - 23.01.2016
Bump ..
Re: Help with UpdateVehicleDamageStatus -
Crayder - 23.01.2016
Dude, in your code you are setting doors to 0
YOu didn't put anything in the bonnet parameter.
encode_doors(0,
bonnet, boot, driver_door, passenger_door);
Re: Help with UpdateVehicleDamageStatus -
Sc0tt - 23.01.2016
Woooooow men, stop drunking please xD
Open your eyes :
PHP код:
encode_doors(bonnet, boot, driver_door, passenger_door) // 4 parameters
{
return bonnet | (boot << 8) | (driver_door << 16) | (passenger_door << 24);
}
The function return "doors", "doors" isn't a parameter. It's only a parameter in the "decode" function.
Re: Help with UpdateVehicleDamageStatus -
Crayder - 24.01.2016
K chuck, then 0b0000000 doesn't mean the bonnet is broken...
Decode the doors of a perfect vehicle, and see what the bits of the fixed bonnet are. Whatever they are is what you use in place of your current 0.
Re: Help with UpdateVehicleDamageStatus -
Sc0tt - 24.01.2016
https://sampwiki.blast.hk/wiki/DoorStates
0 means that the bonnet isn't broken.
I still made a little function to see and it displayed 0.
Re: Help with UpdateVehicleDamageStatus -
Crayder - 24.01.2016
pawn Код:
if(!strcmp(what, "hood", true))
{
doors &= 0xFFFFFF00;
}
If bonnet is truly the low bits, then this is all you need.
pawn Код:
if(!strcmp(what, "trunk", true))
{
doors &= 0xFFFF00FF;
}
pawn Код:
if(!strcmp(what, "driversdoor", true))
{
doors &= 0xFF00FFFF;
}
pawn Код:
if(!strcmp(what, "passengerdoor", true))
{
doors &= 0x00FFFFFF;
}
Also, can you show us the command? We could make a much simpler form without all these if's. Just a simple ternary operator in the UpdateVehicleDamageStatus function with 4 possibilities.
Re: Help with UpdateVehicleDamageStatus -
Sc0tt - 24.01.2016
Hum, i tried your method but it's the same, if other part of the car is broken, it doesn't fix :/
Can you try in local ? You'll see what i say.
Here is my code :
http://pastebin.com/KdX7x55L