Jump to content

WiBox

Recommended Posts

Posted (edited)

is there a way I can check if the player is under attack or from last 20 second he was attacked?

Edited by SSKE
Posted
setElementData()
setTimer() -- to reset the element data

 

~ This has to be the worst board post I have ever read. It simply makes no sense. You start off by talking about space or something, then you randomly start babbling about cupcakes, and you end off with random fish names.

~ Don't listen to this guy, any board with the categories 'dinosaurs, spaceships, fried foods, wild animals, alien abductions, business casual, robots, and fireworks' has true potential.

 

Posted

If you can give an example I'll be grateful, because I don't know how to add if the player got damage from less then 20 second...

Posted
57 minutes ago, SSKE said:

If you can give an example I'll be grateful, because I don't know how to add if the player got damage from less then 20 second...

Look for it in the Wiki, I think you'll find your way around.

~ This has to be the worst board post I have ever read. It simply makes no sense. You start off by talking about space or something, then you randomly start babbling about cupcakes, and you end off with random fish names.

~ Don't listen to this guy, any board with the categories 'dinosaurs, spaceships, fried foods, wild animals, alien abductions, business casual, robots, and fireworks' has true potential.

 

Posted

I'm still searching from the time I made this topic but I don't know how the Data i should add on elementdata.. 

Posted
    function DamageUponUsingEventJoining (player)
        timer3 = setTimer(
            function (player)
                local time4 = 20
                    if ( time4 > 0 ) then
                        for _,localPlayer in ipairs ( getElementsByType("player")) do
                            outputChatBox("If you taked damage from less then 20 seconds you can't join this event!",player, 255, 99, 71)    
                        end
                        time4 = time4 - 1
                    end
            end, 20000, 0)
    end
    addEventHandler("onPlayerDamage", root, DamageUponUsingEventJoining)

I could not try it on my self, so I needed to know if it like that because I could not test it...

Posted

Try this:

 

-- Server Side

damageTimers = {}

function handlePlayerDamage ( attacker, weapon, bodypart, loss ) 
	if (attacker) then -- Check if an attacker exists, you might wanna add a check to see if it's a valid player, also check the attacked player (source)
		if isTimer(damageTimers[source]) then -- Check if there is already a timer to reset the state of that player, happens when the player is damaged again before the 20 seconds are over
			killTimer(damageTimers[source]) -- Kill the old timer and continue to make a new one
		end
		setElementData(source,'damaged',true) -- Mark the player as damaged within the last 20 seconds
		damageTimers[source] = setTimer( -- Make a timer, we used a table damageTimers[]
			function()
				setElementData(source,'damaged',false) -- Mark the player as not damaged within the last 20 seconds AFTER the timer expires (20 seconds)
			end, 20*1000, 0
		)
	end
end
addEventHandler ( "onPlayerDamage", getRootElement (), handlePlayerDamage ) -- addEventHandler to all players

 

~ This has to be the worst board post I have ever read. It simply makes no sense. You start off by talking about space or something, then you randomly start babbling about cupcakes, and you end off with random fish names.

~ Don't listen to this guy, any board with the categories 'dinosaurs, spaceships, fried foods, wild animals, alien abductions, business casual, robots, and fireworks' has true potential.

 

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