Jump to content

Após receber dano não consiga se teleportar


Recommended Posts

Salve rapaizada. Quero colocar para após a pessoa receber algum tipo de dano ela não consiga usar o teleporte durante 10 segundos. Dei uma procurada antes de criar o tópico pelo onPlayerDamage mas não consegui pensar em nenhuma forma de criar isso. Alguém que poderia me ajudar? por favor

OBS: o script é server-side

function tele (thePlayer)
    if not isElement (thePlayer) then return end
    fadeCamera(thePlayer, false, 0.5)
    setTimer(fadeCamera, 1000, 1, thePlayer, true)
    if (commando[thePlayer]) then
        return
    end
    setTimer( function(thePlayer)
    if not (isElement(thePlayer)) then return end
        setElementPosition ( thePlayer, 2501, -1674, 13 )
    end, tempo, 1, thePlayer)
        commando[thePlayer] = true
    setTimer( function()
        commando[thePlayer] = false
    end, tempo*2, 1)
end
addCommandHandler ( "cj", tele )

 

Link to comment
  • Moderators
local damagePlayers = {}

function onDamage( )
	if damagePlayers[source] and isTimer(damagePlayers[source]) then killTimer(damagePlayers[source]) end
	
	damagePlayers[source] = setTimer( function(p)
		if isElement(p) then
			damagePlayers[p] = nil
		end
	end, 10000, 1, source )
end
addEventHandler( "onPlayerDamage", root, onDamage )

Nesse código eu fiz um timer quando o jogador leva hit e reseta depois de 10 segundos.

No comando do teleporte você só irá fazer uma verificação na tabela damagePlayers: 

if damagePlayers[thePlayer] then return outputChatBox("Você não pode usar esse comando agora!", thePlayer) end

Coloque isso no inicio do comando do teleporte.

  • Thanks 1
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...