PDA

View Full Version : Binary D:


MP2
19/07/2012, 12:27 PM
I hate binary.

http://wiki.sa-mp.com/wiki/DoorStates

I need to know whether the bonnet/hood is open or not.

http://puu.sh/JRyt
The bits I'm interested in are opened and removed. If need to check if either are true.

Vince
19/07/2012, 12:43 PM
First byte (8 bits): hood
Opened: doors & 1
Removed: doors & 4

MP2
19/07/2012, 12:47 PM
Wouldn't removed be 3 not 4?

Vince
19/07/2012, 12:49 PM
Wouldn't removed be 3 not 4?

No. Any subsequent bit is the previous bit times 2. 1, 2, 4, 8, 16, 32, ...

Kar
19/07/2012, 12:53 PM
//new panels, doors, lights, tires
//GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
//bonnet = doors & 0x7; - i kinda forgot what this does


if(doors & 0b00000100) // hood is removed
if(doors & 0b00000010) // hood is damaged
if(doors & 0b00000011) // hood is damaged and opened
if(doors & 0b00000001) // hood is opened

Can't remember it totally, but this should be a start?

The__
19/07/2012, 12:57 PM
Aren't those functions kind of old ?
Why dont you use GetVehicleParamsEx (http://wiki.sa-mp.com/wiki/GetVehicleParamsEx)& SetVehicleParamsEx (http://wiki.sa-mp.com/wiki/SetVehicleParamsEx) ?

Kar
19/07/2012, 01:00 PM
Aren't those functions kind of old ?
Why dont you use GetVehicleParamsEx (http://wiki.sa-mp.com/wiki/GetVehicleParamsEx)& SetVehicleParamsEx (http://wiki.sa-mp.com/wiki/SetVehicleParamsEx) ?

Good Idea, can't believe I didn't think about that. Unless he needs the 'damaged option' but he didn't say he needed that :p