Jump to content

Antidamage greenzone


DRW

Recommended Posts

Hello, I want to disable damage dealing only to players if they are in a colshape.

I mean, if a player shoots me he won't deal any damage, but if a zombie attacks me, then he will deal damage to me, it's not working.

Client-sided

colRec = createColRectangle (-1203.599609375, 2814.75, 500,500) 
colRad = createRadarArea (-782.689453125, 656.4794921875, 1700,2200,0,0,0,100) 
  
addEventHandler ("onClientPlayerDamage",localPlayer,  
function (attacker) 
if isElementWithinColShape (localPlayer, colRec) and getElementData (attacker, "player") 
then 
cancelEvent () 
  
end 
end 
) 
  
  

Link to comment
local colRec = createColRectangle (-1203.599609375, 2814.75, 500,500) 
local colRad = createRadarArea (-782.689453125, 656.4794921875, 1700,2200,0,0,0,100) 
local col = {colRec,colRad} 
  
addEventHandler ("onClientPlayerDamage",localPlayer, 
function (attacker) 
    for i , v in pairs (col) do 
        if isElementWithinColShape (source, v) then  
            cancelEvent () 
        end 
    end  
end 
) 

Link to comment
local colRec = createColRectangle (-1203.599609375, 2814.75, 500,500) 
local colRad = createRadarArea (-782.689453125, 656.4794921875, 1700,2200,0,0,0,100) 
local col = {colRec,colRad} 
  
addEventHandler ("onClientPlayerDamage",localPlayer, 
function (attacker) 
    for i , v in pairs (col) do 
        if isElementWithinColShape (source, v) then  
            cancelEvent () 
        end 
    end  
end 
) 

Seems to not be working.

Link to comment
colRec = createColRectangle (-1203.599609375, 2814.75, 500,500) 
colRad = createRadarArea (-782.689453125, 656.4794921875, 1700,2200,0,0,0,100) 
  
addEventHandler ( "onClientPlayerDamage", localPlayer, 
    function (attacker) 
        if getElementType ( attacker ) == "player" then 
            if isElementWithinColShape ( source, colRec ) then 
                cancelEvent () 
            end 
        end 
    end 
) 

Link to comment
colRec = createColRectangle (-1203.599609375, 2814.75, 500,500) 
colRad = createRadarArea (-782.689453125, 656.4794921875, 1700,2200,0,0,0,100) 
  
addEventHandler ( "onClientPlayerDamage", localPlayer, 
    function (attacker) 
        if getElementType ( attacker ) == "player" then 
            if isElementWithinColShape ( source, colRec ) then 
                cancelEvent () 
            end 
        end 
    end 
) 

getElementType expected element at argument 1, got boolean

Link to comment
colRec = createColRectangle (-1203.599609375, 2814.75, 500,500) 
colRad = createRadarArea (-782.689453125, 656.4794921875, 1700,2200,0,0,0,100) 
  
addEventHandler ( "onClientPlayerDamage", localPlayer, 
    function (attacker) 
        if isElement ( attacker ) and getElementType ( attacker ) == "player" then 
            if isElementWithinColShape ( source, colRec ) then 
                cancelEvent () 
            end 
        end 
    end 
) 

Link to comment
colRec = createColRectangle (-1203.599609375, 2814.75, 500,500) 
colRad = createRadarArea (-782.689453125, 656.4794921875, 1700,2200,0,0,0,100) 
  
addEventHandler ( "onClientPlayerDamage", localPlayer, 
    function (attacker) 
        if isElement ( attacker ) and getElementType ( attacker ) == "player" then 
            if isElementWithinColShape ( source, colRec ) then 
                cancelEvent () 
            end 
        end 
    end 
) 

Doesn't work :/

Link to comment

Try this it should work

colRec = createColRectangle (-1203.599609375, 2814.75, 500,500) 
colRad = createRadarArea (-782.689453125, 656.4794921875, 1700,2200,0,0,0,100) 
col = {colRec,colRad} 
  
addEventHandler("onClientPlayerDamage", root, 
function() 
    if isElementWithinGreenzone(source) then  
        cancelEvent() 
    end 
end) 
  
function isElementWithinGreenzone(element) 
    if (not isElement(element)) then return false end 
        for i, zone in pairs(col) do 
            if (isElementWithinColShape(element, zone)) then  
                return true  
            end 
        end 
    return false 
end 

Link to comment
Try this it should work
colRec = createColRectangle (-1203.599609375, 2814.75, 500,500) 
colRad = createRadarArea (-782.689453125, 656.4794921875, 1700,2200,0,0,0,100) 
col = {colRec,colRad} 
  
addEventHandler("onClientPlayerDamage", root, 
function() 
    if isElementWithinGreenzone(source) then  
        cancelEvent() 
    end 
end) 
  
function isElementWithinGreenzone(element) 
    if (not isElement(element)) then return false end 
        for i, zone in pairs(col) do 
            if (isElementWithinColShape(element, zone)) then  
                return true  
            end 
        end 
    return false 
end 

Still not working D:

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