Jump to content

hitElement ou thePlayer?


Recommended Posts

Posted

fiz o seguinte script, porém da erro no getPedOccupiedVehicle, no getElementData e no removeEventHandler. Alguém sabe dizer qual o erro?

function entrega2(hitElement, matchingDimension )
    local v = getPedOccupiedVehicle(hitElement) 
    if getElementData(v,"Carregado") == true then
        setElementFrozen(v,true)
        outputChatBox("Espere o veículo ser descarregado!",hitElement,0,0,150)
        setElementData(v,"Carregado",false)
        destroyElement(finalm2)
        destroyElement(blip2)
        setTimer(function (hitElement, matchingDimension )
            if isElementFrozen(hitElement) == true then
                setElementFrozen(hitElement,false)
                givePlayerMoney(hitElement,math.random(1500,3500))
                removeEventHandler("onVehicleExit",source,remove2)
            end
        end,3500,1,hitElement) 
        removeEventHandler("onMarkerHit",source,entrega2) 
    end
end

 

  • Moderators
Posted

Faltou verificar se hitElement é um jogador.

function entrega2 (hitElement, matchingDimension)
	if (hitElement and getElementType (hitElement) == "player") then
		local v = getPedOccupiedVehicle (hitElement) 
		if getElementData (v, "Carregado") == true then
			setElementFrozen (v, true)
			outputChatBox ("Espere o veículo ser descarregado!", hitElement, 0, 0, 150)
			setElementData (v, "Carregado", false)
			destroyElement (finalm2)
			destroyElement (blip2)
			setTimer (function (theHitElement, theSource)
				if isElementFrozen (theHitElement) then
					setElementFrozen (theHitElement, false)
					givePlayerMoney (theHitElement, math.random (1500,3500))
					removeEventHandler ("onVehicleExit", theSource, remove2)
				end
			end, 3500, 1, hitElement, source)
			removeEventHandler ("onMarkerHit", source, entrega2)
		end
	end
end

 

  • Thanks 1

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

a parte do getPedOccupiedVehicle e getElementData funcionou, obrigado, porém continua com o mesmo erro no removeEventHandler

Posted

Tente:

function entrega2(hitElement, matchingDimension )
	if getElementType(hitElement) ~= "player" then return end
	local v = getPedOccupiedVehicle(hitElement)
	if v and getElementData(v,"Carregado") == true then
		setElementFrozen(v,true)
		outputChatBox("Espere o veículo ser descarregado!",hitElement,0,0,150)
		setElementData(v,"Carregado",false)
		destroyElement(finalm2) -- se "finalm2" for a marker deste evento source vai causar erro
		destroyElement(blip2)
		setTimer(function (marker)
			if not (isElement(hitElement)) then return end
			if isElementFrozen(v) then
				setElementFrozen(v,false)
				givePlayerMoney(hitElement,math.random(1500,3500))
				removeEventHandler("onVehicleExit",marker,remove2) -- certifique-se que a função 'remove2' esteja definida
			end
		end,3500,1,source)
		removeEventHandler("onMarkerHit",source,entrega2) 
	end
end

 

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

Posted (edited)

da o seguinte erro, nos dois: Bad argument @ 'removeEventHandler' [Expected element at argument 2]

Edited by EW1611
Posted

Veja o comentário que deixei na linha 8. 

Mova destroyElement(finalm2) para o timer depois do removeEventHandler.

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