SA-MP Forums Archive
Binary D: - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Binary D: (/showthread.php?tid=360915)



Binary D: - MP2 - 19.07.2012

I hate binary.

https://sampwiki.blast.hk/wiki/DoorStates

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


The bits I'm interested in are opened and removed. If need to check if either are true.


Re: Binary D: - Vince - 19.07.2012

First byte (8 bits): hood
Opened: doors & 1
Removed: doors & 4


Re: Binary D: - MP2 - 19.07.2012

Wouldn't removed be 3 not 4?


Re: Binary D: - Vince - 19.07.2012

Quote:
Originally Posted by MP2
Посмотреть сообщение
Wouldn't removed be 3 not 4?
No. Any subsequent bit is the previous bit times 2. 1, 2, 4, 8, 16, 32, ...


Re: Binary D: - Kar - 19.07.2012

pawn Код:
//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?


Re: Binary D: - The__ - 19.07.2012

Aren't those functions kind of old ?
Why dont you use GetVehicleParamsEx & SetVehicleParamsEx ?


Re: Binary D: - Kar - 19.07.2012

Quote:
Originally Posted by The__
Посмотреть сообщение
Aren't those functions kind of old ?
Why dont you use GetVehicleParamsEx & 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