Lachuks Posted February 22, 2018 Share Posted February 22, 2018 (edited) Hello! Recentrly started working on protect system and added vehicle limit in colshape but something went wrong and it does not work as I wanted to. When arena reach limit all vehicles in whole map teleport in 1 point. I hope you understand what I mean. local colshapepos = {-2633.27832, -39.11388, 1.76461, 18.8447265625, 9.484432220459, 6.1000002861023} local kickpos = {-2602.0732421875, -44.96484375, 4.1796875} local maxvehs = 1 local grupnos = "sss" local co4 = createColCuboid(colshapepos[1], colshapepos[2], colshapepos[3], colshapepos[4], colshapepos[5], colshapepos[6]) setElementID (co4, grupnos) function checkVehicles(theElement) local counter = #getElementsWithinColShape(source, "vehicle") local vehicles = getElementsByType ( "vehicle" ) if counter < maxvehs then elseif counter > maxvehs then for vehicleKey, vehicleValue in ipairs(vehicles) do setElementPosition(theElement, kickpos[1], kickpos[2], kickpos[3]) setElementFrozen(theElement, true) setElementFrozen(theElement, false) end end end addEventHandler("onColShapeHit", getRootElement(), checkVehicles) Edited February 22, 2018 by Emix Link to comment
Tails Posted February 22, 2018 Share Posted February 22, 2018 I don't see anything that teleports all vehicles to one point, however, you are looping through all vehicles, which is weird considering you're only trying to move one vehicle. Get rid of the loop. Link to comment
Lachuks Posted February 22, 2018 Author Share Posted February 22, 2018 I removed that loop but stil same problem. Link to comment
Tails Posted February 22, 2018 Share Posted February 22, 2018 Do you have multiple colshapes? Instead of root use co4 as the root. addEventHandler("onColShapeHit", co4, checkVehicles) also, you may want to make sure it's a vehicle that's hitting the colshape: if (getElementType(theElement) == "vehicle") then 1 Link to comment
Lachuks Posted February 22, 2018 Author Share Posted February 22, 2018 Thank you! Works exelent now 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