[Release] TruckerJob v0.3 [UPDATE 29th January]

Anybody got it working so that the truck is removed on job completion?

to continue using the truck after drop off change line 103

SetVehicleUndriveable(MISSION.truck, true)
to
SetVehicleUndriveable(MISSION.truck, false)

If they get out it WILL lock behind them,

they can drive back to the truck place and start a new mission but they will have to get out and leave the truck and use a new one that spawns with the job.

2 Likes

Thanks for that, but would prefer to delete the vehicle entirely, still a good alternative.

1st truck instant deletes when starting 2nd job.

Not for me? I must have broken it somehow.

I’ve moved my truckjobs down to the docks and when i started a second job the 1st one disappeared.

1 Like

How can we keep the blip on the minimap when we are at the location to start a job?
i have been trying SetBlipAsShortRange(Blip.company,true)
but that doesn’t seem to be working.

How can I delete the vehicle after completing the mission?

add this function:

function MISSION.DestroyTruck()
SetEntityAsMissionEntity(MISSION.truck, true, true)
Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(MISSION.truck))
MISSION.truck = nil
end

and call the function after the addmoney event, like this:

TriggerServerEvent(“truckerJob:addMoney”, tonumber(currentMission[4]))
TriggerEvent(“mt:missiontext”, “Vous avez gagnĂ© ~g~”
currentMission[4]
 " €", 5000)
MISSION.removeMarker()
MISSION.DestroyTruck()
clear()

just made copy of the folder and make second TruckingCompany rename wiht a 1 in end works so far but somehow i can get only the new TruckingCompany ,in old no menu text show ,anyone know which line is missed?

realy want second TruckingCompany wiht other jobs :frowning:

here the code btw modded it so its only give same trailer and no truck spawn so i can use my own truck

-- v0.3
-- misspellings  fixed
-- Blip fixed
-- added testingmission
-- better button selection (slower)

--use this for debugging
function Chat(t)
	TriggerEvent("chatMessage", 'TRUCKER', { 0, 255, 255}, "" .. tostring(t))
end

--locations
--arrays job {886.318542480469,-889.160400390625,25.6037441253662},
---trailer {857.298767089844,-899.177490234375,24.5359588623047},
--local TruckingCompany = {}
--TruckingCompany[0] = {["x"] = 886.318542480469,["y"] = -889.160400390625, ["z"] = 25.6037441253662}
--local TruckingTrailer = {}
--TruckingTrailer[0] = {["x"] = 873.103942871094,["y"] = -954.31103515625, ["z"] = 25.3825164794922}

local TruckingCompany1 = {}
TruckingCompany1[1] = {["x"] = -579.702819824219,["y"] = 5320.74755859375, ["z"] = 69.3546463012695}
local TruckingTrailer1 = {}
TruckingTrailer1[1] = {["x"] = -596.391540527344,["y"] = 5308.740234375, ["z"] = 69.3195053100586}


--local TruckingCompany = {}
--TruckingCompany[0] = {["x"] = -7.100,["y"] = -0.300, ["z"] = 73.077}
--local TruckingTrailer = {}
--TruckingTrailer[0] = {["x"] = 39.822, ["y"] = 25.884, ["z"] = 72.00}

local Truck = {"HAULER", "PACKER", "PHANTOM"}
local Trailer = {"TRAILERLOGS", "TRAILERLOGS", "TRAILERLOGS", "TRAILERLOGS"}

