Jump to content

Make 7 safezones script to one script?


Adde

Recommended Posts

Hello, I have 7 different ZombieArea scripts that I want to make to one script. I tried to do something like this below, but I couldn´t find out how to change setElementData(safeZoneRadar,"zombieProof", true) so it will work :/ anyone who can help?

safecol1 = createColCuboid ( -1704.0307, 644.0531, 24.8906, 280, 280, 280 ) 
safecol2 = createColCuboid ( -1581.42, 419.68, 7.18, 280, 280, 280 ) 
safecol3 = createColCuboid ( -3696.91, -514.90, 12, 280, 280, 280 ) 
safecol4 = createColCuboid ( 21.67, -2027.21, 2.1, 280, 280, 280 ) 
safecol5 = createColCuboid ( 827.55, -2828.13, 10, 280, 280, 280 ) 
safecol6 = createColCuboid ( -2430.30, -641.10, 145, 280, 280, 280 ) 
safecol7 = createColCuboid ( -72.80, 1643.66, 26, 280, 280, 280 ) 
safeZoneRadar1 = createRadarArea ( -1704.0307, 644.0531, 150, 87, 400, 390, 390 ) 
safeZoneRadar2 = createRadarArea ( -1581.42, 419.68, 370, 100, 400, 390, 390 ) 
safeZoneRadar3 = createRadarArea ( -3696.91, -514.90, 530, 770, 400, 390, 390 ) 
safeZoneRadar4 = createRadarArea ( 21.67, -2027.21, 3000, 1350, 61, 255, 61 ) 
safeZoneRadar5 = createRadarArea ( 827.55, -2828.13, 2194, 900, 61, 255, 61 ) 
safeZoneRadar6 = createRadarArea ( -2430.30, -641.10, 85, 85, 400, 390, 390 ) 
safeZoneRadar7 = createRadarArea ( -72.80, 1641.66, 455, 461, 400, 390, 390 ) 
setElementData(safeZoneRadar,"zombieProof", true) 
  
function enterZone(hitPlayer,thePlayer) 
    toggleControl (hitPlayer, "fire", false ) 
    toggleControl (hitPlayer, "aim_weapon", true) 
    toggleControl (hitPlayer, "vehicle_fire", false) 
    outputChatBox("you entered safezone", hitPlayer, 0, 255, 0) 
end 
addEventHandler( "onColShapeHit", safecol, enterZone ) 
  
function leaveZone(hitPlayer,thePlayer) 
    toggleControl (hitPlayer, "fire", true) 
    toggleControl (hitPlayer, "aim_weapon", true) 
    toggleControl (hitPlayer, "vehicle_fire", true) 
    outputChatBox("youԲe leaving safezone", hitPlayer, 255, 0, 0) 
end 
addEventHandler( "onColShapeLeave", safecol, leaveZone ) 

or something like

local safecol = createColCuboid 
{ 
{ -1704.0307, 644.0531, 24.8906, 280, 280, 280 }, 
{ -1581.42, 419.68, 7.18, 280, 280, 280 }, 
{ -3696.91, -514.90, 12, 280, 280, 280 } 
{ 21.67, -2027.21, 2.1, 280, 280, 280 }, 
{ 827.55, -2828.13, 10, 280, 280, 280 }, 
{ -2430.30, -641.10, 145, 280, 280, 280 }, 
{ -72.80, 1643.66, 26, 280, 280, 280 } 
} 
local safeZoneRadar = createRadarArea 
{ 
{-1704.0307, 644.0531, 150, 87, 400, 390, 390 }, 
{-1581.42, 419.68, 370, 100, 400, 390, 390 }, 
{-3696.91, -514.90, 530, 770, 400, 390, 390 }, 
{21.67, -2027.21, 3000, 1350, 61, 255, 61 }, 
{827.55, -2828.13, 2194, 900, 61, 255, 61 }, 
{-2430.30, -641.10, 85, 85, 400, 390, 390 }, 
{-72.80, 1641.66, 455, 461, 400, 390, 390 }, 
} 
setElementData(safeZoneRadar,"zombieProof", true) 
  
function enterZone(hitPlayer,thePlayer) 
    toggleControl (hitPlayer, "fire", false ) 
    toggleControl (hitPlayer, "aim_weapon", true) 
    toggleControl (hitPlayer, "vehicle_fire", false) 
    outputChatBox("you entered safezone", hitPlayer, 0, 255, 0) 
end 
addEventHandler( "onColShapeHit", safecol, enterZone ) 
  
function leaveZone(hitPlayer,thePlayer) 
    toggleControl (hitPlayer, "fire", true) 
    toggleControl (hitPlayer, "aim_weapon", true) 
    toggleControl (hitPlayer, "vehicle_fire", true) 
    outputChatBox("youԲe leaving safezone", hitPlayer, 255, 0, 0) 
end 
addEventHandler( "onColShapeLeave", safecol, leaveZone ) 

Link to comment

None of the codes make sense.

Either construct an array (table), add all collision cuboid's elements there, set the "onColShapeEnter" and "onColShapeLeave" element to root and inside their functions check if source is inside the array (for example: if ( array[ source ] ) then) or construct an array and add an array for each collision cuboid with its positions. Then you loop through that array using the for statement and create each collision cuboid and add an event handler to its respective collision cuboid.

Link to comment

