josiewales Posted June 9, 2021 Share Posted June 9, 2021 I've got a mini game where there is a spawned vehicle (chase_car) chasing and ramming the players car (player_car). I want to trigger an event when chase_car collides with player_car. I have been using HasCollided which works fine but it triggers when chase_car collides with any car, how can I trigger the event to occur ONLY when chase_car collides with player car ? if ((Globals.chase_car.HasCollided) { float reduced_engine = Game.Player.Character.CurrentVehicle.EngineHealth; float reduced_body = Game.Player.Character.CurrentVehicle.BodyHealth; reduced_engine = reduced_engine - 200; reduced_body = reduced_body - 200; Function.Call(Hash.SET_VEHICLE_ENGINE_HEALTH, Game.Player.Character.CurrentVehicle, reduced_engine); Function.Call((Hash)13140802562911894327UL, Game.Player.Character.CurrentVehicle, reduced_body); //set engine body health } Link to comment Share on other sites More sharing options...
DuncanMac Posted June 9, 2021 Share Posted June 9, 2021 There is a native function to get the vehicle a player is in. Use that and add an if condition to only collide with that vehicle, no? GET_VEHICLE_PED_IS_IN(PLAYER_PED_ID() Link to comment Share on other sites More sharing options...
josiewales Posted June 10, 2021 Author Share Posted June 10, 2021 (edited) @DuncanMac (I was unable to enter content in the above post for some reason). I already know the vehicle the player is in, it will always be a Zentorno. What I'm unsure of is how to check when chase_car collides with Zentorno: If Globals.chase_car.HasCollided ...... Zentorno, what is the bridging piece of code HasCollided.GetType or something like that ? Edited June 10, 2021 by josiewales typo Link to comment Share on other sites More sharing options...
josiewales Posted June 10, 2021 Author Share Posted June 10, 2021 I managed to determine when two specific cars collide using isEntityTouchingEntity (code below). The only issue is that it seems to do a loop and reduces the health multiple times in a row. I've tried adding a do once loop but no joy with it....any suggestions ? //collision if ((Function.Call<bool>((Hash)0x17FFC1B2BA35A494, Game.Player.Character.CurrentVehicle, Globals.chase_car))==true) // isEntityTouchingEntity { Int x = 5; Do { x++; float reduced_engine = Game.Player.Character.CurrentVehicle.EngineHealth; float reduced_body = Game.Player.Character.CurrentVehicle.BodyHealth; reduced_engine = reduced_engine - 400; reduced_body = reduced_body - 400; Function.Call(Hash.SET_VEHICLE_ENGINE_HEALTH, Game.Player.Character.CurrentVehicle, reduced_engine); Function.Call((Hash)13140802562911894327UL, Game.Player.Character.CurrentVehicle, reduced_body); //set engine body health GTA.UI.Screen.ShowSubtitle("Once HIT", 2000); } while (x < 3) ; } Link to comment Share on other sites More sharing options...
DuncanMac Posted June 10, 2021 Share Posted June 10, 2021 Have never tried to do what you're doing. Just curious, why would you use cryptic hashes for your natives rather than the function name in english? Link to comment Share on other sites More sharing options...
josiewales Posted June 10, 2021 Author Share Posted June 10, 2021 I use the cryptic hashes because some regular variables throw errors in my code editor and aren't recognised so to overcome this I look up their native serial number and use those instead and then it works.....do you think it would slow down the code...make it less efficient ? Link to comment Share on other sites More sharing options...
DuncanMac Posted June 10, 2021 Share Posted June 10, 2021 (edited) Didn't realize you could get errors that were resolved by using the hash instead. I was just curious. As for performance it shouldn't make any difference whatsoever unless you had this huge script making tremendous demands on your system - in that hypothetical and unrealistic case I would guess the hash would be even more efficient since it doesn't have to be converted from English. Ofc your errors might just be syntax errors? Edited June 10, 2021 by DuncanMac Link to comment Share on other sites More sharing options...
josiewales Posted June 11, 2021 Author Share Posted June 11, 2021 Well - if its not broken don't fix it!!! Link to comment Share on other sites More sharing options...
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