Opa, estou com 2 erros em um mod de trabalho:
1. quando o jogador pega o trabalho de caminhoneiro mas logo em seguida um outro jogador aperta para roubar o caminhão e cancela o roubo do veículo do player que está trabalhando, mesmo com o player fora do veículo o trabalho continua em execução, podendo assim o player dar teleport a algum local próximo da área de entrega, e finalizar o trabalho.
2. Quando o player pega o trabalho e logo em seguida ele comete suicídio, o trabalho continua em execução, mesmo eu adicionando um evento que cancele a função após a morte.
Alguém poderia me ajudar nisso? Desde já agradeço.
Código do mod:
trab4 = createMarker ( 1222.684, -1789.943, 15.7, "cylinder", 1.5, 255, 140, 0, 255)
marcacao = createMarker ( 2482.79126, -2090.34351, 18.54296, "arrow", 1.5, 255,140,0, 255)
setElementVisibleTo ( marcacao, root, false )
entregartrab4 = createMarker ( -2336.06299, -1660.78528, 483.70313 , "corona", 3, 0, 255, 209, 255)
setElementVisibleTo ( entregartrab4, root, false )
blipfim4 = createBlipAttachedTo(entregartrab4, 41, 3, 255, 0, 0, 255, 0, 65535, source)
setElementVisibleTo ( blipfim4, root, false )
function msg (source)
outputChatBox ('#ffffffPara pegar o trabalho digite #ff0000/caminhoneiro', source, 255, 255, 255, true)
end
addEventHandler( "onMarkerHit", trab4, msg )
carga = {}
veh = {}
function pegartrab4 ( source )
if isElementWithinMarker (source, trab4 ) 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(403 ,2479.15234, -2091.43652, 14.56156)
carga[source] = createVehicle(450 ,2487.23511, -2090.43604, 13.54688 + 1)
setElementVisibleTo ( marcacao, root, true )
setElementRotation ( veh[source], 0, 0, 90)
setElementRotation ( carga[source], 0, 0, 90)
warpPedIntoVehicle (source,veh[source])
setElementVisibleTo ( blipfim4, source, true )
setElementVisibleTo ( entregartrab4, source, true )
outputChatBox ('#ffffffAgora pegue a carga e leve-a até o Blip no #FF0000Mount Chilliad.', source, 255, 255, 255, true)
setTimer ( function()
setElementVisibleTo ( marcacao, root, false )
end, 13000, 1 )
else
outputChatBox ('#ffffffVocê tem que ficar no lugar certo para pegar o Trabalho de Caminhoneiro.', source, 255, 255, 255, true)
end
end
addCommandHandler ( "caminhoneiro", pegartrab4 )
function finalizartrab4 (source)
if veh[source] and isElement(veh[source]) then
if (carga[source]) and isElement(carga[source]) then
setElementVisibleTo ( entregartrab4, source, false )
setElementVisibleTo ( blipfim4, source, false )
givePlayerMoney (source, 8000)
destroyElement (veh[source])
destroyElement (carga[source])
outputChatBox ('#ffffffTrabalho finalizado, você recebeu #0F9C08$8.000 #FFFFFFpelo serviço.', source, 255, 255, 255, true)
else
end
end
end
addEventHandler( "onMarkerHit", entregartrab4, finalizartrab4 )
function sair4 (source)
if (veh[source]) and isElement(veh[source]) then
if (carga[source]) and isElement(carga[source]) then
destroyElement (veh[source])
destroyElement (carga[source])
setElementVisibleTo ( blipfim4, source, false )
setElementVisibleTo ( entregartrab4, source, false )
outputChatBox ('#ffffffVocê saiu do veículo e perdeu o trabalho.', source, 255, 255, 255, true)
end
end
end
addEventHandler ("onVehicleExit", root, sair4)
addEventHandler ("onPlayerWasted", root, sair4)