Sign in to follow this  
EW1611

hitElement ou thePlayer?

Recommended Posts

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

 

Share this post


Link to post

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

Share this post


Link to post

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

Share this post


Link to post

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

 

Share this post


Link to post

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

Edited by EW1611

Share this post


Link to post

Veja o comentário que deixei na linha 8. 

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

  • Thanks 1

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.