vXHazE Posted April 16, 2014 Share Posted April 16, 2014 Hi can I somehow block the police cars so that only people in the police group can join them? Link to comment
Alexs Posted April 16, 2014 Share Posted April 16, 2014 Use 'cancelEvent' and 'onVehicleStartEnter'. Link to comment
Vinctus Posted April 17, 2014 Share Posted April 17, 2014 Use 'cancelEvent' and 'onVehicleStartEnter'. here's an example: addEventHandler("onVehicleStartEnter", root, function(enteringPlayer, seat) if enteringPlayer and seat == 0 then -- if he tries to enter driver seat if not getElementData(enteringPlayer, "police") then cancelEvent() end end end) or whatever you use to check if he is police Link to comment
-.Paradox.- Posted April 17, 2014 Share Posted April 17, 2014 policeveh = { [598]=true, [596]=true, [597]=true, [599]=true } addEventHandler("onVehicleEnter", root, function () if (policeveh[getElementModel(source)]) then removePedFromVehicle(thePlayer) cancelEvent() end end) Link to comment
Vinctus Posted April 17, 2014 Share Posted April 17, 2014 cancelling the onVehicleStartEnter is more efficient as it blocks it as soon as you press the key to enter the vehicle Link to comment
Mr_Moose Posted April 17, 2014 Share Posted April 17, 2014 onVehicleEnter is triggered after the player has entered the vehicle and the animation is finished, if you goanna use removePedFromVehicle then it should be used with onVehicleEnter, otherwise it won't have any effect. The same applies for onVehicleStartEnter which will trigger at the same moment a player presses the enter key and there is a vehicle nearby, by cancelling onVehicleStartEnter the animation won't even start so this is the best solution when it comes to blocking people from entering police cars. Also remember that removePedFromVehice won't have any effect if it's triggered from onVehicleStartEnter since the ped isn't even in the vehicle at that moment. The example made by Nikolai96 is only useful if both onVehicleStartEnter and onVehicleEnter trigger the same function, in that case the resulting function will block players that for example is warped into a police car by a staff of the server or similar. Could be useful too but don't forget to verify that the player you tries to remove is inside the vehicle by calling: getPedOccupiedVehicle(player thePlayer) If that value is nil or false then you shouldn't call removePedFromVehicle since it would cause errors. 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