Forrest Posted January 7, 2014 Share Posted January 7, 2014 I'm in the process of making a small and simple handling editor for myself, just as a small project out of boredom. Just basic functions that are really all you need for simple handling editing. But I've bumped into a problem, all the bottom check boxes are for handling flags. And I need to get the flags so that depending on which ones are active they'll be ticked/unticked. But the thing is... How the hell do I check for flags..? local handlingCurrent = getVehicleHandling(theVehicle) outputChatBox(tostring(handlingCurrent["handlingFlags"])) When using the above, all I get is: 67108865 - Depending on which flags are on/off, but the string is ALWAYS different lengths, combinations etc. So how the hell do I go about checking for a specific flag being on or off? Thanks. Link to comment
50p Posted January 7, 2014 Share Posted January 7, 2014 That number represents the flags. If you convert that number to hexadecimal number you will get 0x4000001. Each of the bytes of the number represent 4 flags, as explained here: http://projectcerbera.com/gta/sa/tutorials/handling All you need to do is check if the flag is set by using bitAnd function. I haven't tested this but you can do that and try if it works: local gHandlingFlags = { _1G_BOOST = 0x1, _2G_BOOST = 0x2, NPC_ANTI_ROLL = 0x4, NPC_NEUTRAL_HANDL = 0x8, NO_HANDBRAKE = 0x10, STEER_REARWHEELS = 0x20, HB_REARWHEEL_STEER = 0x40, ALT_STEER_OPT = 0x80, WHEEL_F_NARROW2 = 0x100, WHEEL_F_NARROW = 0x200, WHEEL_F_WIDE = 0x400, WHEEL_F_WIDE2 = 0x800, WHEEL_R_NARROW2 = 0x1000, WHEEL_R_NARROW = 0x2000, WHEEL_R_WIDE = 0x4000, WHEEL_R_WIDE2 = 0x8000, HYDRAULIC_GEOM = 0x10000, HYDRAULIC_INST = 0x20000, HYDRAULIC_NONE = 0x40000, NOS_INST = 0x80000, OFFROAD_ABILITY = 0x100000, OFFROAD_ABILITY2 = 0x200000, HALOGEN_LIGHTS = 0x400000, PROC_REARWHEEL_1ST = 0x800000, USE_MAXSP_LIMIT = 0x1000000, LOW_RIDER = 0x2000000, STREET_RACER = 0x4000000, --UNDEFINED = 0x8000000, SWINGING_CHASSIS = 0x10000000 }; function isFlagSet( val, flag ) return (bitAnd( val, flag ) == flag) end function getVehicleHandlingFlags( vehicle ) local retFlags = { }; local flags = getVehicleHandling( vehicle )["handlingFlags"]; for name, flag in pairs( gHandlingFlags ) do if isFlagSet( flags, flag ) then retFlags[ name ] = true; end end return retFlags; end You can use my function getVehicleHandlingFlags which will return a table of the flags, eg: local handlingFlags = getVehicleHandlingFlags( getPedOccupiedVehicle( localPlayer ) ); for name in pairs( handlingFlags ) do outputChatBox( "Flag set: " .. name ); end If you don't want to loop and check if specific flag is set, you can use my other function isFlagSet: local handlingFlags = getVehicleHandling( localPlayer )["handlingFlags"]; -- standard value, like your example: 67108865 if isFlagSet( handlingFlags, gHandlingFlags.STREET_RACER ) then -- use the table (gHandlingFlags) provided with predefined flag names outputChatBox( "You can mod your car at Wheel Arch Angels." ); end As I explained above: 67108865 == 0x4000001 Check the table gHandlingFlags and find: 0x4000000, it'll be -> STREET_RACER Check the table again and find: 0x1, it'll be -> _1G_BOOST I hope it works and you understood how it works. Link to comment
Forrest Posted January 7, 2014 Author Share Posted January 7, 2014 @50p was one small error where localPlayer had to be replaced with the variable for the vehicle but other than that, spot on! Greatly appreciated buddy! Link to comment
50p Posted January 7, 2014 Share Posted January 7, 2014 I'm glad it worked :> Good luck. Link to comment
Forrest Posted January 7, 2014 Author Share Posted January 7, 2014 Me too haha, I was confused as ever! Thanks buddy. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now