DRW Posted May 26, 2015 Share Posted May 26, 2015 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
Walid Posted May 26, 2015 Share Posted May 26, 2015 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
DRW Posted May 26, 2015 Author Share Posted May 26, 2015 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
WhoAmI Posted May 26, 2015 Share Posted May 26, 2015 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
DRW Posted May 26, 2015 Author Share Posted May 26, 2015 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
WhoAmI Posted May 26, 2015 Share Posted May 26, 2015 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
DRW Posted June 1, 2015 Author Share Posted June 1, 2015 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
Walid Posted June 1, 2015 Share Posted June 1, 2015 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
DRW Posted June 8, 2015 Author Share Posted June 8, 2015 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
Walid Posted June 8, 2015 Share Posted June 8, 2015 Still not working D: i already tested it and it's working fine. Link to comment
DRW Posted June 8, 2015 Author Share Posted June 8, 2015 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 Link to comment
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