Jump to content

Não consigo utilizar o setElementPosition.


Recommended Posts

Então manos, eu estou fazendo um script de emprego para estudar Lua, etc. Cheguei ao final do script e estou me deparando com um problema:

Ao término do emprego era para o jogador que está dentro do veículo ser teleportado para um lugar, porém não está acontecendo. Imagino o que seja mas não consigo resolver talvez por falta de conhecimento ainda, e por isso estou aqui pedindo uma ajuda.

SERVER-SIDE

function checkPointFinal(thePlayer)

        if getElementData(thePlayer, "checkpoint3") == true then

        destroyElement(getPedOccupiedVehicle(thePlayer))
        setElementVisibleTo(blip2, thePlayer, false)
        setElementVisibleTo(blip3, thePlayer, false)
        setElementVisibleTo(blip4, thePlayer, false)
        setElementVisibleTo(blip5, thePlayer, false)

        setElementVisibleTo(job2, thePlayer, false)
        setElementVisibleTo(job3, thePlayer, false)
        setElementVisibleTo(job4, thePlayer, false)
        setElementVisibleTo(job5, thePlayer, false)
        setElementData(thePlayer, "checkpoint1", false)
        setElementData(thePlayer, "checkpoint2", false)
        setElementData(thePlayer, "checkpoint3", false)
        setElementData(thePlayer, "checkpoint4", false)
        setElementData(thePlayer, "jobIniciar", false)

        givePlayerMoney(thePlayer, 500)
        outputChatBox("Debitados R$500,00.", thePlayer, 0,250,0, true)
        outputChatBox("Digite /iniciar no marcador para fazer a corrida novamente.", thePlayer, 0,220,0, true)
        setElementPosition(thePlayer, 1714.3785400391,-1949.0649414063,14.1171875)
        end
    end
addEventHandler("onMarkerHit", job5, checkPointFinal)

 

Link to comment
function checkPointFinal(hitElement, d)
	if isElement(hitElement) and getElementType(hitElement) == "player" and d then -- se existir o elemento e se o tipo do elemento for player e se esta na mesma dimensao do marcador 
		if getElementData(hitElement, "checkpoint3") then
			destroyElement(getPedOccupiedVehicle(hitElement))
			setElementVisibleTo(blip2, hitElement, false)
			setElementVisibleTo(blip3, hitElement, false)
			setElementVisibleTo(blip4, hitElement, false)
			setElementVisibleTo(blip5, hitElement, false)

			setElementVisibleTo(job2, hitElement, false)
			setElementVisibleTo(job3, hitElement, false)
			setElementVisibleTo(job4, hitElement, false)
			setElementVisibleTo(job5, hitElement, false)
			setElementData(hitElement, "checkpoint1", false)
			setElementData(hitElement, "checkpoint2", false)
			setElementData(hitElement, "checkpoint3", false)
			setElementData(hitElement, "checkpoint4", false)
			setElementData(hitElement, "jobIniciar", false)

			givePlayerMoney(hitElement, 500)
			outputChatBox("Debitados R$500,00.", hitElement, 0, 250, 0)
			outputChatBox("Digite /iniciar no marcador para fazer a corrida novamente.", hitElement, 0, 220, 0)
			setElementPosition(hitElement, 1714.3785400391, -1949.0649414063, 14.1171875)
		end
	end
end
addEventHandler("onMarkerHit", job5, checkPointFinal)

Tente isso

  • Like 1
Link to comment

Caso, a do MainSCR não funcionar, tente assim :

function checkPointFinal(hitElement, d)
   if isElement(hitElement) and getElementType(hitElement) == "player" and d then
      if isPedInVehicle(hitElement) then --/> Adicionado
         if getElementData(hitElement, "checkpoint3") then
            destroyElement(getPedOccupiedVehicle(hitElement))
            setElementVisibleTo(blip2, hitElement, false)
            setElementVisibleTo(blip3, hitElement, false)
            setElementVisibleTo(blip4, hitElement, false)
            setElementVisibleTo(blip5, hitElement, false)

            setElementVisibleTo(job2, hitElement, false)
            setElementVisibleTo(job3, hitElement, false)
            setElementVisibleTo(job4, hitElement, false)
            setElementVisibleTo(job5, hitElement, false)
            setElementData(hitElement, "checkpoint1", false)
            setElementData(hitElement, "checkpoint2", false)
            setElementData(hitElement, "checkpoint3", false)
            setElementData(hitElement, "checkpoint4", false)
            setElementData(hitElement, "jobIniciar", false)
 
            givePlayerMoney(hitElement, 500)
            outputChatBox("Debitados R$500,00.", hitElement, 0, 250, 0)
            outputChatBox("Digite /iniciar no marcador para fazer a corrida novamente.", hitElement, 0, 220, 0)
		    
            setTimer ( function () --/> Adicionado
               setElementPosition(hitElement, 1714.3785400391, -1949.0649414063, 14.1171875)
            end, 200, 1) --/> Adicionado
         end --/> Adicionado
      end
   end
end
addEventHandler("onMarkerHit", job5, checkPointFinal)

 

Edited by Angelo Pereira
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...