Jump to content

Anti Zombie Area Bugged


Wisam

Recommended Posts

So im building my rpg/zombie freeroam server and there is an important script that i changed somthing in it and it got bugged.

So this script is supposto cancel the zombies to spawn in the area that is made and also kill any zombie enters the area.

So i was adding more areas and suddenly it stopped working idk why, i mean zombies dont spawn in the area but they can enter it and never die.. oh and there was somthing wierd.. when they followed me inside the area they didnt die and then i jumped over a small obstacle and then when they tried to jump to follow me they died.. and also when i get to a tiny box or stair above the ground level they die too, so here's the script:

  
[b]--This one prevents the zombies from spawning in the area[/b] 
-- Fort Carson Hospital 
safeColFCH = createColCuboid ( -348.83591, 1025.67822, 20.06553, 60, 60, 255 ) 
safeZoneRadarFCH = createRadarArea ( -348.83591, 1025.67822, 60, 60, 0, 94, 0, 80) 
setElementData (safeZoneRadarFCH, "zombieProof", true) 
  
--And this kill them when they enter the area above: 
function enterZone(hitPlayer,thePlayer) 
local skin = getElementModel (hitPlayer) 
if (skin == 13 or  skin == 22 or skin == 56 or skin == 67 or skin == 68 or skin == 69 or skin == 75 or skin == 77 or skin == 84 or skin == 92 or skin == 95 or skin == 97 or skin == 105 or skin == 107 or skin == 108 or skin == 126 or skin == 127 or skin == 128 or skin == 152 or skin == 162 or skin == 167 or skin == 188 or skin == 195 or skin == 206 or skin == 209 or skin == 212 or skin == 213 or skin == 229 or skin == 230 or skin == 258 or skin == 264 or skin == 274 or skin == 277) then 
             killPed (hitPlayer) 
  
       else 
    end 
end 
addEventHandler( "onColShapeHit", safeColFCH, enterZone ) 
  

Link to comment

I don't see any problem within your syntax, though I've organized it slightly better:

local safeColFCH = createColCuboid ( -348.83591, 1025.67822, 20.06553, 60, 60, 255 ) 
local safeZoneRadarFCH = createRadarArea ( -348.83591, 1025.67822, 60, 60, 0, 94, 0, 80) 
setElementData(safeColFCH, "zombieProof", true) 
  
function enterZone (hitPlayer, sameDimension) -- modified second value's name 
    if source == safeColFCH then 
        if not getElementData(source, "zombieProof") then return end -- return in case it's not supposed to kill zombies 
        local skin = getElementModel(hitPlayer) 
        if skin == 13 or skin == 22 or skin == 56 or skin == 67 or skin == 68 or skin == 69 or skin == 75 or skin == 77 or skin == 84 or skin == 92 or skin == 95 or skin == 97 or skin == 105 or skin == 107 or skin == 108 or skin == 126 or skin == 127 or skin == 128 or skin == 152 or skin == 162 or skin == 167 or skin == 188 or skin == 195 or skin == 206 or skin == 209 or skin == 212 or skin == 213 or skin == 229 or skin == 230 or skin == 258 or skin == 264 or skin == 274 or skin == 277 then 
            killPed(hitPlayer) 
        end 
    end 
end 
addEventHandler("onColShapeHit", root, enterZone) 

About that weird issue you were experiencing when those zombies were only dying once these jumped might be caused by a height difference between the floor and the colshape itself. In order to adjust its altitude on a proper value, you could use showcol.

Link to comment

Thanks guys, i just changed the colShape height and it worked.

I want a little help with another simple script similar to this, i want to make that when the player enter the zone he get a message above the radar " Safe Zone" and the message will stay till he leave the zone and if he leave the text will be gone:

Here's the script and the dxDrawText:

Server:

  
addEventHandler ("onResourceStart",getResourceRootElement(getThisResource()), 
function() 
  local allGreenzones = getElementsByType ("radararea") 
  for i,v in ipairs (allGreenzones) do 
    local r,g,b,a = getRadarAreaColor (v) 
    if (r == 0) and (g == 255) and (b == 0) and (a == 127) then 
      local x,y = getElementPosition (v) 
      local sx,sy = getRadarAreaSize (v) 
      local col = createColCuboid (x,y, -50, sx,sy, 7500) 
      setElementID (col, "greenzoneColshape") 
    end 
  end 
end) 
  
addEventHandler ("onColShapeHit", getRootElement(),  
function(hitElement, matchingDimension) 
  if (isElement(hitElement)) and (getElementType (hitElement) == "player") and (getElementID (source) == "greenzoneColshape") then 
    toggleControl (hitElement, "fire", false) 
    toggleControl (hitElement, "next_weapon", true) 
    toggleControl (hitElement, "previous_weapon", true) 
    toggleControl (hitElement, "aim_weapon", false) 
    toggleControl (hitElement, "vehicle_fire", false) 
    showPlayerHudComponent (hitElement, "ammo", true) 
    showPlayerHudComponent (hitElement, "weapon", true) 
    triggerClientEvent (hitElement, "enableGodMode", hitElement) 
  end 
end) 
  
