Help with UpdateVehicleDamageStatus
#1

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 
bonnetbootdriver_doorpassenger_door;
        
decode_doors(doorsbonnetbootdriver_doorpassenger_door);
        
doors encode_doors(0bootdriver_doorpassenger_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.
Reply
#2

You forgot the bonnet parameter in the encode_doors function...
Reply
#3

Quote:
Originally Posted by Crayder
Посмотреть сообщение
You forgot the bonnet parameter in the encode_doors function...
Please men ...

PHP код:
encode_doors(bonnetbootdriver_doorpassenger_door// 4 parameters
{
    return 
bonnet | (boot << 8) | (driver_door << 16) | (passenger_door << 24);

PHP код:
if(!strcmp(what"hood"true))
{
        new 
bonnetbootdriver_doorpassenger_door;
        
decode_doors(doorsbonnetbootdriver_doorpassenger_door);
        
doors encode_doors(0bootdriver_doorpassenger_door); // 4 parameters too, bonnet = 0

Other ideas please ?
Reply
#4

Bump ..
Reply
#5

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);
Reply
#6

Woooooow men, stop drunking please xD

Open your eyes :

PHP код:
encode_doors(bonnetbootdriver_doorpassenger_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.
Reply
#7

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.
Reply
#8

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.
Reply
#9

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.
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)