local MissionData1 = {
--flugfeld12000
    [0] = {-1626.56384277344, -3146.40771484375, 13.0922218322754, 12000},
    [1] = {-1660.08386230469, -3131.49267578125, 13.0922294616699, 12000},
    [2] = {-1921.4755859375, -2994.22216796875, 13.0442749023438, 12000},
    [3] = {-962.844543457031, -2964.90893554688, 13.0450702667236, 12000},
    [4] = {-973.355712890625, -3035.87573242188, 13.0450798034668, 12000},
--hafen12000
    [5] = {141.662216186523, -3088.82690429688, 4.99630889892578, 12000},
    [6] = {138.794769287109, -3196.66870117188, 4.95759258270264, 12000},
    [7] = {-372.7099609375, -2799.32495117188, 5.10030612945557, 12000},
    [8] = {593.899169921875, -2769.830078125, 5.15607032775879, 12000},
    [9] = {1058.40881347656, -3154.00244140625, 5.00077447891235, 12000},
    [10] = {961.650268554688, -3156.20629882813, 5.00080261230469, 12000},
--bergig 12000
    [11] = {2499.04321289063, -331.817413330078, 92.0928359985352, 12000},
    [12] = {2826.08935546875, -720.463439941406, 1.27025256156921, 12000},
    [13] = {-60.7550315856934, 1899.91931152344, 194.782342529297, 12000},
    [14] = {-409.294647216797, 1238.63610839844, 324.741693115234, 12000},
    [15] = {2854.91357421875, 5939.515625, 356.246026611328, 12000},
--powerplant 10000
    [16] = {2829.69140625, 1655.38122558594, 23.7055183410645, 10000},
--bergig 10000
--6000
    [17] = {1730.576171875, 3306.85766601563, 40.3235069274902, 6000},
--8000 nah bereich 
    [18] = {3632.05810546875, 3756.13037109375, 27.615718460083, 8000},
    [19] = {-1816.53527832031, 802.062255859375, 137.579888916016, 8000},
    [20] = {3813.7685546875, 4474.7021484375, 2.75280151367188, 8000},
    [21] = {1730.576171875, 3306.85766601563, 40.3235069274902, 8000},
}
local MISSION = {}
MISSION.start1 = false
MISSION.trailer1 = false
MISSION.truck1 = false

MISSION.hashTruck1 = 0
MISSION.hashTrailer1 = 0

local currentMission1 = -1

local playerCoords1
local playerPed1

local GUI = {}
GUI.loaded          = false
GUI.showStartText   = false
GUI.showMenu        = false
GUI.selected        = {}
GUI.menu            = -1 --current menu

GUI.title           = {}
GUI.titleCount      = 0

GUI.desc            = {}
GUI.descCount       = 0

GUI.button          = {}
GUI.buttonCount     = 0

GUI.time            = 0

--text for mission
local text1 = false
local text2 = false

--blips
local BLIP = {}

BLIP.company = 0

BLIP.trailer = {}
BLIP.trailer.i = 0

BLIP.destination = {}
BLIP.destination.i = 0

--focus button color
local r = 0
local g= 128
local b = 192
local alpha = 200

function clear()    
    MISSION.start1 = false
    SetBlipRoute(BLIP.destination[BLIP.destination.i], false) 
    SetEntityAsNoLongerNeeded(BLIP.destination[BLIP.destination.i])
    
    if ( DoesEntityExist(MISSION.trailer1) ) then
         SetEntityAsNoLongerNeeded(MISSION.trailer1)
    end
    if ( DoesEntityExist(MISSION.truck1) ) then
        -- SetEntityAsNoLongerNeeded(MISSION.truck1)
         --SetVehicleDoorsLocked(MISSION.truck1, 2)
         --SetVehicleUndriveable(MISSION.truck1, true)
    end
    Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(MISSION.trailer1))
    --Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(MISSION.truck1))

    MISSION.trailer1 = 0
    MISSION.truck1 = 0
    MISSION.hashTruck1 = 0
    MISSION.hashTrailer1 = 0
    currentMission1 = -1
end

local initload1 = false
Citizen.CreateThread(function() 
    while true do
       Wait(0)
       playerPed1 = GetPlayerPed(-1)
       playerCoords1 = GetEntityCoords(playerPed1, 0)
        if (not initload1) then
            init()
            initload1 = true
        end
        tick()
    end
    
end)

function init()
  --  BLIP.company = AddBlipForCoord(TruckingCompany[0]["x"], TruckingCompany[0]["y"], TruckingCompany[0]["z"])
   -- SetBlipSprite(BLIP.company, 318)
  --  SetBlipDisplay(BLIP.company, 4)
   -- SetBlipScale(BLIP.company, 0.8)
  --  BeginTextCommandSetBlipName("STRING")
  --  AddTextComponentString('Trucker Jobs')
  --  EndTextCommandSetBlipName(BLIP.company)
    --Citizen.Trace("")
   -- GUI.loaded = true
