ok when i go to destanation the car destroyed and i can' see another blip how to fix it?
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()),
function ()
missionXML = xmlLoadFile("truckmissions.xml");
end
)
TruckMissionMarker = createMarker (-76, -1136, 1, "cylinder", 2, 255, 0, 0, 127, getRootElement())
TruckingMinigameBlip = createBlipAttachedTo ( TruckMissionMarker, 51, 2, 0, 0, 255, 255, 0, 250, getRootElement() )
addEventHandler ("onMarkerHit", getRootElement(),
function (hitElement, matchingDim)
if (source == TruckMissionMarker) and (getElementType(hitElement) == "player") then
if not (isGuestAccount (getPlayerAccount (hitElement))) then
local lastTruckMission = getAccountData (getPlayerAccount (hitElement), "lastTruckMission")
if (lastTruckMission) then
preTruckMission (hitElement, tonumber(lastTruckMission)+1)
else
preTruckMission (hitElement, 0)
end
end
end
if (getElementType (hitElement) == "vehicle") and (getElementID (hitElement) == "missiontruck") and (getElementID (source) == "TruckFinishMarker") and (getVehicleOccupant (hitElement)) then
local markerParent = getElementParent (source)
local truckParent = getElementParent (hitElement)
if (markerParent == truckParent) then
local reward = getElementData (markerParent, "reward")
local damage = getElementHealth (hitElement)
local exactReward = (damage / 1000 * reward )
local actualReward = math.round(tonumber(exactReward))
givePlayerMoney (getVehicleOccupant(hitElement), actualReward)
local thePlayer = getVehicleOccupant(hitElement)
outputChatBox ("#00aafftruck Mission:#ffffff Mission passed! You've won $" .. tostring(actualReward) .. "!", getVehicleOccupant(hitElement), 255, 255, 255, true)
destroyElement (markerParent)
triggerClientEvent (thePlayer, "ClientHideTruckMissionGUI", thePlayer)
if not isGuestAccount (getPlayerAccount(thePlayer)) then
local lastTruckMission = getAccountData (getPlayerAccount (thePlayer), "lastTruckMission")
if (lastTruckMission) then
setAccountData ( getPlayerAccount (thePlayer), "lastTruckMission", tonumber(lastTruckMission) +1)
else
setAccountData ( getPlayerAccount (thePlayer), "lastTruckMission", 0)
end
end
end
end
end
)
function preTruckMission (thePlayer, number)
local missionroot = xmlFindChild (missionXML, "mission", number)
if (missionroot) and (xmlNodeGetAttributes (missionroot)) then
local misAtt = xmlNodeGetAttributes (missionroot)
local title = misAtt["title"]
local time = tostring (tonumber(misAtt["time"])) .. " seconds"
local truckname = getVehicleNameFromModel(tonumber(misAtt["truck"]))
local reward = tostring (misAtt["reward"]) .. " $"
local description = xmlNodeGetValue (missionroot)
triggerClientEvent (thePlayer, "ClientStartTruckMission", thePlayer, number, title, time, truckname, description, reward)
else
outputChatBox ("#00aaffTruck Mission:#ffffff All missions sucessfully done", thePlayer, 255, 255, 255, true)
end
end
addEvent ("ServerStartTruckMission", true)
addEventHandler ("ServerStartTruckMission", getRootElement(),
function()
if not (getElementByID (getPlayerNametagText (source) .. "_mission")) then
if not (isGuestAccount (getPlayerAccount (source))) then
local lastTruckMission = getAccountData (getPlayerAccount (source), "lastTruckMission")
if (lastTruckMission) then
number = tonumber(lastTruckMission) +1
else
number = 0
end
end
local missionroot = xmlFindChild (missionXML, "mission", number)
local misAtt = xmlNodeGetAttributes (missionroot)
local title = misAtt["title"]
local time = tonumber(misAtt["time"])
local truckId = tonumber(misAtt["truck"])
local x = tonumber(misAtt["x"])
local y = tonumber(misAtt["y"])
local z = tonumber(misAtt["z"])
local reward = tonumber(misAtt["reward"])
local description = xmlNodeGetValue (missionroot)
local truck = createVehicle (truckId, -81, -1127, 2, 0, 0, 65, "MISSION")
local trailer = createVehicle (584, 0, 0, 0, 0, 0, 0, "MISSION")
attachTrailerToVehicle(truck, trailer)
local destinationMarker = createMarker (x, y, z, "cylinder", 5, 0, 255, 255, 128, source)
destinationBlip = createBlipAttachedTo (destinationMarker, 53, 2, 255, 255, 255, 255, 0, 9999, source )
local truckJobElement = createElement ("truckMission", getPlayerNametagText(source) .. "_mission")
setElementData (truckJobElement, "reward", reward)
warpPedIntoVehicle (source, truck)
setVehicleLocked (truck, true)
setElementData (truck, "TruckMisison", true)
setElementID (truck, "missiontruck")
setElementID (destinationMarker, "TruckFinishMarker")
setElementID (destinationBlip, "TruckDestinationBlip")
setElementParent (truck, truckJobElement)
setElementParent (destinationMarker, truckJobElement)
setElementParent (destinationBlip, truckJobElement)
setElementParent (trailer, truckJobElement)
setTimer(endTruckMission, time*1000, 1, source)
triggerClientEvent (source, "ClientShowTruckMissionGUI", source)
else
outputChatBox ("#00aaffTruck Mission:#ffffff First finish your current mission!", source, 255, 255, 255, true)
end
end
)
function math.round(number, decimals, method)
decimals = decimals or 0
local factor = 10 ^ decimals
if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
else return tonumber(("%."..decimals.."f"):format(number)) end
end