Adde Posted March 2, 2013 Posted March 2, 2013 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 )
Anderl Posted March 2, 2013 Posted March 2, 2013 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.
iPrestege Posted March 2, 2013 Posted March 2, 2013 u can do it like this for example!# addEventHandler( "onResourceStart", resourceRoot, function () for k, v in ipairs ( table ) do -- Do SomeThing end end )
Adde Posted March 2, 2013 Author Posted March 2, 2013 Okay, but how do I make a table that works for this?
iPrestege Posted March 2, 2013 Posted March 2, 2013 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 } }
Adde Posted March 2, 2013 Author Posted March 2, 2013 aah, I made the first line wrong on the table 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 )
Castillo Posted March 2, 2013 Posted March 2, 2013 No, you must create the radar areas with the positions given.
iPrestege Posted March 2, 2013 Posted March 2, 2013 @ 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 )
Adde Posted March 2, 2013 Author Posted March 2, 2013 (edited) Yes I added that ofc. But I mean if it´s added right and the function is right. Btw, just 1 zone came up when I tested. But I didn´t do like that Edited March 2, 2013 by Guest
Adde Posted March 2, 2013 Author Posted March 2, 2013 (edited) 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 March 2, 2013 by Guest
iPrestege Posted March 2, 2013 Posted March 2, 2013 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 )
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