Jump to content

Enviar um Local para outra função


Recommended Posts

Posted

olá, criei um marker em uma função, que adicionei um addEventHandler para esse marker em outra função, e nessa outra função, queria destruí-lo como está no script abaixo

function pegarcarrocar(thePlayer)
local finalm = createMarker(1323.237, 207.215, 18.55,"cylinder",3.5,100,0,0,255,thePlayer) --DIllimore
createBlipAttachedTo(finalm,0,2,255,0,0,255,0,99999,thePlayer)
addEventHandler("onMarkerHit",finalm,entrega1)
outputChatBox("Leve o veículo até o lugar marcado no mapa!", thePlayer, 0, 0, 150, true )
end

function entrega1(player)
destroyElement(finalm)
removeEventHandler("onMarkerHit",finalm,entrega1)
end

 

  • Moderators
Posted

Não crie o marker local se ele estiver dentro de uma função.

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanksspacer.png

Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile
Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment
Discord Oficial do MTA: https://mtasa.com/discord
Blacklist e Whitelist de Scripters: Planilha

Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.

Posted

No caso você vai usar os dados do evento "onMarkerHit", já que você interligou esse evento na função entrega1.

Sendo assim, a função entrega1 irá receber os parâmetros: hitElement, matchingDimension e a source do evento será o elemento da marker.

Ficará assim:

function entrega1(hitElement)
  	-- sempre indente o código
	if getElementType(hitElement) == "player" then -- verifique se quem colidiu foi o jogador
		destroyElement(source)
		removeEventHandler("onMarkerHit",source,entrega1)
	end
end

 

  • Thanks 1

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

Agora, adicionei um timer com outra função, porem da erro que ele não acha os elementos
 

function entrega3(hitElement, matchingDimension)
    local v = getPedOccupiedVehicle (hitElement) 
    setElementFrozen(v,true)
    setTimer(descongelar,3500,1)
    removeEventHandler("onMarkerHit",source,entrega3) 
end

function descongelar(thePlayer)
    local v = getPedOccupiedVehicle(thePlayer) 
    if isElementFrozen(v) == true then
        setElementFrozen(v,false)
        givePlayerMoney(thePlayer,math.random(1500,3500))
    end
end

 

Posted
setTimer(descongelar,3500,1,hitElement)

 

  • Thanks 1

Please do not PM me with scripting related question nor support, use the forums instead.

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