I need a function to delete the trailer that will cancel the job for the trucking profession....
local mysql = exports.mysql
local connection = mysql:getConnection()
local trailerPlayers = {}
local trailerCount = 0
local trailerPosList = {}
addEventHandler("onResourceStart" , resourceRoot , function()
trailerMarker = createMarker(trailerMarkerPos , "cylinder" , 2.5 , 255 , 153 , 0 , 155)
addEventHandler("onMarkerHit" , trailerMarker , onMarkerGir)
addEventHandler("onMarkerLeave" , trailerMarker , function(player)
if isElement(player) and getElementType(player) == "player" then
triggerClientEvent(player , "truckHidePanel" , player)
end
end)
end)
function onMarkerGir(player)
if isElement(player) and getElementType(player) == "player" then
--if player:getData("job") ~= truckJob then
-- exports['infobox']:addBox(player , "error", "Tırcılık mesleğine giriş yapmış değilsin!")
--return end
if not player.vehicle or player.vehicle.model ~= truckModel then
exports['infobox']:addBox(player , "error", "Dorse alabilmek için bir tırın içerisinde olmalısın!")
return end
if trailerPlayers[player] then
exports['infobox']:addBox(player , "error", "Zaten bir dorse almışsın, iptal etmek için /dorseiptal")
return end
local level = 1 --exports["jobs-level"]:getLevel(player , truckJob)
triggerClientEvent(player , "truckShowPanel" , player , level)
end
end
addEvent("truckCreateTrailer" , true)
addEventHandler("truckCreateTrailer" , root , function(index)
trailerCount = 0
for i=1 , #trailerPositions do
if not trailerPosList[i] then
trailerCount = i
trailerPosList[i] = true
break
end
end
if trailerCount == 0 then
exports['infobox']:addBox(source , "warning", "Şu an daha fazla yük alınamaz, lütfen bir süre bekleyiniz!")
return end
trailerPlayers[source] = {}
trailerPlayers[source]["trailer"] = createVehicle(exped[index][2] , trailerPositions[trailerCount] , 0 , 0 , trailerRot)
trailerPlayers[source]["index"] = index
trailerPlayers[source]["trailerPos"] = trailerCount
print(trailerCount)
exports['infobox']:addBox(source , "warning", exped[index][1].." adlı firmanın yükünü aldın, dorseyi "..trailerCount..". sıradan al ve tırına tak!")
end)
addEventHandler("onTrailerAttach" , root , function(truck)
if truck.model == truckModel then
local player = getVehicleOccupant(truck)
if trailerPlayers[player] and trailerPlayers[player]["trailer"] ~= source then
setTimer(detachTrailer, 50, 1, truck, source)
exports['infobox']:addBox(player , "error", "Bu dorse sana ait değil!")
elseif not trailerPlayers[player]["attached"] and trailerPlayers[player] and trailerPlayers[player]["trailer"] == source then
trailerPlayers[player]["attached"] = true
exports['infobox']:addBox(player , "success", "Başarıyla dorseyi taktın, GPS'e bak ve yükü hedefine ulaştır!")
local index = trailerPlayers[player]["index"]
--truck:setData("gpsDestination" , )
triggerClientEvent(player , "truckMiddMarker" , player , index , {exped[index][6].x , exped[index][6].y})
local index = trailerPlayers[player]["trailerPos"]
setTimer(function(index)
if trailerPosList[index] then
trailerPosList[index] = nil
end
end , 500 , 1 , index)
end
end
end)
function detachTrailer(theTruck, trailer)
if (isElement(theTruck) and isElement(trailer)) then
detachTrailerFromVehicle(theTruck, trailer)
end
end
addEvent("truckMiddMarker" , true)
addEventHandler("truckMiddMarker" , root , function(vehicle)
if trailerPlayers[source] then
if trailerPlayers[source]["trailer"] == getVehicleTowedByVehicle(vehicle) then
exports['infobox']:addBox(source , "success", "Başarıyla dorseyi hedefe ulaştırdın, şimdi başladığın yere geri dön!")
--vehicle:setData("gpsDestination" , {finishPosition.x , finishPosition.y})
destroyElement(trailerPlayers[source]["trailer"])
trailerPlayers[source]["trailer"] = nil
triggerClientEvent(source , "truckDestroyMarker" , source , {finishPosition.x , finishPosition.y})
else
exports['infobox']:addBox(source , "error", "Tırında dorse takılı değil veya takılı olan dorse sana ait değil!")
end
end
end)
addEvent("truckFinish" , true)
addEventHandler("truckFinish" , root , function()
if trailerPlayers[source] then
local miktar = 0 -- boş para
local odul1 = 500
local odul2 = 750
local odul3 = 1100
local odul4 = 1450
local odul5 = 1800
thePlayer = source
local oyuncuBirlik = getPlayerTeam(thePlayer)
local birlikTip = getElementData(oyuncuBirlik, "type")
local birlikLevel = getElementData(oyuncuBirlik, "birlik_level")
local playerFactionID = getElementData(thePlayer, "faction")
local playerFaction = exports.pool:getElement("team", playerFactionID)
local playerFactionType = getElementData(playerFaction, "type")
local playerVehicleFaction = getElementData(getPedOccupiedVehicle(thePlayer), "faction")
-- LOJİSTİK FİRMASI DEĞİŞKENLERİ
if (birlikTip == 5) and (playerVehicleFaction == playerFactionID) then
if birlikLevel == 1 then
miktar = odul1
outputChatBox("-[!]- #ffffff Lojistik Seviyeniz 1 Olduğu İçin Ekstra 500TL Aldın.",source, 255, 0, 0, true)
elseif birlikLevel == 2 then
miktar = odul2
outputChatBox("-[!]- #ffffff Lojistik Seviyeniz 2 Olduğu İçin Ekstra 750TL Aldın.",source, 255, 0, 0, true)
elseif birlikLevel == 3 then
miktar = odul3
outputChatBox("-[!]- #ffffff Lojistik Seviyeniz 3 Olduğu İçin Ekstra 1100TL Aldın.",source, 255, 0, 0, true)
elseif birlikLevel == 4 then
miktar = odul4
outputChatBox("-[!]- #ffffff Lojistik Seviyeniz 4 Olduğu İçin Ekstra 1450TL Aldın.",source, 255, 0, 0, true)
elseif birlikLevel == 5 then
miktar = odul5
outputChatBox(" -[!]- #ffffff Lojistik Seviyeniz 5 Olduğu İçin Ekstra 1800TL Aldın.",source, 255, 0, 0, true)
--[[elseif birlikTip == -1 then
miktar = 2000
outputChatBox("-[!]- Lojistiğin Olmadığı için Ekstra Ödül Alamadın")]]--
end
end
local index = trailerPlayers[source]["index"]
exports['infobox']:addBox(source , "success", "Başarıyla mesleği bitirdin ve hakkın olan "..exped[index][4]+miktar .."TL kazandın!")
exports.global:giveMoney(source, exped[index][4]+miktar )
for k , v in pairs(trailerPlayers) do
v = nil
end
trailerPlayers[source] = nil
end
end)