Jump to content

[AJUDA] Serviço


Recommended Posts

Preciso de ajuda, estava fazendo um script de serviço porém ao colocar ele para fazer essa função:


function sair (source)
    if (veh[source]) and isElement(veh[source]) then
    outputChatBox ('#000000[ #FFB700Aviador#000000 ] #868686Você saiu do veículo e perdeu o trabalho!',source,255,255,255,true)
    destroyElement (veh[source])
    Trabalho = false
    setElementVisibleTo ( entregar, source, false )
    setElementVisibleTo ( blip, source, false )
    setElementData(source, "Trab", false)
   end
end
addEventHandler ("onVehicleExit", getRootElement(), sair)
addEventHandler ("onVehicleExplode", getRootElement(), sair)

 

O último EventHandler não funciona, poderiam me ajudar a resolver? Não tem erro no console.

 

Script:

 

marker = createMarker ( -79.430679321289, 90.90128326416, 2.6, "cylinder", 1.5, 255,140,0, 255)
entregar = createMarker ( -570.20233154297, 2567.4458007813, 53.910755157471 , "cylinder", 3, 255,140,0, 255)
setElementVisibleTo ( entregar, root, false )

blip = createBlipAttachedTo(entregar, 41, 3, 255, 0, 0, 255, 0, 65535, source)
setElementVisibleTo ( blip, root, false )

bliptrab = createBlipAttachedTo(marker, 5, 3, 255, 0, 0, 255, 0, 65535)

function msg (source)
outputChatBox ('#000000[ #FFB700Aviador#000000 ] #868686Para iniciar o trabalho digite: #000000-[ #FFB700/aviador #000000]',source,255,255,255,true)
end
addEventHandler( "onMarkerHit", marker, msg )


veh = {}
function pegartrab (source)
    if isElementWithinMarker (source, marker) then
        if veh[source] and isElement(veh[source]) then destroyElement(veh[source])
        veh[source] = nil
        end
    local x,y,z = getElementPosition(source)
    veh[source] = createVehicle(593 ,-82.958648681641,104.13409423828,3.4968612194061,0,9,160)
    warpPedIntoVehicle (source,veh[source])
    setElementVisibleTo ( blip, source, true )
    setElementVisibleTo ( entregar, source, true )
    outputChatBox ('#000000[ #FFB700Aviador#000000 ] #868686Vá para a marcação indicada no mapa!',source,255,255,255,true)
    else
    outputChatBox ('#000000[ #FFB700Aviador#000000 ] #FF0000Erro! #868686Você não esta no circulo para pegar o trabalho.',source,255,255,255,true)
    end
end
addCommandHandler ( "aviador", pegartrab  )

function acabar (source)
if veh[source] and isElement(veh[source]) then
destroyElement (veh[source])
setElementVisibleTo ( entregar, source, false )
setElementVisibleTo ( blip, source, false )
givePlayerMoney (source, 20000)
outputChatBox ('#000000[ #FFB700Aviador#000000 ] #868686Trabalho finalizado com #00ff00Sucesso #FF0000Você ganhou 20k +50exp',source,255,255,255,true)

local experience = tonumber(getElementData(source,"experience"))
    if (experience) then
                    setElementData(source,"experience",experience+50)
                else
                    setElementData(source,"experience",50)
    end

else
end
end
addEventHandler( "onMarkerHit", entregar, acabar )

function sair (source)
    if (veh[source]) and isElement(veh[source]) then
    outputChatBox ('#000000[ #FFB700Aviador#000000 ] #868686Você saiu do veículo e perdeu o trabalho!',source,255,255,255,true)
    destroyElement (veh[source])
    Trabalho = false
    setElementVisibleTo ( entregar, source, false )
    setElementVisibleTo ( blip, source, false )
    setElementData(source, "Trab", false)
   end
end
addEventHandler ("onVehicleExit", getRootElement(), sair)
addEventHandler ("onVehicleExplode", getRootElement(), sair)


function deslogar (source)
if (veh[source]) and isElement(veh[source]) then
destroyElement (veh[source])
Trabalho = false
setElementVisibleTo ( entregar, source, false )
setElementVisibleTo ( blip, source, false )
setElementData(source, "Trab", false)
end
end
addEventHandler ("onPlayerQuit", getRootElement(), deslogar)

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