Military Guy Posted June 11, 2022 Posted June 11, 2022 (edited) How to make a damage player in area? Edited June 12, 2022 by Vinyard Removed non-English version of this message.
FernandoMTA Posted June 12, 2022 Posted June 12, 2022 Like PUBG outside the safe zone where the player takes damage slowly?
Military Guy Posted June 12, 2022 Author Posted June 12, 2022 2 hours ago, FernandoMTA said: Like PUBG outside the safe zone where the player takes damage slowly? Yes
FernandoMTA Posted June 12, 2022 Posted June 12, 2022 (edited) 2 hours ago, Military Guy said: Yes You coud do something like this in a client script: local DAMAGE_AREA = createColPolygon(-1, 4, 5, 8, 9, 4, 5, -2, -1, 4) -- colshape coordinates here local DAMAGE_DELAY = 3000 -- miliseconds between damage hits local DAMAGE_AMOUNT = 5 -- health points to lose local damageTimer local function takeDamage() -- cancel damage timer if dead if isPedDead(localPlayer) then if isTimer(damageTimer) then killTimer(damageTimer) damageTimer = nil end return end -- take damage (this may kill the player) setElementHealth(localPlayer, math.max(0, getElementHealth(localPlayer) - DAMAGE_AMOUNT)) outputChatBox("Ouch", 255, 56, 56) -- you can trigger some visual effects here (if you want) end addEventHandler( "onClientColShapeHit", DAMAGE_AREA, function (theElement, matchingDimension) if (theElement ~= localPlayer) then return end if not (matchingDimension) then return end -- take damage instantly (if you want) takeDamage() -- set damage timer damageTimer = setTimer(takeDamage, DAMAGE_DELAY, 0) end) addEventHandler( "onClientColShapeLeave", DAMAGE_AREA, function (theElement, matchingDimension) if (theElement ~= localPlayer) then return end if not (matchingDimension) then return end -- cancel damage timer if isTimer(damageTimer) then killTimer(damageTimer) damageTimer = nil end end) Edited June 12, 2022 by FernandoMTA 1 1
Military Guy Posted June 12, 2022 Author Posted June 12, 2022 2 hours ago, FernandoMTA said: You coud do something like this in a client script: local DAMAGE_AREA = createColPolygon(-1, 4, 5, 8, 9, 4, 5, -2, -1, 4) -- colshape coordinates here local DAMAGE_DELAY = 3000 -- miliseconds between damage hits local DAMAGE_AMOUNT = 5 -- health points to lose local damageTimer local function takeDamage() -- cancel damage timer if dead if isPedDead(localPlayer) then if isTimer(damageTimer) then killTimer(damageTimer) damageTimer = nil end return end -- take damage (this may kill the player) setElementHealth(localPlayer, math.max(0, getElementHealth(localPlayer) - DAMAGE_AMOUNT)) outputChatBox("Ouch", 255, 56, 56) -- you can trigger some visual effects here (if you want) end addEventHandler( "onClientColShapeHit", DAMAGE_AREA, function (theElement, matchingDimension) if (theElement ~= localPlayer) then return end if not (matchingDimension) then return end -- take damage instantly (if you want) takeDamage() -- set damage timer damageTimer = setTimer(takeDamage, DAMAGE_DELAY, 0) end) addEventHandler( "onClientColShapeLeave", DAMAGE_AREA, function (theElement, matchingDimension) if (theElement ~= localPlayer) then return end if not (matchingDimension) then return end -- cancel damage timer if isTimer(damageTimer) then killTimer(damageTimer) damageTimer = nil end end) THX! 1
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