This is a table :

  
local safecol  = { 
{ -1704.0307, 644.0531, 24.8906, 280, 280, 280 }, 
{ -1581.42, 419.68, 7.18, 280, 280, 280 }, 
{ -3696.91, -514.90, 12, 280, 280, 280 } 
{ 21.67, -2027.21, 2.1, 280, 280, 280 }, 
{ 827.55, -2828.13, 10, 280, 280, 280 }, 
{ -2430.30, -641.10, 145, 280, 280, 280 }, 
{ -72.80, 1643.66, 26, 280, 280, 280 } 
} 
  
Link to comment

aah, I made the first line wrong on the table :P

So it will look something like this?:

local safeZoneRadar = { 
{-1704.0307, 644.0531, 150, 87, 400, 390, 390 }, 
{-1581.42, 419.68, 370, 100, 400, 390, 390 }, 
{-3696.91, -514.90, 530, 770, 400, 390, 390 }, 
{21.67, -2027.21, 3000, 1350, 61, 255, 61 }, 
{827.55, -2828.13, 2194, 900, 61, 255, 61 }, 
{-2430.30, -641.10, 85, 85, 400, 390, 390 }, 
{-72.80, 1641.66, 455, 461, 400, 390, 390 } 
} 
  
addEventHandler( "onResourceStart", resourceRoot,   
function () 
   for k, v in ipairs ( table ) do 
setElementData(safeZoneRadar"zombieProof", true) 
    end 
end   
) 

Link to comment

@ SolidSnake

as what i know as far should to be like that?

addEventHandler( "onResourceStart", resourceRoot,   
function () 
   for _,v in ipairs ( safeZoneRadar ) do 
local area = createRadarArea ( v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8]) 
setElementData(area,"zombieProof", true) 
    end 
end   
) 
Link to comment

there are zombies spawning everywear. So anti zombie don´t work.

createRadarArea ( -1704.0307, 644.0531, 150, 87, 400, 390, 390 ) 
createRadarArea ( -1581.42, 419.68, 370, 100, 400, 390, 390 ) 
createRadarArea ( -3696.91, -514.90, 530, 770, 400, 390, 390 ) 
createRadarArea ( 21.67, -2027.21, 3000, 1350, 61, 255, 61 ) 
createRadarArea ( 827.55, -2828.13, 2194, 900, 61, 255, 61 ) 
createRadarArea ( -2430.30, -641.10, 85, 85, 400, 390, 390 ) 
createRadarArea ( -72.80, 1641.66, 455, 461, 400, 390, 390 ) 
  
local safeZoneRadar = { 
{-1704.0307, 644.0531, 150, 87, 400, 390, 390 }, 
{-1581.42, 419.68, 370, 100, 400, 390, 390 }, 
{-3696.91, -514.90, 530, 770, 400, 390, 390 }, 
{21.67, -2027.21, 3000, 1350, 61, 255, 61 }, 
{827.55, -2828.13, 2194, 900, 61, 255, 61 }, 
{-2430.30, -641.10, 85, 85, 400, 390, 390 }, 
{-72.80, 1641.66, 455, 461, 400, 390, 390 } 
} 
  
addEventHandler( "onResourceStart", resourceRoot,   
function () 
   for k, v in ipairs ( table ) do 
setElementData(safeZoneRadar"zombieProof", true) 
    end 
end   
) 

Edited by Guest
Link to comment
there are zombies spawning everywear. So anti zombie don´t work
createRadarArea ( -1704.0307, 644.0531, 150, 87, 400, 390, 390 ) 
createRadarArea ( -1581.42, 419.68, 370, 100, 400, 390, 390 ) 
createRadarArea ( -3696.91, -514.90, 530, 770, 400, 390, 390 ) 
createRadarArea ( 21.67, -2027.21, 3000, 1350, 61, 255, 61 ) 
createRadarArea ( 827.55, -2828.13, 2194, 900, 61, 255, 61 ) 
createRadarArea ( -2430.30, -641.10, 85, 85, 400, 390, 390 ) 
createRadarArea ( -72.80, 1641.66, 455, 461, 400, 390, 390 ) 
  
local safeZoneRadar = { 
{-1704.0307, 644.0531, 150, 87, 400, 390, 390 }, 
{-1581.42, 419.68, 370, 100, 400, 390, 390 }, 
{-3696.91, -514.90, 530, 770, 400, 390, 390 }, 
{21.67, -2027.21, 3000, 1350, 61, 255, 61 }, 
{827.55, -2828.13, 2194, 900, 61, 255, 61 }, 
{-2430.30, -641.10, 85, 85, 400, 390, 390 }, 
{-72.80, 1641.66, 455, 461, 400, 390, 390 } 
} 
  
addEventHandler( "onResourceStart", resourceRoot,   
function () 
   for k, v in ipairs ( table ) do 
setElementData(safeZoneRadar"zombieProof", true) 
    end 
end   
) 

local safeZoneRadar = { 
{-1704.0307, 644.0531, 150, 87, 400, 390, 390 }, 
{-1581.42, 419.68, 370, 100, 400, 390, 390 }, 
{-3696.91, -514.90, 530, 770, 400, 390, 390 }, 
{21.67, -2027.21, 3000, 1350, 61, 255, 61 }, 
{827.55, -2828.13, 2194, 900, 61, 255, 61 }, 
{-2430.30, -641.10, 85, 85, 400, 390, 390 }, 
{-72.80, 1641.66, 455, 461, 400, 390, 390 } 
} 
  
addEventHandler( "onResourceStart", resourceRoot,   
function () 
   for k, v in ipairs ( safeZoneRadar ) do 
local area = createRadarArea ( v[1],v[2],v[3],v[4],v[5],v[6],v[7]) 
setElementData(area,"zombieProof", true) 
    end 
end   
) 

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...