Jump to content

vehicle limit


Lachuks

Recommended Posts

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. :S :$

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 by Emix
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...