addEventHandler ("onColShapeLeave", getRootElement(),  
function(leaveElement, matchingDimension) 
  if (getElementType (leaveElement) == "player") and (getElementID (source) == "greenzoneColshape") then 
    toggleControl (leaveElement, "fire", true) 
    toggleControl (leaveElement, "next_weapon", true) 
    toggleControl (leaveElement, "previous_weapon", true) 
    toggleControl (leaveElement, "aim_weapon", true) 
    toggleControl (leaveElement, "vehicle_fire", true) 
    showPlayerHudComponent (leaveElement, "ammo", true) 
    showPlayerHudComponent (leaveElement, "weapon", true) 
    triggerClientEvent (leaveElement, "disableGodMode", leaveElement) 
  end 
end) 
  

Client:

  
function godmodeHandler () 
  cancelEvent () 
end 
  
addEvent ("enableGodMode",true) 
addEventHandler ("enableGodMode",getRootElement(), 
function() 
  if (source == getLocalPlayer()) then 
    addEventHandler ("onClientPlayerDamage",getRootElement(),godmodeHandler) 
  end 
end) 
  
addEvent ("disableGodMode",true) 
addEventHandler ("disableGodMode",getRootElement(), 
function() 
  if (source == getLocalPlayer()) then 
    removeEventHandler ("onClientPlayerDamage",getRootElement(),godmodeHandler) 
  end 
end) 
  
  
function zonetxt(source) 
  dxDrawText("", 47, 770, 290, 770, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false) 
  dxDrawText("Safe Zone", 88, 757, 202, 873, tocolor(0, 0, 0, 255), 1.20, "bankgothic", "left", "top", false, false, false, false, false) 
  dxDrawText("Safe Zone", 88, 755, 202, 871, tocolor(0, 0, 0, 255), 1.20, "bankgothic", "left", "top", false, false, false, false, false) 
  dxDrawText("Safe Zone", 86, 757, 200, 873, tocolor(0, 0, 0, 255), 1.20, "bankgothic", "left", "top", false, false, false, false, false) 
  dxDrawText("Safe Zone", 86, 755, 200, 871, tocolor(0, 0, 0, 255), 1.20, "bankgothic", "left", "top", false, false, false, false, false) 
  dxDrawText("Safe Zone", 87, 756, 201, 872, tocolor(42, 255, 0, 255), 1.20, "bankgothic", "left", "top", false, false, false, false, false) 
  triggerServerEvent(hitElement,"onColShapeHit",hitElement) 
end 
addEventHandler ("onColShapeHit", getRootElement, zonetxt) 
  
  

Link to comment
  
function godmodeHandler () 
  cancelEvent () 
end 
  
addEvent ("enableGodMode",true) 
addEventHandler ("enableGodMode",getRootElement(), 
function() 
  if (source == getLocalPlayer()) then 
    addEventHandler ("onClientPlayerDamage",source,godmodeHandler) 
    addEventHandler( "onClientRender", root, zonetxt ) 
  end 
end) 
  
addEvent ("disableGodMode",true) 
addEventHandler ("disableGodMode",getRootElement(), 
function() 
  if (source == getLocalPlayer()) then 
    removeEventHandler ("onClientPlayerDamage", source,godmodeHandler) 
    removeEventHandler( "onClientRender", root, zonetxt ) 
  end 
end) 
  
  
function zonetxt( ) 
  dxDrawText("", 47, 770, 290, 770, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false) 
  dxDrawText("Safe Zone", 88, 757, 202, 873, tocolor(0, 0, 0, 255), 1.20, "bankgothic", "left", "top", false, false, false, false, false) 
  dxDrawText("Safe Zone", 88, 755, 202, 871, tocolor(0, 0, 0, 255), 1.20, "bankgothic", "left", "top", false, false, false, false, false) 
  dxDrawText("Safe Zone", 86, 757, 200, 873, tocolor(0, 0, 0, 255), 1.20, "bankgothic", "left", "top", false, false, false, false, false) 
  dxDrawText("Safe Zone", 86, 755, 200, 871, tocolor(0, 0, 0, 255), 1.20, "bankgothic", "left", "top", false, false, false, false, false) 
  dxDrawText("Safe Zone", 87, 756, 201, 872, tocolor(42, 255, 0, 255), 1.20, "bankgothic", "left", "top", false, false, false, false, false) 
  triggerServerEvent(localPlayer,"onColShapeHit",localPlayer) 
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...