Jump to content

[SOLVED] How to fix anti zombie area


Brolis

Recommended Posts

safecol = createColCuboid ( 95.974617004395, 1751.3895263672, 17.640625, 255, 255, 255 ) 
safeZoneRadar = createRadarArea ( 95.974617004395, 1751.3895263672, 255, 255, 91, 127, 0, 100 ) -- 200 = alpha.  
setElementData (safeZoneRadar, "zombieProof", true) 
  
  
function enterZone(hitPlayer,thePlayer) 
    local skin = getElementModel (hitPlayer) 
      if ( skin == 287 ) then 
    toggleControl (hitPlayer, "fire", true ) 
    toggleControl (hitPlayer, "aim_weapon", true) 
    toggleControl (hitPlayer, "vehicle_fire", true) 
    --outputChatBox("INFO: You have entered Area 69/51!", hitPlayer, 0, 255, 0) 
      elseif ( skin == 285 ) then 
    toggleControl (hitPlayer, "fire", true ) 
    toggleControl (hitPlayer, "aim_weapon", true) 
    toggleControl (hitPlayer, "vehicle_fire", true) 
    --outputChatBox("INFO: You have entered Area 69/51!", hitPlayer, 0, 255, 0) 
      elseif ( skin == 191 ) then 
    toggleControl (hitPlayer, "fire", true ) 
    toggleControl (hitPlayer, "aim_weapon", true) 
    toggleControl (hitPlayer, "vehicle_fire", true) 
    --outputChatBox("INFO: You have entered Area 69/51!", hitPlayer, 0, 255, 0) 
      elseif ( skin == 192 ) then 
    toggleControl (hitPlayer, "fire", true ) 
    toggleControl (hitPlayer, "aim_weapon", true) 
    toggleControl (hitPlayer, "vehicle_fire", true) 
    --outputChatBox("INFO: You have entered Area 69/51!", hitPlayer, 0, 255, 0) 
      elseif ( skin == 193 ) then 
    toggleControl (hitPlayer, "fire", true ) 
    toggleControl (hitPlayer, "aim_weapon", true) 
    toggleControl (hitPlayer, "vehicle_fire", true) 
    --outputChatBox("INFO: You have entered Area 69/51!", hitPlayer, 0, 255, 0) 
      elseif ( skin == 294 ) then 
    toggleControl (hitPlayer, "fire", true ) 
    toggleControl (hitPlayer, "aim_weapon", true) 
    toggleControl (hitPlayer, "vehicle_fire", true) 
    --outputChatBox("INFO: You have entered Area 69/51!", hitPlayer, 0, 255, 0) 
     
     
       else 
         killPed (hitPlayer) 
       end 
end 
  
addEventHandler( "onColShapeHit", safecol, enterZone ) 
  
function leaveZone(hitPlayer,thePlayer) 
local skin = getElementModel (hitPlayer) 
    toggleControl (hitPlayer, "fire", true) 
    toggleControl (hitPlayer, "aim_weapon", true) 
    toggleControl (hitPlayer, "vehicle_fire", true) 
    --outputChatBox("INFO: You have left Area 69/51!", hitPlayer, 255, 0, 0) 
 if not ( skin == 287 )  then 
  killPed (hitPlayer) 
  outputChatBox("INFO: You are not allowed to enter Area 69/51!", hitPlayer, 240, 0, 0) 
 elseif not ( skin == 285 )  then 
  killPed (hitPlayer) 
  outputChatBox("INFO: You are not allowed to enter Area 69/51!", hitPlayer, 240, 0, 0) 
 elseif not ( skin == 191 )  then 
  killPed (hitPlayer) 
  outputChatBox("INFO: You are not allowed to enter Area 69/51!", hitPlayer, 240, 0, 0) 
 elseif not ( skin == 192 )  then 
  killPed (hitPlayer) 
  outputChatBox("INFO: You are not allowed to enter Area 69/51!", hitPlayer, 240, 0, 0) 
  elseif not ( skin == 193 )  then 
  killPed (hitPlayer) 
  outputChatBox("INFO: You are not allowed to enter Area 69/51!", hitPlayer, 240, 0, 0) 
 elseif not ( skin == 294 )  then 
  killPed (hitPlayer) 
  outputChatBox("INFO: You are not allowed to enter Area 69/51!", hitPlayer, 240, 0, 0) 
end 
end 
addEventHandler( "onColShapeLeave", safecol, leaveZone ) 
  

