Andres99907 Posted January 7, 2018 Share Posted January 7, 2018 I have a problem with the swat, I put a resource that makes it fire, but it explodes if there is someone else inside, I tried to make the doors lock in the swat and that they can not warp when a player is inside but it did not work. help Link to comment
Andres99907 Posted January 7, 2018 Author Share Posted January 7, 2018 this is the script to lock the doors function lockdoors ( theVehicle, seat ) if ( getElementModel ( theVehicle ) == 601 ) then if isVehicleLocked ( playervehicle ) then setVehicleLocked ( v, true ) else setVehicleLocked ( v, false ) end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), lockdoors ) Link to comment
KaMi Posted January 7, 2018 Share Posted January 7, 2018 (edited) function lockcar ( thePlayer ) playervehicle = getPedOccupiedVehicle ( thePlayer ) -- define 'playervehicle' as the vehicle the player is in local id = getElementModel ( playervehicle ) if id == 601 then -- if a player is in a vehicle if isVehicleLocked ( playervehicle ) then -- and if the vehicle is already locked setVehicleLocked ( playervehicle, false ) --unlock it else -- otherwise (if it isn't locked) setVehicleLocked ( playervehicle, true ) -- lock it playSoundFrontEnd ( thePlayer, 46 ) --optional argument end end end function bindLockOnSpawn ( theSpawnpoint ) -- when a player spawns bindKey ( source, "l", "down", lockcar ) -- bind the 'l' key to the 'lockcar' function end addEventHandler ( "onPlayerSpawn", getRootElement(), bindLockOnSpawn ) when you respawn ( /kill ) the key going to be binded and what happend with the fire of tank? Edited January 7, 2018 by <~KaMiKaZe~> 1 Link to comment
ÆBKV Posted January 7, 2018 Share Posted January 7, 2018 (edited) addEventHandler("onPlayerVehicleEnter",root, function(vehicle) local id = getElementModel(vehicle) if id == 601 then setVehicleLocked(vehicle,true) end end ) addEventHandler("onPlayerVehicleExit",root, function(vehicle) local id = getElementModel(vehicle) if id == 601 then setVehicleLocked(vehicle,false) end end ) Edited January 7, 2018 by ÆBKV 1 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