Jump to content

Antidamage greenzone


DRW

Recommended Posts

Posted

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 
) 
  
  

Posted
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 
) 

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

Posted
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 
) 

Posted
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

Posted
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 
) 

Posted
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 :/

Posted

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 

Posted
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:

Posted

Still not working D:

i already tested it and it's working fine.

Sure it's making attackers to not deal damage to players? Because people in my server keep DMing in those zones

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