Jump to content

[HELP]Task Problem


carli

Recommended Posts

hi I found the mechanic Task System I've done a little bit, but there is a problem problem when I started the task, the marker comes, I'm pulling the tool after the end marker does not give the marker after the end I want to give the marker again I want to leave the code if you help


 

arac_blip = {
    {2216.41846, -1967.56018, 13.39062},
    {2214.03809, -1935.79236, 13.40592},
   
}
   
    
binecegi_arac = {
    [525] = true,  
    }

hasOrder = false
lastLoc = 0  
distance = 0


function startMission (player, seat)
    local job = exports.GTIemployment:getPlayerJob(true)
    if (job == "Mechanic" and seat == 0) then
        if (binecegi_arac[getElementModel(source)] and hasOrder == false and player == localPlayer) then
          local division = getElementData(player, "division")
         loc = math.random(#arac_blip)
                if (loc == lastLoc) then
                    startMission(player, seat)
                    return
                end
        delX, delY, delZ = arac_blip[loc][1], arac_blip[loc][2], arac_blip[loc][3]
        theVehicle = createVehicle(415, delX, delY, delZ + 5)
        theMarker = createMarker(delX, delY, delZ, "cylinder", 5, 255, 200, 0, 150)
        delBlip = createBlip(delX, delY, delZ, 55)
        zone = getZoneName(delX, delY, delZ, false)
        exports.GTIhud:dm("Çekilmesi gereken bir araba var "..zone, 0, 200, 0)
        x, y, z = getElementPosition(localPlayer)
        distance = getDistanceBetweenPoints2D(delX, delY, x, y)
        hasOrder = true
        setElementData(localPlayer, "GTItrucker.HasOrder", true)
        lastLoc = loc
        addEventHandler("onClientMarkerHit", theMarker, deliverCar)
    end
end
end
addEventHandler("onClientVehicleEnter", root, startMission)

function deliverCar(hitElement)
    if (isElement(theVehicle) and isPedInVehicle(hitElement) and getElementModel(getPedOccupiedVehicle(hitElement)) == 525) then
        if (hitElement == localPlayer) then
            if (isElement(theMarker)) then
                destroyElement(theMarker)
            end
            if (isElement(delBlip)) then
                destroyElement(delBlip)
            end
            local plr = getVehicleOccupant(getPedOccupiedVehicle(localPlayer))
            if (isElement(plr)) then
                delMarker = createMarker(2196.235, -1977.568, 12.55, "cylinder", 3, 255, 200, 0, 150)
                delBlip = createBlip(2196.235, -1977.568, 12.55, 41)
                exports.GTIhud:dm("Görevinizi tamamlamak için haritanızdaki blip araba çekin.", 0, 200, 0)
                addEventHandler("onClientMarkerHit", delMarker, completeMission)

            end
        end    
    end
end

function completeMission(hitElement)    
    if (isElement(hitElement) and isPedInVehicle(hitElement) and getElementModel(getPedOccupiedVehicle(hitElement)) == 525) then
        if (hitElement == localPlayer) then
            local veh = getPedOccupiedVehicle(localPlayer)
            local dis = exports.GTIutil:getDistanceBetweenElements2D(veh, theVehicle)
            if (dis > 100) then return end
            if (isElement(theVehicle)) then
                detachTrailerFromVehicle(getPedOccupiedVehicle(localPlayer), theVehicle)
                destroyElement(theVehicle)
            end
            
            if (isElement(delMarker)) then
                destroyElement(delMarker)
            end
            if (isElement(delBlip)) then
                destroyElement(delBlip)
            end
            
            local plr = getVehicleOccupant(getPedOccupiedVehicle(localPlayer))
            exports.GTIhud:dm("Başarıyla arabayı çektin ve Los Santos sokaklarını temizledin", 0, 200, 0)
            local payment = distance
            triggerServerEvent("GTImechanic.completeMission", localPlayer, localPlayer, payment)
            
            hasOrder = false
        end    
    end
end    

function onQuitJob(job, bool)
    if (job == "Mechanic" and hasOrder) then
        if (source == localPlayer) then
            if (isElement(theVehicle)) then
                destroyElement(theVehicle)
            end
                
            if (isElement(delMarker)) then
                destroyElement(delMarker)
            end
            if (isElement(delBlip)) then
                destroyElement(delBlip)
            end
            if (isElement(theMarker)) then
                destroyElement(theMarker)
            end
            hasOrder = false
        end    
    end
end
addEventHandler("onClientPlayerQuitJob", root, onQuitJob)    


 



Edited by carli
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...