Jump to content

Occupation tool problem


aunque

Recommended Posts

I prepared a job script in this way, but the last markers are accepted even if they are entered with different tools and that marker 
does not disappear, how can I solve this?
 
 
 
kargo_arac = {}
kargo_teslim = {}
 
function meslekbitis(source)
    if source then
        if isElement(kargo_arac[source]) then
            destroyElement(kargo_arac[source])
            destroyElement(meslekbitis_marker)
            setElementData(source, "kargo:meslek", false)
            setElementData(source, "meslek", false)
            local para = 123
            givePlayerMoney(source, para)
        end
    end  
end
addEvent("meslek:basla", true)
addEventHandler("meslek:basla", root, function()
    setElementData(source, "kargo:meslek", true)
    setElementData(source, "meslek", true)
    kargo_arac[source] = createVehicle(456, -29.71848, -1122.65125, 1.07812)
    warpPedIntoVehicle(source, kargo_arac[source])
    setVehicleLocked(kargo_arac[source], true)
    local meslekbitis_marker = createMarker(-157.16824, -282.63116, 3.90531, "checkpoint", 2.5 , 255, 185, 15)
    addEventHandler("onMarkerHit", meslekbitis_marker, meslekbitis)
    kargobitis_blips = createBlip(-157.16824, -282.63116, 3.90531, 56)
   
end)





 
Link to comment

hello @aunque welcome to the forum, i made some edits about the system,can you try this.

kargo_arac = {}
kargo_teslim = {}

local meslekbitis_marker
local kargobitis_blips

function meslekbitis(hitElement, matchingDimension)
    if(getElementType(hitElement) == "player") then
       local jobVehicle = getPedOccupiedVehicle(hitElement)
       if(jobVehicle) then
          if(kargo_arac[jobVehicle]) then
             destroyElement(kargo_arac[jobVehicle])
             destroyElement(meslekbitis_marker)
             destroyElement(kargobitis_blips)
             setElementData(hitElement, "kargo:meslek", false)
             setElementData(hitElement, "meslek", false)
             givePlayerMoney(hitElement, 123)
          end
       end
    end
end

addEvent("meslek:basla", true)
addEventHandler("meslek:basla", root, function()
    setElementData(source, "kargo:meslek", true)
    setElementData(source, "meslek", true)
    kargo_arac[source] = createVehicle(456, -29.71848, -1122.65125, 1.07812)
    warpPedIntoVehicle(source, kargo_arac[source])
    setVehicleLocked(kargo_arac[source], true)
    meslekbitis_marker = createMarker(-157.16824, -282.63116, 3.90531, "checkpoint", 2.5 , 255, 185, 15)
    kargobitis_blips = createBlip(-157.16824, -282.63116, 3.90531, 56)
    addEventHandler("onMarkerHit", meslekbitis_marker, meslekbitis)
end)

 

i edits the code, check again

Edited by Shady1
kodu düzeltttim
Link to comment
kargo_arac = {}
kargo_teslim = {}

local meslekbitis_marker
local kargobitis_blips

function meslekbitis(hitElement, matchingDimension)
    if(getElementType(hitElement) == "vehicle") then
       if(kargo_arac[hitElement]) then
          local player = getVehicleOccupant(hitElement)
          destroyElement(kargo_arac[hitElement])
          destroyElement(meslekbitis_marker)
          destroyElement(kargobitis_blips)
          setElementData(player, "kargo:meslek", false)
          setElementData(player, "meslek", false)
          givePlayerMoney(player, 123) 
       end
    end
end

addEvent("meslek:basla", true)
addEventHandler("meslek:basla", root, function()
    setElementData(source, "kargo:meslek", true)
    setElementData(source, "meslek", true)
    kargo_arac[source] = createVehicle(456, -29.71848, -1122.65125, 1.07812)
    warpPedIntoVehicle(source, kargo_arac[source])
    setVehicleLocked(kargo_arac[source], true)
    meslekbitis_marker = createMarker(-157.16824, -282.63116, 3.90531, "checkpoint", 2.5 , 255, 185, 15)
    kargobitis_blips = createBlip(-157.16824, -282.63116, 3.90531, 56)
    addEventHandler("onMarkerHit", meslekbitis_marker, meslekbitis)
end)

 

try this code

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...