end

--Draw Text / Menus
function tick()
    
    --debugging stange things
    if ( type(BLIP.trailer[BLIP.trailer.i]) == "boolean" ) then
        --Citizen.Trace("-FAIL!-")
    elseif( BLIP.trailer[BLIP.trailer.i] == nil ) then
        --Citizen.Trace("-nil-")
    else
       BLIP.trailer[BLIP.trailer.i] = BLIP.trailer[BLIP.trailer.i]
       BLIP.destination[BLIP.destination.i] = BLIP.destination[BLIP.destination.i]
    end
    
    
    --Show menu, when player is near
    if( MISSION.start1 == false) then
    if( GetDistanceBetweenCoords( playerCoords1, TruckingCompany1[1]["x"], TruckingCompany1[1]["y"], TruckingCompany1[1]["z"] ) < 10) then
            if(GUI.showStartText == false) then
                GUI.drawStartText()
            end
                --key controlling
                if(IsControlPressed(1, Keys["N+"]) and GUI.showMenu == false) then
                    --clear()
                    GUI.showMenu = true
                    GUI.menu = 0
                end
                if(IsControlPressed(1, Keys["N-"]) and GUI.showMenu == true) then
                    GUI.showMenu = false
                end
            else
                GUI.showStartText = false
        end --if GetDistanceBetweenCoords ...

        --menu
        if( GUI.loaded == false ) then
            GUI.init()
        end

        if( GUI.showMenu == true and GUI.menu ~= -1) then
            if( GUI.time == 0) then
                GUI.time = GetGameTimer()
            end
            if( (GetGameTimer() - GUI.time) > 10) then
                GUI.updateSelectionMenu(GUI.menu)
                GUI.time = 0
            end
            GUI.renderMenu(GUI.menu)
        end --if GUI.loaded == false
    elseif( MISSION.start1 == true ) then
        
        MISSION.markerUpdate(IsEntityAttached(MISSION.trailer1))
        if( IsEntityAttached(MISSION.trailer1) and text1 == false) then
            TriggerEvent("mt:missiontext", "Drive to the marked ~g~destination~w~.", 10000)
            text1 = true
        elseif( not IsEntityAttached(MISSION.trailer1) and text2 == false ) then
            TriggerEvent("mt:missiontext", "Get your ~o~trailer~w~.", 15000)
            text2 = true
        end
        Wait(2000)
        local trailerCoords = GetEntityCoords(MISSION.trailer1, 0)
        if ( GetDistanceBetweenCoords(currentMission1[1], currentMission1[2], currentMission1[3], trailerCoords ) < 5 and  not IsEntityAttached(MISSION.trailer1)) then
            TriggerEvent("mt:missiontext", "You earned $"..currentMission1[4], 5000)
            MISSION.removeMarker()
            TriggerServerEvent('truckerJob:success1',currentMission1[4])
            clear()
        elseif ( GetDistanceBetweenCoords(currentMission1[1], currentMission1[2], currentMission1[3], trailerCoords ) < 5 and IsEntityAttached(MISSION.trailer1) ) then
            TriggerEvent("mt:missiontext", "You have arrived. Press ~r~H~w~ to detach the trailer", 15000)
			MISSION.removeMarker()
        end
        
        if ( IsEntityDead(MISSION.trailer1) ) then
            MISSION.removeMarker()
            clear()
        end
    end --if MISSION.start1 == false
end



