TorNix~|nR Posted March 4, 2018 Share Posted March 4, 2018 Hello guys, I have this script working fine, when you join with a vehicle to zone, it will be automatically respawned and you will get out of it but when you are on zone, you can get into the vehicles, I want even when you are inside the zone and spawn a vehicle, you will can not use it help please Code local myCol = createColRectangle (667.73, 1850.39, 50, 50) function destroyTheVehicles (player) if getElementType (player) == "player" and isPedInVehicle (player) then local vehicle = getPedOccupiedVehicle(player) removePedFromVehicle(player) respawnVehicle(vehicle) outputChatBox ("Vehicles are not allowed here!", player, 255, 0, 0) end end addEventHandler ("onColShapeHit", myCol, destroyTheVehicles) Link to comment
NeXuS™ Posted March 4, 2018 Share Posted March 4, 2018 Use the onVehicleStartEnter event. 1 Link to comment
TorNix~|nR Posted March 5, 2018 Author Share Posted March 5, 2018 I know, but I don't know how to use it onVehicleStartEnter help please? Link to comment
NeXuS™ Posted March 5, 2018 Share Posted March 5, 2018 function cancelEnter(thePlayer) if isElementWithinColShape(thePlayer, myCol) then destroyElement(source) outputChatBox("Vehicles are not allowed here!", thePlayer, 255, 0, 0) end end addEventHandler("onVehicleStartEnter", root, cancelEnter) Should work just fine. 1 Link to comment
TorNix~|nR Posted March 5, 2018 Author Share Posted March 5, 2018 (edited) On 3/4/2018 at 18:53, TorNix~|nR said: Hello guys, I have this script working fine, when you join with a vehicle to zone, it will be automatically respawned and you will get out of it but when you are on zone, you can get into the vehicles, I want even when you are inside the zone and spawn a vehicle, you will can not use it help please Code local myCol = createColRectangle (667.73, 1850.39, 50, 50) function destroyTheVehicles (player) if getElementType (player) == "player" and isPedInVehicle (player) then local vehicle = getPedOccupiedVehicle(player) removePedFromVehicle(player) respawnVehicle(vehicle) outputChatBox ("Vehicles are not allowed here!", player, 255, 0, 0) end end addEventHandler ("onColShapeHit", myCol, destroyTheVehicles) Working fine Thank you, but how can I make more cols, not just 1, I know I should use the table but I don't know how? help please? Edited March 5, 2018 by TorNix~|nR Link to comment
NeXuS™ Posted March 6, 2018 Share Posted March 6, 2018 Create more cols, add more event handlers with the new cols as the attached element, and in the onVehicleStartEnter event, write isElementWithinColShape(...) or isElementWithinColShape(...) 1 Link to comment
TorNix~|nR Posted March 6, 2018 Author Share Posted March 6, 2018 I know I can use more event handlers, but I want to make it more easy, and not a big code like this for example local cols = { {667.73, 1850.39, 50, 50}, -- First location {1667.73, 1050.39, 100, 100}, -- Second location } but I don't know how to do it inside the code, help please? Link to comment
NeXuS™ Posted March 6, 2018 Share Posted March 6, 2018 (edited) local colPositions = { {667.73, 1850.39, 50, 50}, {1667.73, 1050.39, 100, 100}, } local createdCols = {} for i, k in pairs(colPositions) do local tCol = createColRectangle(k[1], k[2], k[3], k[4]) -- Creating the col at the position with the fix width and height. addEventHandler("onColShapeHit", tCol, destroyTheVehicles) -- Adding the "onColShapeHit" event to the created col. table.insert(createdCols, tCol) -- Adding the created col to the "createdCols" table. end function cancelEnter(thePlayer) for i, k in pairs(createdCols) do -- Looping through the created cols. if isElementWithinColShape(thePlayer, k) then -- Checking if the player is inside one. destroyElement(source) -- If he is. outputChatBox("Vehicles are not allowed here!", thePlayer, 255, 0, 0) break end end end addEventHandler("onVehicleStartEnter", root, cancelEnter) function destroyTheVehicles(player) if getElementType(player) == "player" and isPedInVehicle(player) then local vehicle = getPedOccupiedVehicle(player) removePedFromVehicle(player) respawnVehicle(vehicle) outputChatBox("Vehicles are not allowed here!", player, 255, 0, 0) end end Just so you understand, this is the last full code I provide you. From now-on, I'll only tell you what functions you'll need, and if you can't find the right way, I'll ONLY push you. Edited March 6, 2018 by NeXuS™ 1 Link to comment
TorNix~|nR Posted March 6, 2018 Author Share Posted March 6, 2018 Thank you so much, I already told you I don't know how to make a table, from now on, I can ty 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