pelo que entendi do erro na hora de iniciar a rota
estao no mesmo elemento
na hora que de finalizar a rota
ele da conflito de destruir o mark e o blip
o sistema funciona da seguitne maneira voce vai la pra aperta f7 pra iniciar a rota mais no momento que eu cancelo em cima do blip ele da esse erro
MarkerIniciarRota = {}
MarkerRota = {}
BlipRota = {}
IndexComecar = {}
for i = 1,#Config.PosicoesIniciarRota do
MarkerIniciarRota[i] = createMarker(Config.PosicoesIniciarRota[i].Pos[1],Config.PosicoesIniciarRota[i].Pos[2],Config.PosicoesIniciarRota[i].Pos[3] -1.3, "cylinder",1.5, 5, 134, 249,0)
setElementData(MarkerIniciarRota[i], "NC.MarkerDroga",true)
addEvent("NC.IniciarRota",true)
addEventHandler("NC.IniciarRota",root,function()
if not isGuestAccount(getPlayerAccount(source)) then
if isElementWithinMarker(source, MarkerIniciarRota[i]) then
local Acls = Config.PosicoesIniciarRota[i].Acls
if isObjectInTableACLGroups(source, Acls) then
if getElementData(source, "NC.Rota") then
removeElementData(source, "NC.Rota")
if MarkerRota[source] and isElement(MarkerRota[source]) then
destroyElement(MarkerRota[source])
MarkerRota[source] = nil
triggerClientEvent(source,"NIGHT>SAIR",source)
end
if BlipRota[source] and isElement(BlipRota[source]) then
destroyElement(BlipRota[source])
BlipRota[source] = nil
end
IndexComecar[source] = nil
else
triggerClientEvent(source,"NIGHT>MSG",source)
IndexComecar[source] = {1, i}
local Index = IndexComecar[source][1]
local x,y,z = Config.PosicoesRotas[i][Index][1],Config.PosicoesRotas[i][Index][2],Config.PosicoesRotas[i][Index][3]
setElementData(source, "NC.Rota",true)
message(source,"success", "Voce Iniciou Uma Rota")
MarkerRota[source] = createMarker(x,y,z -1, "cylinder",1.2,255, 255, 255,100)
BlipRota[source] = createBlipAttachedTo(MarkerRota[source], 0)
setElementVisibleTo(MarkerRota[source],root,false)
setElementVisibleTo(MarkerRota[source],source,true)
setElementVisibleTo(BlipRota[source],root,false)
setElementVisibleTo(BlipRota[source],source,true)
addEventHandler("onMarkerHit",MarkerRota[source],ContinuarTrabalho)
end
else
message(source,"error", "Voce Nao Faz Parte Desse Grupo")
end
end
end
end)
end
addEvent("NC.IniciarRota2",true)
addEventHandler("NC.IniciarRota2",root,
function()
destroyElement(MarkerRota[source])
MarkerRota[source] = nil
IndexComecar[source] = nil
triggerClientEvent(source,"NIGHT>SAIR",source)
setElementData(source, "NC.Rota",false)
destroyElement(BlipRota[source])
BlipRota[source] = nil
message(source,"info", "Voce Finalizou A Rota Com Sucesso")
end)
function GiveItemRandom(player,index)
local Random = math.random(#Config.PosicoesIniciarRota[index].Itens)
local Item = Config.PosicoesIniciarRota[index].Itens[Random]
local Dinheiro = Config.PosicoesIniciarRota[index].DinheiroSujoReceber
local Quantidade = math.random(Config.PosicoesIniciarRota[index].Quantidade.De,Config.PosicoesIniciarRota[index].Quantidade.Ate)
exports["[HS]InventorySystemD"]:giveItem( player, Item, Quantidade)
exports["[HS]InventorySystemD"]:giveItem( player, Config.ConfigRotas["ID Dinheiro Sujo"], Dinheiro)
-- triggerClientEvent(player, "notifyitem", player, "sucesso", ""..Quantidade.."", ""..Item.."")
--triggerClientEvent(player, "notifyitem", player, "sucesso", ""..Dinheiro.."", "dinheirosujo")
end
function ContinuarTrabalho(player)
if player and isElement(player) and getElementType(player) == "player" then
local vehicle = getPedOccupiedVehicle(player)
if ( vehicle ) then message(source,"error", "Saia do Veiculo Para Entregar a Rota") return end
if isElementVisibleTo(source, player) then
local Index = IndexComecar[player][1]
local IndexRota = IndexComecar[player][2]
if Index == #Config.PosicoesRotas[IndexRota] then
setPedAnimation(player, "bomber", "bom_plant",2000,true,false,false,false)
setTimer(function()
GiveItemRandom(player, IndexRota)
if getElementData(player, "NC.Rota") then
removeElementData(player, "NC.Rota")
end
if MarkerRota[player] and isElement(MarkerRota[player]) then
destroyElement(MarkerRota[player])
MarkerRota[player] = nil
end
if BlipRota[player] and isElement(BlipRota[player]) then
message(source,"error", "Você finalizou uma rota prossiga para a proxima")
destroyElement(BlipRota[player])
BlipRota[player] = nil
end
IndexComecar[player] = nil
end,2000,1)
else
setPedAnimation(player, "bomber", "bom_plant",2000,true,false,false,false)
setTimer(function()
GiveItemRandom(player, IndexRota)
if MarkerRota[player] and isElement(MarkerRota[player]) then
destroyElement(MarkerRota[player])
MarkerRota[player] = nil
end
if BlipRota[player] and isElement(BlipRota[player]) then
destroyElement(BlipRota[player])
BlipRota[player] = nil
end
IndexComecar[player][1] = IndexComecar[player][1] +1
local Index = IndexComecar[player][1]
local IndexRota = IndexComecar[player][2]
local x, y, z = Config.PosicoesRotas[IndexRota][Index][1],Config.PosicoesRotas[IndexRota][Index][2],Config.PosicoesRotas[IndexRota][Index][3]
MarkerRota[player] = createMarker(x, y, z -1, "cylinder",1.2,255, 255, 255,100)
BlipRota[player] = createBlipAttachedTo(MarkerRota[player], 0)
-- local xv, yv, zv = getElementPosition(player)
-- triggerClientEvent(player, "setmaptora", player, xv, yv, zv, x, y, z)
setElementVisibleTo(MarkerRota[player],root,false)
setElementVisibleTo(MarkerRota[player],player,true)
setElementVisibleTo(BlipRota[player],root,false)
setElementVisibleTo(BlipRota[player],player,true)
addEventHandler("onMarkerHit",MarkerRota[player],ContinuarTrabalho)
end,2000,1)
end
end
end
end
function isObjectInTableACLGroups(player,acls)
for i,v in ipairs(acls) do
if aclGetGroup(v) then
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup(v)) then
return true
end
end
end
return false
end