---------------------------------------
---------------------------------------
---------------------------------------
----------------MISSON-----------------
---------------------------------------   
---------------------------------------  
---------------------------------------
function GUI.optionMisson(trailerN)
    
    --select trailer
    MISSION.hashTrailer1 = GetHashKey(Trailer[trailerN + 1])
    RequestModel(MISSION.hashTrailer1)
    
    while not HasModelLoaded(MISSION.hashTrailer1) do
        Wait(1)
    end
    
    --select random truck
    local randomTruck = GetRandomIntInRange(1, #Truck)
    
    MISSION.hashTruck1 = GetHashKey(Truck[randomTruck])
	RequestModel(MISSION.hashTruck1)
    
    while not HasModelLoaded(MISSION.hashTruck1) do
        Wait(1)
    end
end

function GUI.mission(missionN)
    --currently one destination per ride
    BLIP.trailer.i = BLIP.trailer.i + 1
    BLIP.destination.i = BLIP.destination.i + 1
    currentMission1 = MissionData1[missionN]
    GUI.showMenu = false
    --mission start
    MISSION.start1 = true
    MISSION.spawnTrailer()
    MISSION.spawnTruck()    
end

function MISSION.spawnTruck()
    
    --MISSION.truck1 = CreateVehicle(MISSION.hashTruck1, 12.1995, -1.174761, 73.000, 0.0, true, false)
    SetVehicleOnGroundProperly(MISSION.trailer1)
   -- SetVehicleNumberPlateText(MISSION.truck1, "M15510")
    --SetVehRadioStation(MISSION.truck1, "OFF")
	--SetPedIntoVehicle(playerPed, MISSION.truck1, -1)
    --SetVehicleEngineOn(MISSION.truck1, true, false, false)
    
    --important
    --SetEntityAsMissionEntity(MISSION.truck1, true, true);
end

function MISSION.spawnTrailer()
    MISSION.trailer1 = CreateVehicle(MISSION.hashTrailer1, TruckingTrailer1[1]["x"], TruckingTrailer1[1]["y"], TruckingTrailer1[1]["z"], 270.0, true, false)
    SetVehicleOnGroundProperly(MISSION.trailer1)
    
    --setMarker on trailer
    MISSION.trailer1Marker()
end

local oneTime = false

function MISSION.trailer1Marker()
    --BLIP.trailer.i = BLIP.trailer.i + 1 this happens in GUI.mission()
    BLIP.trailer[BLIP.trailer.i] = AddBlipForEntity(MISSION.trailer1)
    SetBlipSprite(BLIP.trailer[BLIP.trailer.i], 1)
    SetBlipColour(BLIP.trailer[BLIP.trailer.i], 17)
    SetBlipRoute(BLIP.trailer[BLIP.trailer.i], false)
    Wait(50)
end

function MISSION.markerUpdate(trailerAttached)
    if( not BLIP.destination[BLIP.destination.i] and trailerAttached) then
       -- BLIP.destination.i = BLIP.destination.i + 1 this happens in GUI.mission()
        BLIP.destination[BLIP.destination.i]  = AddBlipForCoord(currentMission1[1], currentMission1[2], currentMission1[3])
        SetBlipSprite(BLIP.destination[BLIP.destination.i], 1)
        SetBlipColour(BLIP.destination[BLIP.destination.i], 2)
        SetBlipRoute(BLIP.destination[BLIP.destination.i], true)
    end
    if( trailerAttached ) then
        SetBlipSprite(BLIP.trailer[BLIP.trailer.i], 2) --invisible
    elseif ( not trailerAttached and BLIP.trailer[BLIP.trailer.i]) then
        SetBlipSprite(BLIP.trailer[BLIP.trailer.i], 1) --visible
        SetBlipColour(BLIP.trailer[BLIP.trailer.i], 17)
    end
    Wait(50)
end

function MISSION.removeMarker()
    SetBlipSprite(BLIP.destination[BLIP.destination.i], 2)--invisible
    SetBlipSprite(BLIP.trailer[BLIP.trailer.i], 2) --invisible
end

function MISSION.getMoney()
   TriggerEvent("es:addedMoney", currentMission1[4])
    TriggerEvent("truckerJob:getMoney", currentMission1[4])
end
---------------------------------------
---------------------------------------
---------------------------------------
-----------------MENU------------------
---------------------------------------   
---------------------------------------  
---------------------------------------
function GUI.drawStartText()
    TriggerEvent("mt:missiontext", "                                                         ~r~ Press ~r~Numpad+~r~ to open the Menu", 500)
    --GUI.showStartText = true
end

function GUI.renderMenu(menu)
    GUI.renderTitle()
    GUI.renderDesc()
    GUI.renderButtons(menu)
end

function GUI.init()
   GUI.loaded = true
    GUI.addTitle("", 0.425, 0.19, 0.45, 0.07 )
    GUI.addDesc("~r~Numpad-~w~ to exit the menu", 0.575, 0.375, 0.15, 0.30 )

    --menu, title, function, position
    --GUI.addButton(0, "RON trailer", GUI.optionMisson, 0.35, 0.25, 0.3, 0.05 )
    --GUI.addButton(0, "Container trailer", GUI.optionMisson, 0.35, 0.30, 0.3, 0.05 )
    --GUI.addButton(0, "Articulated trailer", GUI.optionMisson, 0.35, 0.35, 0.3, 0.05 )
    GUI.addButton(0, "Wood trailer", GUI.optionMisson, 0.35, 0.40, 0.3, 0.05 )
    GUI.addButton(0, "exit menu", GUI.exit, 0.35, 0.95, 0.0, 0.05 )
  --  GUI.addButton(0, "Press num pad - 2 exit menu", GUI.exit, 0.35, 0.50, 0.3, 0.05 )
    
    GUI.buttonCount = 0
    GUI.addButton(1, "", GUI.mission1, 0.35, 0.00, 0.0, 0.01)
    GUI.addButton(1, "Airfield 1 [ 12.000 $ ]", GUI.mission, 0.35, 0.04, 0.3, 0.03)
    GUI.addButton(1, "Airfield 2 [ 12.000 $ ]", GUI.mission, 0.35, 0.08, 0.3, 0.03)
    GUI.addButton(1, "Airfield 3 [ 12.000 $ ]", GUI.mission, 0.35, 0.12, 0.3, 0.03)
    GUI.addButton(1, "Airfield 4 [ 12.000 $ ]", GUI.mission, 0.35, 0.16, 0.3, 0.03)
    GUI.addButton(1, "Airfield 5 [ 12.000 $ ]", GUI.mission, 0.35, 0.20, 0.3, 0.03)
    GUI.addButton(1, "Harbor 1 [ 12.000 $ ]", GUI.mission, 0.35, 0.26, 0.3, 0.03)
    GUI.addButton(1, "Harbor 2 [ 12.000 $ ]", GUI.mission, 0.35, 0.30, 0.3, 0.03)
	GUI.addButton(1, "Harbor 3 [ 12.000 $ ]", GUI.mission, 0.35, 0.34, 0.3, 0.03)
    GUI.addButton(1, "Harbor 4 [ 12.000 $ ]", GUI.mission, 0.35, 0.38, 0.3, 0.03)
	GUI.addButton(1, "Harbor 5 [ 12.000 $ ]", GUI.mission, 0.35, 0.42, 0.3, 0.03)
    GUI.addButton(1, "Harbor 6 [ 12.000 $ ]", GUI.mission, 0.35, 0.46, 0.3, 0.03)
	GUI.addButton(1, "Mountains 1 [ 12.000 $ ]", GUI.mission, 0.35, 0.52, 0.3, 0.03)
    GUI.addButton(1, "Mountains 2 [ 12.000 $ ]", GUI.mission, 0.35, 0.56, 0.3, 0.03)
	GUI.addButton(1, "Mountains 3 [ 12.000 $ ]", GUI.mission, 0.35, 0.60, 0.3, 0.03)
    GUI.addButton(1, "Mountains 4 [ 12.000 $ ]", GUI.mission, 0.35, 0.64, 0.3, 0.03)
	GUI.addButton(1, "Mountains 5 [ 12.000 $ ]", GUI.mission, 0.35, 0.68, 0.3, 0.03)
    GUI.addButton(1, "Powerplant  [ 10.000 $ ]", GUI.mission, 0.35, 0.72, 0.3, 0.03)
	GUI.addButton(1, "Close Range 1 [ 8.000 $ ]", GUI.mission, 0.35, 0.78, 0.3, 0.03)
    GUI.addButton(1, "Close Range 2 [ 8.000 $ ]", GUI.mission, 0.35, 0.82, 0.3, 0.03)
	GUI.addButton(1, "Close Range 3 [ 8.000 $ ]", GUI.mission, 0.35, 0.86, 0.3, 0.03)
    GUI.addButton(1, "Close Range 4 [ 8.000 $ ]", GUI.mission, 0.35, 0.90, 0.3, 0.03)
	GUI.addButton(1, "Close Range 5 [ 8.000 $ ]", GUI.mission, 0.35, 0.94, 0.3, 0.03)
    GUI.addButton(1, "exit menu", GUI.exit, 0.35, 0.97, 0.0, 0.03)
end

--Render stuff
function GUI.renderTitle()
    for id, settings in pairs(GUI.title) do
        local screen_w = 0
        local screen_h = 0
        screen_w, screen_h = GetScreenResolution(0,0)
        boxColor = {0,0,0,0}
		SetTextFont(0)
		SetTextScale(0.0, 0.40)
		SetTextColour(255, 255, 255, 255)
		SetTextCentre(true)
		SetTextDropshadow(0, 0, 0, 0, 0)
		SetTextEdge(0, 0, 0, 0, 0)
		SetTextEntry("STRING")
        AddTextComponentString(settings["name"])
        DrawText((settings["xpos"] + 0.001), (settings["ypos"] - 0.015))
        --AddTextComponentString(settings["name"])
        GUI.renderBox(
            settings["xpos"], settings["ypos"], settings["xscale"], settings["yscale"],
            boxColor[1], boxColor[2], boxColor[3], boxColor[4]
        )
    end
end

function GUI.renderDesc()
		for id, settings in pairs(GUI.desc) do
		local screen_w = 0
		local screen_h = 0
		screen_w, screen_h =  GetScreenResolution(0, 0)
		boxColor = {0,0,0,240}
		SetTextFont(0)
		SetTextScale(0.0, 0.37)
		SetTextColour(255, 255, 255, 255)
		SetTextDropShadow(0, 0, 0, 0, 0)
		SetTextEdge(0, 0, 0, 0, 0)
		SetTextEntry("STRING")
		AddTextComponentString(settings["name"] .. "\n" .."\n" .."Navigate with" .. "\n" .. "arrows." .. "\n" .. "ENTER to Select".. "\n" .."Hold H to Detach" .. "\n" .. "Trailer")
		DrawText((settings["xpos"] - 0.06), (settings["ypos"] - 0.13))
		AddTextComponentString(settings["name"])
		GUI.renderBox(
            settings["xpos"], settings["ypos"], settings["xscale"], settings["yscale"],
            boxColor[1], boxColor[2], boxColor[3], boxColor[4]
        )
		end
end

function GUI.renderButtons(menu)
	for id, settings in pairs(GUI.button[menu]) do
		local screen_w = 0
		local screen_h = 0
		screen_w, screen_h =  GetScreenResolution(0, 0)
		boxColor = {0,0,0,100}
		if(settings["active"]) then
			boxColor = {r,g,b,alpha}
		end
		SetTextFont(0)
		SetTextScale(0.0, 0.37)
		SetTextColour(255, 255, 255, 255)
		SetTextCentre(true)
		SetTextDropShadow(0, 0, 0, 0, 0)
		SetTextEdge(0, 0, 0, 0, 0)
		SetTextEntry("STRING")
		AddTextComponentString(settings["name"])
		DrawText((settings["xpos"] + 0.001), (settings["ypos"] - 0.015))
		--AddTextComponentString(settings["name"])
		GUI.renderBox(
            settings["xpos"], settings["ypos"], settings["xscale"],
            settings["yscale"], boxColor[1], boxColor[2], boxColor[3], boxColor[4]
        )
	 end     
end

function GUI.renderBox(xpos, ypos, xscale, yscale, color1, color2, color3, color4)
	DrawRect(xpos, ypos, xscale, yscale, color1, color2, color3, color4);
end

--adding stuff
function GUI.addTitle(name, xpos, ypos, xscale, yscale)
	GUI.title[GUI.titleCount] = {}
	GUI.title[GUI.titleCount]["name"] = name
	GUI.title[GUI.titleCount]["xpos"] = xpos
	GUI.title[GUI.titleCount]["ypos"] = ypos 	
	GUI.title[GUI.titleCount]["xscale"] = xscale
	GUI.title[GUI.titleCount]["yscale"] = yscale
end

function GUI.addDesc(name, xpos, ypos, xscale, yscale)
	GUI.desc[GUI.descCount] = {}
	GUI.desc[GUI.descCount]["name"] = name
	GUI.desc[GUI.descCount]["xpos"] = xpos
	GUI.desc[GUI.descCount]["ypos"] = ypos 	
	GUI.desc[GUI.descCount]["xscale"] = xscale
	GUI.desc[GUI.descCount]["yscale"] = yscale
end

function GUI.addButton(menu, name, func, xpos, ypos, xscale, yscale)
    if(not GUI.button[menu]) then
        GUI.button[menu] = {}
        GUI.selected[menu] = 0
    end
    GUI.button[menu][GUI.buttonCount] = {}
	GUI.button[menu][GUI.buttonCount]["name"] = name
	GUI.button[menu][GUI.buttonCount]["func"] = func
	GUI.button[menu][GUI.buttonCount]["xpos"] = xpos
	GUI.button[menu][GUI.buttonCount]["ypos"] = ypos 	
	GUI.button[menu][GUI.buttonCount]["xscale"] = xscale
	GUI.button[menu][GUI.buttonCount]["yscale"] = yscale
    GUI.button[menu][GUI.buttonCount]["active"] = 0
    GUI.buttonCount = GUI.buttonCount + 1
end

function GUI.null()
end

function GUI.exit()
    GUI.showMenu = false
	print("Exit menu")
end

--update stuff
function GUI.updateSelectionMenu(menu)
    if( IsControlPressed(0, Keys["DOWN"]) ) then
        if( GUI.selected[menu] < #GUI.button[menu] ) then
            GUI.selected[menu] = GUI.selected[menu] + 1
        end
    elseif( IsControlPressed(0, Keys["TOP"]) ) then
        if( GUI.selected[menu] > 0 ) then
            GUI.selected[menu] = GUI.selected[menu] - 1 
        end
    elseif( IsControlPressed(0, Keys["ENTER"]) ) then
        if( type(GUI.button[menu][GUI.selected[menu]]["func"]) == "function" ) then
            --remember variable GUI.selected[menu]
            
            --call mission functions
            GUI.button[menu][GUI.selected[menu]]["func"](GUI.selected[menu])
            
            GUI.menu = 1
            GUI.selected[menu] = 0
            if( not GUI.menu ) then
                GUI.menu = -1
            end
            Wait(100)
            
            --GUI.button[menu][GUI.selected[menu]]["func"](GUI.selected[menu])
        else
            Citizen.Trace("\n Failes to call function! - Selected Menu: "..GUI.selected[menu].." \n")
        end
        GUI.time = 0
    end
    local i = 0
    for id, settings in ipairs(GUI.button[menu]) do
        GUI.button[menu][i]["active"] = false
        if( i == GUI.selected[menu] ) then
            GUI.button[menu][i]["active"] = true
        end
        i = i + 1
    end
end

can you make the menu little slower plz ?

Everything works, expect it dosn’t give me money?

can anyone help me tie this into vRP framework to give players the money to that wallet system?

Love the script but it is not actually giving people money. It will say +30000 at the top like it does, but never actually updates/deposits the money, any known fixes? I literally haven’t changed the script at all.

Check some above comments, a fix is mentioned there.

What part of your script stops the truck from spawning? I want to make it so people have to have their own truck to do it.

Everytime I edit the code to not spawn a truck, it either doesn’t spawn a truck but the mission blips and everything stop. OR the script just stops

Hi again xD

can you send it to me? :stuck_out_tongue:

job.lua
TriggerServerEvent(‘Job:success’,currentMission[4])

server.lua
RegisterServerEvent(‘Job:success’)
AddEventHandler(‘Job:success’,function(price)
print("user_id = "
user_id)
– Get the players money amount
vRP.getUserId({source},function(user_id)
total = price;
– update player money amount
vRP.giveMoney(user_id,total)
end)
end)

  • Anyone knows whats wrong?

  • i want to use the triggerevent to sent the event to server.lua so it adds money to your “Wallet”

  • Trying to Convert it from ES to vRP

4 Likes

I’ve got the same problem :confused:
Any help please? :frowning:

can someone tell me why i only see a " armored van " blip on the map and there is nothing, that’s the only thing that truckingjob does on my server, any pointers?