I want that when I drive in that area with 287, 285, 193, 192, 191, 294 skin I will not die.

Please fix this script, thanks.

Edited by Guest
Link to comment

try this:

local nonKillables = { --this is easier 
    [287]=true, 
    [285]=true, 
    [193]=true, 
    [192]=true, 
    [191]=true, 
    [294]=true; 
} 
safecol = createColCuboid ( 95.974617004395, 1751.3895263672, 17.640625, 255, 255, 255 ) 
safeZoneRadar = createRadarArea ( 95.974617004395, 1751.3895263672, 255, 255, 91, 127, 0, 100 ) -- 200 = alpha. 
setElementData (safeZoneRadar, "zombieProof", true) 
  
function enterZone(hitPlayer,thePlayer) 
    local skin = getElementModel (hitPlayer) 
    if nonKillables[skin] then 
        toggleControl (hitPlayer, "fire", true ) 
        toggleControl (hitPlayer, "aim_weapon", true) 
        toggleControl (hitPlayer, "vehicle_fire", true) 
        --outputChatBox("INFO: You have entered Area 69/51!", hitPlayer, 0, 255, 0) 
    else 
        killPed (hitPlayer) 
    end 
end 
  
addEventHandler( "onColShapeHit", safecol, enterZone ) 
  
function leaveZone(hitPlayer,thePlayer) 
    local skin = getElementModel (hitPlayer) 
    toggleControl (hitPlayer, "fire", true) 
    toggleControl (hitPlayer, "aim_weapon", true) 
    toggleControl (hitPlayer, "vehicle_fire", true) 
    --outputChatBox("INFO: You have left Area 69/51!", hitPlayer, 255, 0, 0) 
    if not nonKillables[skin] then 
        killPed (hitPlayer) 
        outputChatBox("INFO: You are not allowed to enter Area 69/51!", hitPlayer, 240, 0, 0) 
    end 
end 
addEventHandler( "onColShapeLeave", safecol, leaveZone ) 

and next time please use the ['lua'][/lua] tags.

Edited by Guest
Link to comment
  • 2 weeks later...

Hi again, now i have a error in my console...

WARNING: area51\area51zone.lua:34: Bad argument @ 'toggleControl'

Please, fix this error, I am using your pasted resource/script...

I'll try to fix it by myself I think now I know how to fix that, you puted a line in not correct line.

    local skin = getElementModel (hitPlayer) 
    toggleControl (hitPlayer, "fire", true) 

You missed, not swapped

    if nonKillables[skin] then 

Link to comment

oh, you mean this:

local nonKillables = { --this is easier 
    [287]=true, 
    [285]=true, 
    [193]=true, 
    [192]=true, 
    [191]=true, 
    [294]=true; 
} 
safecol = createColCuboid ( 95.974617004395, 1751.3895263672, 17.640625, 255, 255, 255 ) 
safeZoneRadar = createRadarArea ( 95.974617004395, 1751.3895263672, 255, 255, 91, 127, 0, 100 ) -- 200 = alpha. 
setElementData (safeZoneRadar, "zombieProof", true) 
  
addEventHandler( "onColShapeHit", safecol, function(hitPlayer,thePlayer) 
    if getElementType(hitPlayer)=="player" then 
        local skin = getElementModel (hitPlayer) 
        if nonKillables[skin] then 
            toggleControl (hitPlayer, "fire", true ) 
            toggleControl (hitPlayer, "aim_weapon", true) 
            toggleControl (hitPlayer, "vehicle_fire", true) 
            --outputChatBox("INFO: You have entered Area 69/51!", hitPlayer, 0, 255, 0) 
        else 
            killPed (hitPlayer) 
        end 
    end 
end) 
  
addEventHandler( "onColShapeLeave", safecol,function(hitPlayer,thePlayer) 
    if getElementType(hitPlayer)=="player"then 
        local skin = getElementModel (hitPlayer) 
        if nonKillables[skin] then 
            toggleControl (hitPlayer, "fire", true) 
            toggleControl (hitPlayer, "aim_weapon", true) 
            toggleControl (hitPlayer, "vehicle_fire", true) 
            --outputChatBox("INFO: You have left Area 69/51!", hitPlayer, 255, 0, 0) 
        else 
            killPed (hitPlayer,hitPlayer) 
            outputChatBox("INFO: You are not allowed to enter Area 69/51!", hitPlayer, 240, 0, 0) 
        end 
    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...