Jump to content

Anti vehicle zone


TorNix~|nR

Recommended Posts

hi everyone, I have script of anti veh zone it works, but when the vehicle destroyed, it never respawn, anyone help?

local positions = {
 {xxx, xxx, xxx, xxx},
}

local aRadarAreaPlaces = {
{ xxx, xxx, xxx, xxx, xxx, xxx, xxx, xxx },
}

function pos()
 for k, v in ipairs(positions) do
  local mycol = createColRectangle (v[1], v[2], v[3], v[4])
 for _, a in ipairs( aRadarAreaPlaces ) do 
  local pRadarArea = createRadarArea ( unpack( a ) )
  addEventHandler ("onColShapeHit", mycol, destroyTheVehicles)
   addEventHandler ("onColShapeHit", pRadarArea, destroyTheVehicles) 
 end
end
end
addEventHandler("onResourceStart", resourceRoot, pos)


function destroyTheVehicles (hitElement, dimension)
  if (getElementType(hitElement) ~= "vehicle" or not dimension) then
  return
 end

 local player = getVehicleController(hitElement)
 if (isElement(player)) then
 end

 destroyElement(hitElement)  
 setTimer(respawnVehicle,5000,0)(hitElement) 
end

 

Link to comment

At line 31 and 32 you are deleting then respawning.

How can you respawn something that does not exist?

Instead of deleting the vehicle how about just:

  1. Eject player from the vehicle.
  2. Set the vehicle position to somewhere off the map like (9999,9999,0).
  3. Then set the timer to respawn it.
function destroyTheVehicles (hitElement, dimension)
  if (getElementType(hitElement) ~= "vehicle" or not dimension) then
  return
 end

 local player = getVehicleController(hitElement)
 if (isElement(player)) then
    removePedFromVehicle ( player )
 end

 setElementPosition(hitElement,696969,696969,0)
 setTimer(respawnVehicle,5000,0)(hitElement) 
end

 

Link to comment

I make it without setposition, just with removeped, but I need when removeped and when you are in the base (position), when you enter the car, you will remove automatically

local positions = {
 {1560, -1137.41, 165, 165}, -- 
 {2372.29, 1823.58, 158, 158}, -- 
 {-2145.80, 118.67, 200, 200}, -- 
}

local aRadarAreaPlaces = {
{ 1560, -1137.41, 165, 165, 0, 255, 0, 0 }, -- 
{ 2372.29, 1823.58, 155, 158, 0, 255, 0, 0 }, -- 
{ -2145.80, 118.67, 200, 200, 0, 255, 0, 0 }, --  
}

function pos()
 for k, v in ipairs(positions) do
  local mycol = createColRectangle (v[1], v[2], v[3], v[4])
 for _, a in ipairs( aRadarAreaPlaces ) do 
  local pRadarArea = createRadarArea ( unpack( a ) )
  addEventHandler ("onColShapeHit", mycol, destroyTheVehicles)
   addEventHandler ("onColShapeHit", pRadarArea, destroyTheVehicles) 
 end
end
end
addEventHandler("onResourceStart", resourceRoot, pos)


function destroyTheVehicles (hitElement, dimension)
  if (getElementType(hitElement) ~= "vehicle" or not dimension) then
  return
 end

 
 local player = getVehicleController(hitElement)
 if (isElement(player)) then
   outputChatBox ("#FFFF00[LS] #FF0000You can not drive vehicles in boss zone! #00FF00Only you can spawn them!" ,player, 255, 0, 0, true)
    removePedFromVehicle ( player )
 end


setTimer(respawnVehicle, 1000, 1, hitElement)
end

 

Edited by TorNix~|nR
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...