Skip to content

Commit

Permalink
v1.3 adds the possibility to force quit the job
Browse files Browse the repository at this point in the history
  • Loading branch information
lama-development authored Jun 6, 2023
1 parent fb5498b commit 78d42b1
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
31 changes: 29 additions & 2 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function StartJob()
-- choose random trailer model
local model = math.randomchoice(Config.TrailerModels)
-- add trailer blip to map
local blip = AddBlipForCoord(location.x, location.y, location.z)
blip = AddBlipForCoord(location.x, location.y, location.z)
SetBlipSprite(blip, 479)
SetBlipColour(blip, 26)
SetBlipRoute(blip, true)
Expand All @@ -77,9 +77,18 @@ function StartJob()
end
trailer = SpawnTrailer(model, location)
DisplayNotification("~b~New task: ~w~pick up the trailer at the marked location.")
jobStarted = true
if Config.UseND then
DisplayNotification("Long press ~r~SHIFT~w~ + ~r~X~w~ at any time to force-cancel the job and pay a penalty.")
else
DisplayNotification("Long Press ~r~SHIFT~w~ + ~r~X~w~ at any time to force-cancel the job.")
end
while true do
opti = 2
-- check if forcequit
if IsControlPressed(1, 73) then
ForceQuit()
break
end
-- gets distance between player and trailer location and check if player is in the vicinity of it
if #(playerCoords - vector3(location.x, location.y, location.z)) <= 20 then
-- and check if they have picked up the trailer
Expand Down Expand Up @@ -107,6 +116,11 @@ function DeliverTrailer()
DisplayNotification("~b~New task: ~w~deliver the trailer at the marked location.")
while true do
opti = 2
-- check if forcequit
if IsControlPressed(1, 73) then
ForceQuit()
break
end
-- gets distance between player and task location and check f player is in the vicinity of it
if #(playerCoords - vector3(location.x, location.y, location.z)) <= 20 then
DisplayHelpTextThisFrame("press_detach_trailer")
Expand Down Expand Up @@ -186,6 +200,19 @@ function EndJob()
end
end

function ForceQuit()
DeleteVehicle(GetVehiclePedIsIn(PlayerPedId(), false))
DeleteVehicle(trailer)
RemoveBlip(blip)
if Config.UseND then
TriggerServerEvent("lama_jobs:forcequit")
DisplayNotification("You've been fined ~r~$" .. Config.Penalty .. " ~w~for cancelling the job.")
else
DisplayNotification("~r~You've cancelled the job.")
end
amount = 0
end

-- function to spawn vehicle at desired location
function SpawnVehicle(model, location)
RequestModel(model)
Expand Down
4 changes: 4 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Config.UseND = true
-- Only works if you set UseND to true, otherwise leave this as it is
Config.PayPerDelivery = 750

-- Set the amount of money the player will be fined for cancelling the job
-- Only works if you set UseND to true, otherwise leave this as it is
Config.Penalty = 250

-- Set the truck model name used for the job
Config.TruckModel = 'phantom'

Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name 'TruckJob'
description 'Work as a truck driver'
author 'Lama#9612'
version '1.2'
version '1.3'

fx_version 'cerulean'
game 'gta5'
Expand Down
6 changes: 6 additions & 0 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ RegisterNetEvent("lama_jobs:finished", function()
end
end)

RegisterNetEvent("lama_jobs:forcequit", function()
local src = source
local penalty = Config.Penalty
NDCore.Functions.DeductMoney(penalty, src, "bank")
end)

-- version checker
Citizen.CreateThread(function()
updatePath = "/lama-development/TruckJob"
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2
1.3

0 comments on commit 78d42b1

Please sign in to comment.