joaoMartins1234545 Posted December 17, 2022 Share Posted December 17, 2022 The script should work like this: if the player enters a vehicle or just happens to be in (for vehicle spawns etc) - vehicle becomes indestructable when the player leaves the vehicle - vehicle becomes destructable. Can anyone help with that? Link to comment
Vampire Posted December 17, 2022 Share Posted December 17, 2022 Hello @joaoMartins1234545 and welcome! I've moved your topic to the Scripting section so you can get better assistance. Link to comment
DiSaMe Posted December 17, 2022 Share Posted December 17, 2022 You can do that in two ways. The first way is the way you worded it - damage gets disabled or enabled when a player enters or exits the vehicle. To do that, you need these events: onPlayerVehicleEnter or onVehicleEnter - to detect when a player enters the vehicle onPlayerVehicleExit or onVehicleExit - to detect when a player exits the vehicle And this function to toggle the damage: setVehicleDamageProof Also, it depends on whether it has to work just for the driver seat or all seats. If you want it for the driver seat only, then you need to check if the seat parameter is 0 in vehicle enter/exit events. If you want it for all seats, then in vehicle exit event you need to retrieve the list of players in the vehicle using getVehicleOccupants and check if it is empty - so the damage will only be enabled if there are no other players remaining in the vehicle. The second way is to check every time the vehicle is damaged, and cancel the damage if it's occupied. This has to be done client-side because only client-side damage events can be cancelled. You need this event to detect when the vehicle gets damaged: onClientVehicleDamage And call this function from within that event to cancel the damage: cancelEvent If you need it for the driver seat only, use getVehicleOccupant to check if there's a player in the seat 0. For all seats, retrieve the list of players in the vehicle using getVehicleOccupants and check if it is non-empty. Link to comment
joaoMartins1234545 Posted December 21, 2022 Author Share Posted December 21, 2022 On 17/12/2022 at 00:56, Vampire said: Hello @joaoMartins1234545 and welcome! I've moved your topic to the Scripting section so you can get better assistance. thanks On 17/12/2022 at 04:19, Reyomin said: ur awesome thanks 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