This commit is contained in:
Hawk 2024-12-29 21:06:22 +01:00
parent 5301ff838d
commit 246996f2d9
No known key found for this signature in database
GPG Key ID: 2890D5366F8BAC14
472 changed files with 64373 additions and 0 deletions

View File

@ -0,0 +1,2 @@
# cad-diving
Sunken Ship Diving Script for QBCore (Legacy Inspired)

View File

@ -0,0 +1,73 @@
QBCore = exports['qb-core']:GetCoreObject()
local locations = {
[1] = {x = 3144.94, y = -280.54, z = -10.31},
[2] = {x = 3151.75, y = -286.02, z = -27.16},
[3] = {x = 3127.14, y = -341.26, z = -23.14},
[4] = {x = 3162.18, y = -357.39, z = -27.6},
[5] = {x = 3195.47, y = -388.18, z = -32.16},
[6] = {x = 3188.67, y = -395.82, z = -27.51},
[7] = {x = 3221.45, y = -405.6, z = -48.48},
[8] = {x = 3192.30, y = -385.23, z = -16.81},
}
local normal = {
[1] = {item = 'steel'},
[2] = {item = 'iron'},
[3] = {item = 'plastic'},
}
local rare = {
[1] = {item = 'goldbar'},
[2] = {item = 'diamond'},
}
local pickup = math.random(1, #locations)
Citizen.CreateThread(function()
Wait(1000)
CreateBlip()
while true do
inRange = false
x = locations[pickup].x
y = locations[pickup].y
z = locations[pickup].z
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
local distance = #(vector3(coords.x, coords.y, coords.z) - vector3(x, y, z))
if distance < 250 then
inRange = true
if distance > 3 then
QBCore.Functions.DrawText3D(x, y, z, "Distance: "..(math.floor(distance*10)/10).."m")
else
pickup = math.random(1, #locations)
local random = math.random(1, 1000)
if random > 0 and random < 600 then
TriggerServerEvent("cad-diving:collected", "normal", normal[math.random(1,#normal)].item, math.random(1, 4))
elseif random > 980 and random < 1000 then
TriggerServerEvent("cad-diving:collected", "rare", rare[math.random(1,#rare)].item, 1)
else
TriggerServerEvent("cad-diving:collected", "none", nil)
end
Citizen.Wait(2000)
end
end
if inRange then
Citizen.Wait(4)
else
Citizen.Wait(2000)
end
end
end)
function CreateBlip()
local divingblip = AddBlipForCoord(3146.24, -280.84, -8.44)
SetBlipSprite(divingblip, 465)
SetBlipDisplay(diving, 4)
SetBlipScale(divingblip, 0.9)
SetBlipColour(divingblip, 3)
SetBlipAsShortRange(divingblip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString('Sunket skib')
EndTextCommandSetBlipName(divingblip)
end

View File

@ -0,0 +1,7 @@
fx_version 'cerulean'
game "gta5"
author "Cadburry#7547"
client_script "cl_diving.lua"
server_script 'sv_diving.lua'

View File

@ -0,0 +1,17 @@
QBCore = exports['qb-core']:GetCoreObject()
RegisterServerEvent("cad-diving:collected")
AddEventHandler("cad-diving:collected", function(type, item, count)
local xPlayer = QBCore.Functions.GetPlayer(source)
if xPlayer ~= nil then
if type == "normal" then
xPlayer.Functions.AddItem(item, count)
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items[item], "add")
elseif type == "rare" then
xPlayer.Functions.AddItem(item, count)
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items[item], "add")
else
TriggerClientEvent("QBCore:Notify", source, "Du fangede intet")
end
end
end)

View File

@ -0,0 +1,15 @@
# Postal Op Delivery Job
This is a job where you sign in near the postal op and put in a deposit for a truck which will be used to deliver packages to store, banks, etc
# Dependencies
- qb-core
- qb-target
- PolyZone
# How to install?
- Download latest version from releases
- Put in resources and ensure in server.cfg
- Thats all!
# Support
Join Discord: https://discord.gg/qxGPARNwNP

View File

@ -0,0 +1,283 @@
local QBCore = exports['qb-core']:GetCoreObject()
--===================================================
-- LOCALS
--===================================================
local currentJob = {}
local onJob = false
local onDelivery = false
local goPostalVehicle = nil
local currentJobPay = 0
local totalpayamount = 0
local MaxDelivery = 0
local PackageObject = nil
local missionblip = nil
local isDeliverySignedIn = false
local PlayerJob = {}
--===================================================
-- CONFIG
--===================================================
local locations = Config.deliveryLocations
local vehicleSpawnLocations = Config.vehicleSpawnLocations
--===================================================
-- FUNCTIONS
--===================================================
CreateThread(function()
local bCfg = Config.blip
PostalBlip = AddBlipForCoord(bCfg.coords)
SetBlipSprite(PostalBlip, bCfg.sprite)
SetBlipScale(PostalBlip, bCfg.scale)
SetBlipDisplay(PostalBlip, 4)
SetBlipColour(PostalBlip, bCfg.color)
SetBlipAsShortRange(PostalBlip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(bCfg.label)
EndTextCommandSetBlipName(PostalBlip)
end)
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
PlayerJob = QBCore.Functions.GetPlayerData().job
end)
RegisterNetEvent('QBCore:Client:OnJobUpdate', function()
PlayerJob = QBCore.Functions.GetPlayerData().job
end)
AddEventHandler('onResourceStart', function(resourceName)
if GetCurrentResourceName() == resourceName then
PlayerJob = QBCore.Functions.GetPlayerData().job
end
end)
function NewDeliveryShift()
if MaxDelivery >= 0 then
local jobLocation = locations[math.random(1, #locations)]
SetDeliveryJobBlip(jobLocation[1], jobLocation[2], jobLocation[3])
currentJob = jobLocation
currentJobPay = CalculateTravelDistanceBetweenPoints(GetEntityCoords(goPostalVehicle), currentJob[1],
currentJob[2], currentJob[3]) / 2 / 4
if currentJobPay > 60 then
currentJobPay = math.random(1200, 1500)
end
QBCore.Functions.Notify("Kør til næste leverings punkt!")
else
onJob = false
RemoveJobBlip()
SetNewWaypoint(-425.44, -2787.76, 6.0)
QBCore.Functions.Notify("Du er færdig! Kør tilbage til depottet.")
end
end
function SpawnGoPostal(x, y, z, h)
local vehicleHash = GetHashKey(Config.vehicleModel)
RequestModel(vehicleHash)
while not HasModelLoaded(vehicleHash) do
Wait(0)
end
goPostalVehicle = CreateVehicle(vehicleHash, x, y, z, h, true, false)
local id = NetworkGetNetworkIdFromEntity(goPostalVehicle)
SetNetworkIdCanMigrate(id, true)
SetNetworkIdExistsOnAllMachines(id, true)
SetVehicleDirtLevel(goPostalVehicle, 0)
SetVehicleHasBeenOwnedByPlayer(goPostalVehicle, true)
SetEntityAsMissionEntity(goPostalVehicle, true, true)
SetVehicleEngineOn(goPostalVehicle, true)
SetVehicleColours(goPostalVehicle, 131, 74)
TaskWarpPedIntoVehicle(PlayerPedId(), goPostalVehicle, -1)
TriggerEvent('vehiclekeys:client:SetOwner', GetVehicleNumberPlateText(goPostalVehicle))
exports['qb-fuel']:SetFuel(goPostalVehicle, 100.0)
end
function getParkingPosition(spots)
for id, v in pairs(spots) do
if GetClosestVehicle(v.x, v.y, v.z, 3.0, 0, 70) == 0 then
return true, v
end
end
QBCore.Functions.Notify("Parkeringspladsen er fuld, vent venligst.")
end
function SetDeliveryJobBlip(x, y, z)
if DoesBlipExist(missionblip) then RemoveBlip(missionblip) end
missionblip = AddBlipForCoord(x, y, z)
SetBlipSprite(missionblip, 164)
SetBlipColour(missionblip, 53)
SetNewWaypoint(x, y)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("Destination")
EndTextCommandSetBlipName(missionblip)
end
function RemoveJobBlip()
if DoesBlipExist(missionblip) then RemoveBlip(missionblip) end
end
function LoadAnim(animDict)
RequestAnimDict(animDict)
while not HasAnimDictLoaded(animDict) do
Wait(10)
end
end
function LoadModel(model)
RequestModel(model)
while not HasModelLoaded(model) do
Wait(10)
end
end
--===================================================
-- JOB WORK
--===================================================
CreateThread(function()
local pedModel = GetHashKey(Config.pedModel)
RequestModel(pedModel)
while not HasModelLoaded(pedModel) do
Wait(1)
end
local ped = CreatePed(4, pedModel, Config.pedCoords.x, Config.pedCoords.y, Config.pedCoords.z,
Config.pedCoords.w, false, false)
SetBlockingOfNonTemporaryEvents(ped, true)
SetPedDiesWhenInjured(ped, false)
SetEntityHeading(ped, Config.pedCoords.w)
SetPedCanPlayAmbientAnims(ped, true)
SetPedCanRagdollFromPlayerImpact(ped, false)
SetEntityInvincible(ped, true)
FreezeEntityPosition(ped, true)
if PlayerJob.name == Config.JobName then
exports['qb-target']:AddTargetModel('s_m_m_postal_01', {
options = {
{
type = "client",
event = "cad-postalop:startwork",
icon = "fas fa-sign-in-alt",
label = "Gå på arbejde",
canInteract = function(entity, data)
return not isDeliverySignedIn
end,
},
{
type = "client",
event = "cad-postalop:finishwork",
icon = "fas fa-money-check-alt",
label = "Modtag løn og afslut arbejde",
canInteract = function(entity, data)
return isDeliverySignedIn
end,
},
},
distance = 1.5
})
end
exports['qb-target']:AddTargetBone('boot', {
options = {
{
type = "client",
event = "cad-postalop:takepackage",
icon = "fas fa-box",
label = "Tag pakke",
canInteract = function(entity, data)
return onJob and (entity == goPostalVehicle)
end,
}
},
distance = 2.5,
})
end)
CreateThread(function()
while true do
local inRange = false
if isDeliverySignedIn then
if (GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), currentJob[1], currentJob[2], currentJob[3], true) < 50) and onJob and onDelivery then
inRange = true
DrawMarker(2, currentJob[1], currentJob[2], currentJob[3], 0, 0, 0, 0, 0, 0, 0.3, 0.2, -0.2, 100, 100,
155, 255, true, true, 0, 0)
if (GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), currentJob[1], currentJob[2], currentJob[3], true) < 1.5) and onJob and onDelivery then
LoadAnim("creatures@rottweiler@tricks@")
TaskPlayAnim(PlayerPedId(), "creatures@rottweiler@tricks@", "petting_franklin", 8.0, 8.0, -1, 50, 0,
false, false, false)
FreezeEntityPosition(PlayerPedId(), true)
Wait(5000)
DeleteObject(PackageObject)
FreezeEntityPosition(PlayerPedId(), false)
ClearPedTasksImmediately(PlayerPedId())
PackageObject = nil
onDelivery = false
totalpayamount = totalpayamount + currentJobPay
MaxDelivery = MaxDelivery - 1
NewDeliveryShift()
end
end
end
if not inRange then
Wait(1000)
end
Wait(4)
end
end)
RegisterNetEvent('cad-postalop:startwork', function()
if not isDeliverySignedIn and not onJob then
if not DoesEntityExist(goPostalVehicle) then
local freespot, v = getParkingPosition(vehicleSpawnLocations)
if freespot then SpawnGoPostal(v.x, v.y, v.z, v.h) end
MaxDelivery = math.random(2, 8)
NewDeliveryShift()
onJob = true
isDeliverySignedIn = true
else
QBCore.Functions.Notify("Du har allerede et køretøj!")
end
else
QBCore.Functions.Notify("Du er allerede igang med et job, færdiggør det først.")
end
end)
RegisterNetEvent('cad-postalop:takepackage', function()
if not onDelivery and onJob and not IsPedInAnyVehicle(PlayerPedId()) and GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), currentJob[1], currentJob[2], currentJob[3], true) < 40 then
LoadModel("hei_prop_heist_box")
local pos = GetEntityCoords(PlayerPedId(), false)
PackageObject = CreateObject(GetHashKey("hei_prop_heist_box"), pos.x, pos.y, pos.z, true, true, true)
AttachEntityToEntity(PackageObject, PlayerPedId(), GetPedBoneIndex(PlayerPedId(), 28422), 0.0, -0.03, 0.0, 5.0,
0.0, 0.0, 1, 1, 0, 1, 0, 1)
LoadAnim("anim@heists@box_carry@")
TaskPlayAnim(PlayerPedId(), "anim@heists@box_carry@", "idle", 8.0, 8.0, -1, 50, 0, false, false, false)
onDelivery = true
end
end)
RegisterNetEvent('cad-postalop:finishwork', function()
if isDeliverySignedIn then
if not onJob then
if DoesEntityExist(goPostalVehicle) then
DeleteVehicle(goPostalVehicle)
RemoveJobBlip()
if IsVehicleDamaged(goPostalVehicle) then
totalpayamount = totalpayamount - 1000
QBCore.Functions.Notify("Din lastbil blev beskadiget, du er blevet trukket 1000,- for at dække skaderne.")
end
isDeliverySignedIn = false
onJob = false
TriggerServerEvent('cad-delivery:cash', totalpayamount, 0)
Wait(500)
totalpayamount = 0
else
isDeliverySignedIn = false
onJob = false
QBCore.Functions.Notify("Den lastbil var altså dyr... Du får ingen løn denne omgang.")
end
else
QBCore.Functions.Notify("Du er nødt til at afslutte dit job først.")
end
else
QBCore.Functions.Notify("Gå på arbejde før du kan få dine penge!")
end
end)
--===================================================
-- END
--===================================================s

View File

@ -0,0 +1,44 @@
Config = {}
Config.blip = {
label = 'HPNord',
coords = vector3(-425.44, -2787.76, 6.0),
sprite = 304,
scale = 0.5,
color = 10
}
Config.JobName = "delivery"
Config.pedModel = 's_m_m_postal_01'
Config.pedCoords = vector4(-425.44, -2787.76, 5.0, 326.65)
Config.vehicleModel = 'benson'
Config.vehicleSpawnLocations = {
{ x = -446.24, y = -2789.72, z = 5.96, h = 46.04 },
{ x = -451.24, y = -2793.8, z = 5.96, h = 47.51 },
{ x = -455.8, y = -2798.48, z = 5.96, h = 44.91 }
}
Config.deliveryLocations = {
[1] = { 441.12, -981.12, 30.68 },
[2] = { 306.72, -594.88, 43.28 },
[3] = { -37.2, -1110.36, 26.44 },
[4] = { -267.08, -955.64, 31.24 },
[5] = { -1200.36, -891.12, 14.0 },
[6] = { -705.72, -906.68, 19.2 },
[7] = { 26.04, -1339.24, 29.48 },
[8] = { -41.52, -1752.52, 29.44 },
[9] = { -534.64, -165.96, 38.32 },
[10] = { -633.08, 233.88, 81.88 },
[11] = { 246.92, 222.2, 106.28 },
[12] = { 375.64, 333.72, 103.56 },
[13] = { 314.48, -278.6, 54.16 },
[14] = { 149.44, -1040.0, 29.36 },
[15] = { -1081.96, -248.24, 37.76 },
[16] = { -350.76, -48.84, 49.04 },
[17] = { -1484.2, -380.24, 40.16 },
[18] = { 2550.24, 382.0, 108.64 },
[19] = { -1816.56, -1193.48, 14.32 },
[20] = { -2966.64, 388.0, 15.04 },
}

View File

@ -0,0 +1,19 @@
fx_version 'cerulean'
game "gta5"
lua54 'yes'
author "Cadburry"
description "Postal Op Job which uses qb-target & polyzone"
version "1.1"
shared_scripts {
'config.lua',
}
server_script 'server.lua'
client_script 'client.lua'
files {
'handling.meta',
}
data_file 'HANDLING_FILE' 'handling.meta'

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<CHandlingDataMgr>
<HandlingData>
<Item type="CHandlingData">
<handlingName>benson</handlingName>
<fMass value="5500.000000" />
<fInitialDragCoeff value="6.000000" />
<fPercentSubmerged value="80.000000" />
<vecCentreOfMassOffset x="0.000000" y="0.000000" z="0.000000" />
<vecInertiaMultiplier x="2.800000" y="2.500000" z="3.500000" />
<fDriveBiasFront value="0.000000" />
<nInitialDriveGears value="4" />
<fInitialDriveForce value="0.300000" />
<fDriveInertia value="1.000000" />
<fClutchChangeRateScaleUpShift value="1.300000" />
<fClutchChangeRateScaleDownShift value="1.300000" />
<fInitialDriveMaxFlatVel value="100.000000" />
<fBrakeForce value="0.250000" />
<fBrakeBiasFront value="0.600000" />
<fHandBrakeForce value="0.300000" />
<fSteeringLock value="31.000000" />
<fTractionCurveMax value="1.600000" />
<fTractionCurveMin value="1.400000" />
<fTractionCurveLateral value="13.000000" />
<fTractionSpringDeltaMax value="0.150000" />
<fLowSpeedTractionLossMult value="0.500000" />
<fCamberStiffnesss value="0.000000" />
<fTractionBiasFront value="0.420000" />
<fTractionLossMult value="1.000000" />
<fSuspensionForce value="1.700000" />
<fSuspensionCompDamp value="1.200000" />
<fSuspensionReboundDamp value="1.400000" />
<fSuspensionUpperLimit value="0.110000" />
<fSuspensionLowerLimit value="-0.140000" />
<fSuspensionRaise value="0.000000" />
<fSuspensionBiasFront value="0.550000" />
<fAntiRollBarForce value="0.350000" />
<fAntiRollBarBiasFront value="0.300000" />
<fRollCentreHeightFront value="0.600000" />
<fRollCentreHeightRear value="0.600000" />
<fCollisionDamageMult value="1.700000" />
<fWeaponDamageMult value="1.000000" />
<fDeformationDamageMult value="1.500000" />
<fEngineDamageMult value="1.500000" />
<fPetrolTankVolume value="75.000000" />
<fOilVolume value="6.000000" />
<fSeatOffsetDistX value="0.000000" />
<fSeatOffsetDistY value="0.000000" />
<fSeatOffsetDistZ value="0.000000" />
<nMonetaryValue value="25000" />
<strModelFlags>224048</strModelFlags>
<strHandlingFlags>0</strHandlingFlags>
<strDamageFlags>0</strDamageFlags>
<AIHandling>TRUCK</AIHandling>
<SubHandlingData>
<Item type="NULL" />
<Item type="NULL" />
<Item type="NULL" />
</SubHandlingData>
</Item>
</HandlingData>
</CHandlingDataMgr>

View File

@ -0,0 +1,18 @@
local QBCore = exports['qb-core']:GetCoreObject()
--===================================================
-- JOB CASH
--===================================================
RegisterNetEvent('cad-delivery:cash', function(currentJobPay, value)
local _source = source
local Player = QBCore.Functions.GetPlayer(_source)
local job = Player.PlayerData.job.name
if value ~= 0 then
--User triggering anti-cheat
DropPlayer(_source, "Anti-cheat triggered")
else
if job == Config.JobName then
Player.Functions.AddMoney("bank", currentJobPay, "HPNord Indbetaling")
TriggerClientEvent("QBCore:Notify", _source, "Du modtog en indbetaling på " .. currentJobPay..",-")
end
end
end)

View File

@ -0,0 +1,2 @@
/test
watch.cjs

View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -0,0 +1,223 @@
![Keep oilwell](https://raw.githubusercontent.com/swkeep/keep-oilwell/main/.github/images/banner3.png)
# Preview
- [Youtube video](https://youtu.be/lGgsUonmXmw)
# Dependencies
- [qb-target](https://github.com/BerkieBb/qb-target)
- [qb-menu](https://github.com/qbcore-framework/qb-menu)
# Key Features
- NoPixel inspired oil company
- Owning oilwells
- ...
## Patch 1.1.0 (employees)
- new notifications when an oilwell part breaks.
- oilwell owners can employ a person to operate their oilwells for them. (employees have access to crude oil transfer, but when they use it, it sends available oil to the owner's storage, not the employee's storage.)
- employees should have `oilwell` job.
- owners can fire their employees at will employees access will be revoked immediately.
- removed some data which should not be available on client-side.
- added script loading report.
- the CEO have ability to remove any oilwell from now on (this is not a permanent removal therefore oil wells are just flagged as deleted for easy recovery).
- information menu is now recives data directly from server.
### How to update to new patch (database changes):
- 1. update your `oilrig_position` by using ALTER TABLE available at end of sql.sql
- 2. import new table `oilcompany_employees`
## Patch 1.0.0
- (important) if you are using old version make sure you have a backup.
- balanced oil production for 1 hour
- to be able to operate oilwells players must be on duty
- oilwells now take damege and players should fix them or they will stop working
- new items to fix oilwells
- transport accepts all oil types
- new oil types
- blender new formula and new elemnts
- qb-target won't despawn with objects
- fixed qb-target not showing up
- fixed props blinking
- fixed props not spawning if players don't have oilwell job
- better check for job and onduty
- new withdraw system
- withdraw purge menu
- added octane calculation
- showing oilwell prop before assigning them
- oilbarell props
- to be honest there was so many changes i don't remember most of them!
## Usage
- add oilwell by "/create oilwell" and then place and asign it to a player. (admins)
- or use 'oilwell' item to spawn oilwell
## Installation
## Step 0:
- import sql.sql in your database
## Step 1:
\*\* qb-core shared items.lua
```lua
["oilbarell"] = {
["name"] = "oilbarell",
["label"] = "Oil barell",
["weight"] = 15000,
["type"] = "item",
["image"] = "oilBarrel.png",
["unique"] = true,
["useable"] = false,
["shouldClose"] = true,
["combinable"] = nil,
["description"] = "Oil Barrel"
},
["oilwell"] = {
["name"] = "oilwell",
["label"] = "Oilwell",
["weight"] = 50000,
["type"] = "item",
["image"] = "oilwell.png",
["unique"] = false,
["useable"] = true,
["shouldClose"] = true,
["combinable"] = nil,
["description"] = "Oilwell"
},
["reliefvalvestring"] = {
["name"] = "reliefvalvestring",
["label"] = "Relief Valve String",
["weight"] = 4000,
["type"] = "item",
["image"] = "relief_valve_string.png",
["unique"] = false,
["useable"] = true,
["shouldClose"] = true,
["combinable"] = nil,
["description"] = "Relief Valve String"
},
["oilfilter"] = {
["name"] = "oilfilter",
["label"] = "Oil Filter",
["weight"] = 5000,
["type"] = "item",
["image"] = "oil_filter.png",
["unique"] = false,
["useable"] = true,
["shouldClose"] = true,
["combinable"] = nil,
["description"] = "Oil Filter"
},
["skewgear"] = {
["name"] = "skewgear",
["label"] = "Skew Gear",
["weight"] = 6000,
["type"] = "item",
["image"] = "skew_gear.png",
["unique"] = false,
["useable"] = true,
["shouldClose"] = true,
["combinable"] = nil,
["description"] = "Skew Gear"
},
["timingchain"] = {
["name"] = "timingchain",
["label"] = "Timing Chain",
["weight"] = 7000,
["type"] = "item",
["image"] = "timing_chain.png",
["unique"] = false,
["useable"] = true,
["shouldClose"] = true,
["combinable"] = nil,
["description"] = "Timing Chain"
},
["driveshaft"] = {
["name"] = "driveshaft",
["label"] = "Drive Shaft",
["weight"] = 5000,
["type"] = "item",
["image"] = "drive_shaft.png",
["unique"] = false,
["useable"] = true,
["shouldClose"] = true,
["combinable"] = nil,
["description"] = "Drive Shaft"
},
```
## Step 2:
\*\* qb-core shared jobs.lua
```lua
['oilwell'] = {
label = 'Oil Company',
defaultDuty = true,
offDutyPay = false,
grades = {
['0'] = {
name = 'Oilwell Operator',
payment = 50
},
['1'] = {
name = 'Oilwell Operator tier 2',
payment = 75
},
['2'] = {
name = 'Event Driver tier 2',
payment = 100
},
['3'] = {
name = 'Sales',
payment = 125
},
['4'] = {
name = 'CEO',
isboss = true,
payment = 150
},
},
},
```
## Step 3: tooltip
- in qb-inventory\js\app.js find FormatItemInfo() there is if statement like: if (itemData.name == "id_card")
- track where all of elseif statments are ended then add code below.
```javascript
else if (itemData.name == "oilbarell") {
$(".item-info-title").html("<p>" + itemData.label + "</p>");
$(".item-info-description").html("<p>Gal: " + itemData.info.gal + "</p>" + "<p>Type: " + itemData.info.type + "</p>" + "<p>Octane: " + itemData.info.avg_gas_octane + "</p>");
}
```
# Support
- [Discord](https://discord.gg/ccMArCwrPV)
# Donation
- [Donation](https://swkeep.github.io)
![Keep oilwell](https://raw.githubusercontent.com/swkeep/keep-oilwell/main/.github/images/screenshots/2022-05-17-16_00_11-000275.jpg)
![Keep oilwell](https://raw.githubusercontent.com/swkeep/keep-oilwell/main/.github/images/screenshots/2022-05-17-16_00_18-000276.jpg)
![Keep oilwell](https://raw.githubusercontent.com/swkeep/keep-oilwell/main/.github/images/screenshots/2022-05-17-16_00_34-000277.jpg)
![Keep oilwell](https://raw.githubusercontent.com/swkeep/keep-oilwell/main/.github/images/screenshots/2022-05-17-16_00_46-000278.jpg)
![Keep oilwell](https://raw.githubusercontent.com/swkeep/keep-oilwell/main/.github/images/screenshots/2022-05-17-16_00_50-000279.jpg)
![Keep oilwell](https://raw.githubusercontent.com/swkeep/keep-oilwell/main/.github/images/screenshots/2022-05-17-16_01_04-000280.jpg)
![Keep oilwell](https://raw.githubusercontent.com/swkeep/keep-oilwell/main/.github/images/screenshots/2022-05-17-16_01_09-000281.jpg)
![Keep oilwell](https://raw.githubusercontent.com/swkeep/keep-oilwell/main/.github/images/screenshots/2022-05-17-16_01_11-000282.jpg)
![Keep oilwell](https://raw.githubusercontent.com/swkeep/keep-oilwell/main/.github/images/screenshots/2022-05-17-16_01_13-000283.jpg)

View File

@ -0,0 +1,407 @@
local QBCore = exports['qb-core']:GetCoreObject()
PlayerJob = {}
OnDuty = nil
OBJECT = nil
local rigmodel = GetHashKey('p_oil_pjack_03_s')
function CheckJob()
return (PlayerJob.name == 'oilwell')
end
function CheckOnduty()
return (PlayerJob.name == 'oilwell' and PlayerJob.onduty)
end
-- class
OilRigs = {
dynamicSpawner_state = false,
data_table = {}, -- this table holds oilwells data and defined by server
core_entities = {} -- this table holds objects that has some functions to them and filled by dynamic spawner
}
function OilRigs:add(s_res, id)
if self.data_table[id] ~= nil then
return
end
self.data_table[id] = {}
self.data_table[id] = s_res
if self.data_table[id].isOwner == true then
local blip_settings = Oilwell_config.Settings.oil_well.blip
blip_settings.type = 'oil_well'
blip_settings.id = id
self.data_table[id].blip_handle = createCustom(self.data_table[id].position.coord, blip_settings)
end
end
function OilRigs:update(s_res, id)
if self.data_table[id] == nil then return end
s_res.entity = self.data_table[id].entity
s_res.Qbtarget = self.data_table[id].Qbtarget
self.data_table[id] = s_res
QBCore.Functions.TriggerCallback('keep-oilwell:server:oilwell_metadata', function(metadata)
self:syncSpeed(self.data_table[id].entity, metadata.speed)
end, self.data_table[id].oilrig_hash)
end
function OilRigs:startUpdate(cb)
QBCore.Functions.TriggerCallback('keep-oilrig:server:getNetIDs', function(result)
for key, value in pairs(result) do
self:update(value, key)
Wait(15)
end
cb(true)
end)
end
function OilRigs:syncSpeed(entity, speed)
local anim_speed = Round((speed / Oilwell_config.AnimationSpeedDivider), 2)
SetEntityAnimSpeed(entity, 'p_v_lev_des_skin', 'p_oil_pjack_03_s', anim_speed + .0)
end
function OilRigs:getById(id)
for key, value in pairs(self.data_table) do
if value.id == id then
return value
end
end
return false
end
function OilRigs:getByEntityHandle(handle)
for key, value in pairs(self.data_table) do
if value.entity == handle then
return value
end
end
return false
end
function OilRigs:readAll()
return self.data_table
end
function OilRigs:DynamicSpawner()
self.dynamicSpawner_state = true
local object_spawn_distance = 125.0
CreateThread(function()
-- create core blips
Wait(50)
for index, value in pairs(Oilwell_config.locations) do
value.blip.type = index
if not value.blip.handle and PlayerJob.name == 'oilwell' then
value.blip.handle = createCustom(value.position, value.blip)
end
if not value.qbtarget then
Add_3rd_eye(value.position, index)
value.qbtarget = true
end
end
for _, oilwell in pairs(self.data_table) do
if not oilwell.qbtarget then
local c = oilwell.position.coord
local coord = vector3(c.x, c.y, c.z)
createOwnerQbTarget(oilwell.oilrig_hash, coord)
oilwell.qbtarget = true
end
end
while self.dynamicSpawner_state do
local pedCoord = GetEntityCoords(PlayerPedId())
-- oilwells/pumps
for index, value in pairs(self.data_table) do
local c = value.position.coord
c = vector3(c.x, c.y, c.z)
local distance = #(c - pedCoord)
if distance < object_spawn_distance and self.data_table[index].entity == nil then
self.data_table[index].entity = spawnObjects(rigmodel, self.data_table[index].position)
QBCore.Functions.TriggerCallback('keep-oilwell:server:oilwell_metadata', function(metadata)
self:syncSpeed(self.data_table[index].entity, metadata.speed)
end, self.data_table[index].oilrig_hash)
elseif distance > object_spawn_distance and self.data_table[index].entity ~= nil then
DeleteEntity(self.data_table[index].entity)
self.data_table[index].entity = nil
end
end
for index, value in pairs(Oilwell_config.locations) do
local position = vector3(value.position.x, value.position.y, value.position.z)
local distance = #(position - pedCoord)
if self.core_entities[index] == nil then
self.core_entities[index] = {}
end
if distance < object_spawn_distance and self.core_entities[index].entity == nil then
self.core_entities[index].entity = spawnObjects(value.model, {
coord = { x = position.x, y = position.y, z = position.z, },
rotation = { x = value.rotation.x, y = value.rotation.y, z = value.rotation.z, }
})
elseif distance > object_spawn_distance and self.core_entities[index].entity ~= nil then
DeleteEntity(self.core_entities[index].entity)
self.core_entities[index].entity = nil
end
end
Wait(1250)
end
end)
end
function OilRigs:Flush_Entities()
for _, oilwell in pairs(self.data_table) do
if oilwell.entity then
DeleteObject(oilwell.entity)
end
RemoveBlip(oilwell.blip_handle)
end
self.dynamicSpawner_state = false
Wait(5)
self.data_table = {}
end
--
RegisterNetEvent('keep-oilrig:client:changeRigSpeed', function(qbtarget)
if not CheckJob() then
QBCore.Functions.Notify('Du er ikke hyret af et oliefirma', "error")
return false
end
if not CheckOnduty() then
QBCore.Functions.Notify('Du skal være på job!', "error")
return false
end
local rig = OilRigs:getByEntityHandle(qbtarget.entity)
if not rig then
return --print('oilwell not found')
end
QBCore.Functions.TriggerCallback('keep-oilwell:server:oilwell_metadata', function(metadata)
OilRigs:startUpdate(function()
local inputData = exports['qb-input']:ShowInput({
header = "Skift hastighed",
submitText = "change",
inputs = {
{
type = 'text',
isRequired = true,
name = 'Hastighed',
text = 'Nuværrende hastighed ' .. metadata.speed
},
}
})
if inputData then
local speed = tonumber(inputData.speed)
if not inputData.speed then
return
end
if not (0 <= speed and speed <= 100) then
QBCore.Functions.Notify('Hastighed skal være mellem 0-100', "error")
return
end
QBCore.Functions.Notify('Hanstighed er nu ' .. speed, "success")
TriggerServerEvent('keep-oilrig:server:updateSpeed', inputData, rig.id)
end
end)
end, rig.oilrig_hash)
end)
local function loadData()
OilRigs:Flush_Entities()
QBCore.Functions.GetPlayerData(function(PlayerData)
PlayerJob = PlayerData.job
OnDuty = PlayerData.job.onduty
QBCore.Functions.TriggerCallback('keep-oilrig:server:getNetIDs', function(result)
for key, value in pairs(result) do
OilRigs:add(value, key)
end
OilRigs:DynamicSpawner()
end)
end)
end
RegisterNetEvent('keep-oilrig:client:syncSpeed', function(id, speed)
local rig = OilRigs:getById(id)
if rig then
OilRigs:syncSpeed(rig.entity, speed)
end
end)
function spawnObjects(model, position)
TriggerEvent('keep-oilrig:client:clearArea', position.coord)
-- every oilwell exist only on client side!
local entity = CreateObject(model, position.coord.x, position.coord.y, position.coord.z, 0, 0, 0)
while not DoesEntityExist(entity) do Wait(10) end
SetEntityRotation(entity, position.rotation.x, position.rotation.y, position.rotation.z, 0.0, true)
FreezeEntityPosition(entity, true)
SetEntityProofs(entity, 1, 1, 1, 1, 1, 1, 1, 1)
return entity
end
-- --------------------------------------------------------------
RegisterNetEvent('keep-oilrig:client:spawn')
AddEventHandler('keep-oilrig:client:spawn', function()
local coords = ChooseSpawnLocation()
QBCore.Functions.TriggerCallback('keep-oilrig:server:createNewOilrig', function(NetId)
if NetId ~= nil then
local entity = NetworkGetEntityFromNetworkId(NetId)
OBJECT = entity
exports['qb-target']:AddEntityZone("oil-rig-" .. entity, entity, {
name = "oil-rig-" .. entity,
heading = GetEntityHeading(entity),
debugPoly = false,
}, {
options = {
{
type = "client",
event = "keep-oilrig:client:enterInformation",
icon = "fa-regular fa-file-lines",
label = "Tildel personel",
canInteract = function(entity)
if not CheckJob() then return false end
if not (PlayerJob.grade.level == 4) then
TriggerEvent('QBCore:Notify', 'Du skal være på job!', "error")
Wait(2000)
return false
end
if not CheckOnduty() then
TriggerEvent('QBCore:Notify', 'Du skal være på job!', "error")
Wait(2000)
return false
end
return true
end,
},
{
type = "client",
event = "keep-oilwell:menu:OPENMENU",
icon = "fa-regular fa-file-lines",
label = "Adjust position",
canInteract = function(entity)
if not CheckJob() then
TriggerEvent('QBCore:Notify', 'Kun chefen kan dette', "error")
Wait(2000)
return false
end
if not (PlayerJob.grade.level == 4) then
TriggerEvent('QBCore:Notify', 'Kun chefen kan dette', "error")
Wait(2000)
return false
end
if not CheckOnduty() then
TriggerEvent('QBCore:Notify', 'Du skal være på job!', "error")
Wait(2000)
return false
end
return true
end,
},
},
distance = 2.5
})
end
end, coords)
end)
RegisterNetEvent('keep-oilrig:client:enterInformation', function(qbtarget)
local inputData = exports['qb-input']:ShowInput({
header = "Tildel oliebrønd: ",
submitText = "Tildel",
inputs = { {
type = 'text',
isRequired = true,
name = 'Navn',
text = "Navn på oliebrønd"
},
{
type = 'number',
isRequired = true,
name = 'BorgerID',
text = "Borgerens ID"
},
}
})
if inputData then
if not inputData.name and not inputData.cid then
return
end
local netId = NetworkGetNetworkIdFromEntity(qbtarget.entity)
inputData.netId = netId
QBCore.Functions.TriggerCallback('keep-oilrig:server:regiserOilrig', function(result)
DeleteEntity(qbtarget.entity)
if result == true then
Wait(1500)
QBCore.Functions.Notify('Registrerer oliebrønd til: ' .. inputData.cid, "success")
loadData()
end
end, inputData)
end
end)
RegisterNetEvent('keep-oilwell:client:force_reload', function()
Wait(25)
loadData()
end)
AddEventHandler('onResourceStart', function(resourceName)
if (GetCurrentResourceName() ~= resourceName) then
return
end
Wait(500)
QBCore.Functions.GetPlayerData(function(PlayerData)
PlayerJob = PlayerData.job
OnDuty = PlayerData.job.onduty
loadData()
end)
StartBarellAnimation()
end)
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
Wait(3000)
QBCore.Functions.GetPlayerData(function(PlayerData)
PlayerJob = PlayerData.job
OnDuty = PlayerData.job.onduty
loadData()
end)
StartBarellAnimation()
end)
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
OilRigs.dynamicSpawner_state = false
end)
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo)
PlayerJob = JobInfo
OnDuty = PlayerJob.onduty
loadData()
end)
RegisterNetEvent('QBCore:Client:SetDuty', function(duty)
OnDuty = duty
loadData()
end)
RegisterNetEvent('keep-oilrig:client:local_mail_sender', function(data)
local Lang = Oilwell_config.Locale
Lang.mail.message = string.format(Lang.mail.message, data.gender, data.charinfo.lastname, data.money, data.amount,
data.refund)
TriggerServerEvent('qb-phone:server:sendNewMail', {
sender = Lang.mail.sender,
subject = Lang.mail.subject,
message = Lang.mail.message,
button = {}
})
end)
RegisterNetEvent('keep-oilwell:server_lib:AddExplosion', function(bullding_type)
local c = Oilwell_config.locations[bullding_type].position
local t = 0
for i = 1, 5, 1 do
AddExplosion(c.x, c.y, c.z + 0.5, 9, 10.0, true, false, true)
t = t + 1000
Wait(t)
end
end)

View File

@ -0,0 +1,203 @@
local QBCore = exports['qb-core']:GetCoreObject()
function isOwner(entity)
local oilrig = OilRigs:getByEntityHandle(entity)
if not oilrig then
return --print('failed to get oilwell')
end
local is_employee = nil
local is_owner = nil
-- await didn't work!
QBCore.Functions.TriggerCallback('keep-oilwell:server:is_employee', function(_is_employee, _is_owner)
is_employee, is_owner = _is_employee, _is_owner
end, oilrig.oilrig_hash)
for i = 1, 5, 1 do
if is_employee ~= nil then
break
end
Wait(50)
end
return is_employee, is_owner
end
local function Draw2DText(content, font, colour, scale, x, y)
SetTextFont(font)
SetTextScale(scale, scale)
SetTextColour(colour[1], colour[2], colour[3], 255)
SetTextEntry("STRING")
SetTextDropShadow(0, 0, 0, 0, 255)
SetTextDropShadow()
SetTextEdge(4, 0, 0, 0, 255)
SetTextOutline()
AddTextComponentString(content)
DrawText(x, y)
end
local function RotationToDirection(rotation)
local adjustedRotation = {
x = (math.pi / 180) * rotation.x,
y = (math.pi / 180) * rotation.y,
z = (math.pi / 180) * rotation.z
}
local direction = {
x = -math.sin(adjustedRotation.z) *
math.abs(math.cos(adjustedRotation.x)),
y = math.cos(adjustedRotation.z) *
math.abs(math.cos(adjustedRotation.x)),
z = math.sin(adjustedRotation.x)
}
return direction
end
local function RayCastGamePlayCamera(distance)
local cameraRotation = GetGameplayCamRot()
local cameraCoord = GetGameplayCamCoord()
local direction = RotationToDirection(cameraRotation)
local destination = {
x = cameraCoord.x + direction.x * distance,
y = cameraCoord.y + direction.y * distance,
z = cameraCoord.z + direction.z * distance
}
local a, b, c, d, e = GetShapeTestResult(
StartShapeTestRay(cameraCoord.x, cameraCoord.y,
cameraCoord.z, destination.x,
destination.y, destination.z,
-1, PlayerPedId(), 0))
return c, e
end
function ChooseSpawnLocation()
local plyped = PlayerPedId()
local pedCoord = GetEntityCoords(plyped)
local activeLaser = true
local oilrig = CreateObject(GetHashKey('p_oil_pjack_03_s'), pedCoord.x, pedCoord.y, pedCoord.z, 1, 1, 0)
SetEntityAlpha(oilrig, 150, true)
while activeLaser do
Wait(0)
local color = {
r = 2,
g = 241,
b = 181,
a = 200
}
local position = GetEntityCoords(plyped)
local coords, entity = RayCastGamePlayCamera(1000.0)
Draw2DText('Tryk ~g~E~w~ for at placere oliebrønd', 4, { 255, 255, 255 }, 0.4, 0.43,
0.888 + 0.025)
if IsControlJustReleased(0, 38) then
activeLaser = false
DeleteEntity(oilrig)
return coords
end
DrawLine(position.x, position.y, position.z, coords.x, coords.y,
coords.z, color.r, color.g, color.b, color.a)
SetEntityCollision(oilrig, false, false)
SetEntityCoords(oilrig, coords.x, coords.y, coords.z, 0.0, 0.0, 0.0, 0)
end
end
function createCustom(coord, o)
local blip = AddBlipForCoord(
coord.x,
coord.y,
coord.z
)
SetBlipSprite(blip, o.sprite)
SetBlipColour(blip, o.colour)
if o.range == 'short' then
SetBlipAsShortRange(blip, true)
else
SetBlipAsShortRange(blip, false)
end
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(replaceString(o))
EndTextCommandSetBlipName(blip)
return blip
end
function replaceString(o)
local s = o.name
if o.id ~= nil then
-- oilwells
local oilrig = OilRigs:getById(o.id)
s = s:gsub("OILWELLNAME", oilrig.name)
s = s:gsub("OILWELL_HASH", oilrig.oilrig_hash)
s = s:gsub("DB_ID_RAW", o.id)
s = s:gsub("TYPE", o.type)
else
s = s:gsub("TYPE", o.type)
end
return s
end
function createOwnerQbTarget(hash, coord)
exports['qb-target']:RemoveZone("oil-rig-" .. hash)
Targets.qb_target.oilwell(coord, hash)
end
RegisterNetEvent('keep-oilwell:client:remove_oilwell', function(data)
local oilwell = OilRigs:getByEntityHandle(data.entity)
for i = 1, 3, 1 do
local value = RandomHash(4)
local inputData = exports['qb-input']:ShowInput({
header = 'Gentag: ' .. value .. '',
inputs = {
{
type = 'text',
isRequired = true,
name = 'Gentag',
text = ''
},
}
})
if not inputData then
QBCore.Functions.Notify('Annulleret', "primary")
return
end
if inputData.RandomHash ~= value then
QBCore.Functions.Notify('Fejlede', "primary")
return
end
end
TriggerServerEvent('keep-oilwell:server:remove_oilwell', oilwell.oilrig_hash)
end)
function Add_3rd_eye(coord, Type)
local key = Type
if key == 'storage' then
Targets.qb_target.storage(coord, key)
elseif key == 'distillation' then
Targets.qb_target.distillation(coord, key)
elseif key == 'blender' then
Targets.qb_target.blender(coord, key)
elseif key == 'barrel_withdraw' then
Targets.qb_target.barrel_withdraw(coord, key)
elseif key == 'crude_oil_transport' then
Targets.qb_target.crude_oil_transport(coord, key)
elseif key == 'toggle_job' then
Targets.qb_target.toggle_job(coord, key)
end
end
---force remove objects in area
---@param coord table
RegisterNetEvent('keep-oilrig:client:clearArea', function(coord)
ClearAreaOfObjects(coord.x, coord.y, coord.z, 5.0, 1)
end)
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(PlayerJob)
if CheckJob() then
OnDuty = CheckOnduty()
end
end)
RegisterNetEvent('keep-oilrig:client:goOnDuty', function(PlayerJob)
TriggerServerEvent("QBCore:ToggleDuty")
if CheckJob() and CheckOnduty() == false then
OnDuty = true
else
OnDuty = false
end
end)

View File

@ -0,0 +1,122 @@
local QBCore = exports['qb-core']:GetCoreObject()
local function showCDU(data)
if not data then return end
local state = ''
if data.metadata.state == true then
state = 'Aktiv'
else
state = 'Inaktiv'
end
local header = "Råoile destilations-enhed (" .. state .. ')'
-- header
local CDU_Temperature = data.metadata.temp
local CDU_Gal = data.metadata.oil_storage
local openMenu = {
{
header = header,
isMenuHeader = true,
icon = 'fa-solid fa-gear'
}, {
header = 'Temperatur',
icon = 'fa-solid fa-temperature-high',
txt = "" .. CDU_Temperature .. " °C",
},
{
header = 'Råoile i CDU',
icon = 'fa-solid fa-oil-can',
txt = CDU_Gal .. " Liter",
},
{
header = 'Pump råoile til CDU',
icon = 'fa-solid fa-arrows-spin',
params = {
event = "keep-oilrig:CDU_menu:pumpCrudeOil_to_CDU"
}
},
{
header = 'Skift temperatur',
icon = 'fa-solid fa-temperature-arrow-up',
params = {
event = "keep-oilrig:CDU_menu:set_CDU_temp"
}
},
{
header = 'Toggle CDU',
icon = 'fa-solid fa-sliders',
params = {
event = "keep-oilrig:CDU_menu:switchPower_of_CDU"
}
},
{
header = 'Forlad',
icon = 'fa-solid fa-circle-xmark',
params = {
event = "qb-menu:closeMenu"
}
}
}
exports['qb-menu']:openMenu(openMenu)
end
AddEventHandler('keep-oilrig:CDU_menu:ShowCDU', function()
QBCore.Functions.TriggerCallback('keep-oilrig:server:get_CDU_Data', function(result)
showCDU(result)
end)
end)
AddEventHandler('keep-oilrig:CDU_menu:switchPower_of_CDU', function()
QBCore.Functions.TriggerCallback('keep-oilrig:server:switchPower_of_CDU', function(result)
showCDU(result)
end)
end)
AddEventHandler('keep-oilrig:CDU_menu:set_CDU_temp', function()
local inputData = exports['qb-input']:ShowInput({
header = "CDU Temperatur",
submitText = "Angiv ny temperatur",
inputs = { {
type = 'number',
isRequired = true,
name = 'temp',
text = "Angiv ny temperatur"
},
}
})
if inputData then
if not inputData.temp then
return
end
QBCore.Functions.TriggerCallback('keep-oilrig:server:set_CDU_temp', function(result)
showCDU(result)
end, inputData)
end
end)
AddEventHandler('keep-oilrig:CDU_menu:pumpCrudeOil_to_CDU', function()
local inputData = exports['qb-input']:ShowInput({
header = "Pump råoile til CDU",
submitText = "Enter",
inputs = { {
type = 'number',
isRequired = true,
name = 'mændge',
text = "Angiv mængde råoile"
},
}
})
if inputData then
inputData.amount = tonumber(inputData.amount)
if not inputData.amount then
return
end
if inputData.amount <= 0 then
QBCore.Functions.Notify('Mængde skal være mere end 0', "error")
return
end
QBCore.Functions.TriggerCallback('keep-oilrig:server:pumpCrudeOil_to_CDU', function(result)
showCDU(result)
end, inputData)
end
end)

View File

@ -0,0 +1,199 @@
local QBCore = exports['qb-core']:GetCoreObject()
local function showblender(data)
local state = ''
local start_btn = 'Start'
local start_icon = 'fa-solid fa-square-caret-right'
if type(data) == "table" and data.metadata.state == false then
state = 'Inactive'
start_btn = 'Start'
start_icon = 'fa-solid fa-square-caret-right'
else
state = 'Active'
start_btn = 'Stop'
start_icon = "fa-solid fa-circle-stop"
end
local header = "Blender unit (" .. state .. ')'
-- header
local heavy_naphtha = data.metadata.heavy_naphtha
local light_naphtha = data.metadata.light_naphtha
local other_gases = data.metadata.other_gases
-- new elements
local diesel = data.metadata.diesel
local kerosene = data.metadata.kerosene
local fuel_oil = data.metadata.fuel_oil
local openMenu = {
{
header = header,
isMenuHeader = true,
icon = 'fa-solid fa-blender'
}, {
header = 'Tung råoile',
icon = 'fa-solid fa-circle',
txt = heavy_naphtha .. " liter",
disabled = true
},
{
header = 'Let råoile',
icon = 'fa-solid fa-circle',
txt = light_naphtha .. " liter",
disabled = true
},
{
header = 'Andre gasser',
icon = 'fa-solid fa-circle',
txt = other_gases .. " liter",
disabled = true
},
}
-- new elements
if diesel then
openMenu[#openMenu + 1] = {
header = 'Diesel',
icon = 'fa-solid fa-circle',
txt = diesel .. " liter",
disabled = true
}
end
if kerosene then
openMenu[#openMenu + 1] = {
header = 'Petroleum',
icon = 'fa-solid fa-circle',
txt = kerosene .. " liter",
disabled = true
}
end
if fuel_oil then
openMenu[#openMenu + 1] = {
header = 'Brændselsolie',
icon = 'fa-solid fa-circle',
txt = fuel_oil .. " Liter (Bruges ikke i blandingsprocessen)",
disabled = true
}
end
openMenu[#openMenu + 1] = {
header = 'Skift opskrift',
icon = 'fa-solid fa-scroll',
params = {
event = "keep-oilrig:blender_menu:recipe_blender"
}
}
openMenu[#openMenu + 1] = {
header = start_btn .. ' Blander',
icon = start_icon,
params = {
event = "keep-oilrig:blender_menu:toggle_blender"
}
}
openMenu[#openMenu + 1] = {
header = 'Pump brændselsolie til tank',
icon = 'fa-solid fa-arrows-spin',
params = {
event = "keep-oilrig:blender_menu:pump_fueloil"
}
}
openMenu[#openMenu + 1] = {
header = 'Forlad',
icon = 'fa-solid fa-circle-xmark',
params = {
event = "qb-menu:closeMenu"
}
}
exports['qb-menu']:openMenu(openMenu)
end
AddEventHandler('keep-oilrig:blender_menu:pump_fueloil', function()
QBCore.Functions.TriggerCallback('keep-oilrig:server:pump_fueloil', function(result)
showblender(result)
end)
end)
AddEventHandler('keep-oilrig:blender_menu:ShowBlender', function()
QBCore.Functions.TriggerCallback('keep-oilrig:server:ShowBlender', function(result)
showblender(result)
end)
end)
AddEventHandler('keep-oilrig:blender_menu:toggle_blender', function()
QBCore.Functions.TriggerCallback('keep-oilrig:server:toggle_blender', function(result)
showblender(result)
end)
end)
local function inRange(x, min, max)
return (x >= min and x <= max)
end
AddEventHandler('keep-oilrig:blender_menu:recipe_blender', function()
local inputData = exports['qb-input']:ShowInput({
header = "Pump råoile til CDU",
submitText = "Enter",
inputs = {
{
type = 'number',
isRequired = true,
name = 'heavy_naphtha',
text = "Tung råoile"
},
{
type = 'number',
isRequired = true,
name = 'light_naphtha',
text = "Let råoile"
},
{
type = 'number',
isRequired = true,
name = 'other_gases',
text = "Andre gasser"
},
-- new elements
{
type = 'number',
isRequired = true,
name = 'diesel',
text = "Diesel"
},
{
type = 'number',
isRequired = true,
name = 'kerosene',
text = "Petroleum"
},
}
})
if inputData then
if not
(
inputData.heavy_naphtha
and inputData.light_naphtha
and inputData.other_gases
and inputData.diesel
and inputData.kerosene
) then
return
end
for _, value in pairs(inputData) do
if not inRange(tonumber(value), 0, 100) then
QBCore.Functions.Notify('Nummer skal være mellem 0-100', "primary")
return
end
end
QBCore.Functions.TriggerCallback('keep-oilrig:server:recipe_blender', function(result)
showblender(result)
end, inputData)
end
end)

View File

@ -0,0 +1,83 @@
local menu = MenuV:CreateMenu('Swkeep Oliebrønd', 'Menu', 'topright', 0, 0, 0, 'size-125', 'default', 'menuv', 'swkeep_oilwell', 'default')
menu.Title = ('Entity: %s'):format(OBJECT)
local slider = menu:AddSlider({ icon = '', label = 'Præcision', value = '', values = {
{ label = 'X1', value = 1 },
{ label = 'X2', value = 2 },
{ label = 'X3', value = 3 },
{ label = 'X4', value = 4 },
{ label = 'X5', value = 5 },
{ label = 'X6', value = 6 }
} })
local range = menu:AddRange({
icon = '↔️',
label = 'Roter på Z',
min = -10,
max = 10,
value = 0,
saveOnUpdate = true
})
local range2 = menu:AddRange({
icon = '↕️',
label = 'Roter på Y',
min = -10,
max = 10,
value = 0,
saveOnUpdate = true
})
local range3 = menu:AddRange({
icon = '↕️',
label = 'Roter på X',
min = -10,
max = 10,
value = 0,
saveOnUpdate = true
})
--- Events
slider:On('change', function(item, newValue, oldValue)
local m = 10 * newValue
range.Max = m
range.Min = -m
range2.Max = m
range2.Min = -m
range3.Max = m
range3.Min = -m
end)
range:On('change', function(item, newValue, oldValue)
menu.Title = ('Enhed: %s'):format(OBJECT)
range.Description = ('Nuværrende værdi (x) : %s'):format(newValue)
local roration = GetEntityRotation(OBJECT, 0)
SetEntityRotation(OBJECT, roration.x, roration.y, 0.0 + newValue * 6, 0.0, true)
end)
range2:On('change', function(item, newValue, oldValue)
menu.Title = ('Enhed: %s'):format(OBJECT)
range2.Description = ('Nuværrende værdi (y) : %s'):format(newValue)
local roration = GetEntityRotation(OBJECT, 0)
SetEntityRotation(OBJECT, roration.x, 0.0 + newValue * 6, roration.z, 0.0, true)
end)
range3:On('change', function(item, newValue, oldValue)
menu.Title = ('Enhed: %s'):format(OBJECT)
range3.Description = ('Nuværrende værdi (z) : %s'):format(newValue)
local roration = GetEntityRotation(OBJECT, 0)
SetEntityRotation(OBJECT, 0.0 + newValue * 3, roration.y, roration.z, 0.0, true)
end)
local isOpen = false
AddEventHandler('keep-oilwell:menu:OPENMENU', function()
if not IsPauseMenuActive() and IsNuiFocused() ~= 1 and not isOpen then
MenuV:OpenMenu(menu)
isOpen = true
elseif isOpen == true then
MenuV:CloseMenu(menu)
isOpen = false
end
end)

View File

@ -0,0 +1,290 @@
local QBCore = exports['qb-core']:GetCoreObject()
local function showInfo(data)
QBCore.Functions.TriggerCallback('keep-oilwell:server:oilwell_metadata', function(selected_oilrig)
local header = "Navn: " .. data.name
local partInfoString = "Bælte: " ..
selected_oilrig.part_info.belt ..
" Polish: " .. selected_oilrig.part_info.polish .. " Clutch: " .. selected_oilrig.part_info.clutch
local duration = math.floor(selected_oilrig.duration / 60)
-- header
local openMenu = {
{
header = header,
isMenuHeader = true,
icon = 'fa-solid fa-oil-well'
}, {
header = 'Hastighed',
icon = 'fa-solid fa-gauge',
txt = "" .. selected_oilrig.speed .. " RPM",
disabled = true,
},
{
header = 'Køretid',
icon = 'fa-solid fa-clock',
txt = "" .. duration .. " Min",
disabled = true,
},
{
header = 'Temperatur',
icon = 'fa-solid fa-temperature-high',
txt = "" .. selected_oilrig.temp .. " °C",
disabled = true,
},
{
header = 'Olie i tanken',
icon = 'fa-solid fa-oil-can',
txt = "" .. selected_oilrig.oil_storage .. "/L",
disabled = true,
},
{
header = 'Part Info',
icon = 'fa-solid fa-oil-can',
txt = partInfoString,
disabled = true,
},
{
header = 'Pump olie til tank',
icon = 'fa-solid fa-arrows-spin',
params = {
event = 'keep-oilrig:storage_menu:PumpOilToStorage',
args = {
oilrig_hash = data.oilrig_hash
}
}
},
{
header = 'Manage ansatte',
icon = 'fa-solid fa-people-group',
params = {
event = 'keep-oilwell:menu:ManageEmployees',
args = data.oilrig_hash
}
},
{
header = 'Forlad',
icon = 'fa-solid fa-circle-xmark',
params = {
event = "qb-menu:closeMenu"
}
}
}
exports['qb-menu']:openMenu(openMenu)
end, data.oilrig_hash)
end
RegisterNetEvent('keep-oilwell:menu:ManageEmployees', function(oilrig_hash)
QBCore.Functions.TriggerCallback('keep-oilwell:server:employees_list', function(result)
if not result then return end
-- header
local Menu = {
{
header = 'Oliebrønd ansatte',
isMenuHeader = true,
icon = 'fa-solid fa-vest'
},
}
Menu[#Menu + 1] = {
header = 'Tilføj ansat',
icon = 'fa-solid fa-person-circle-plus',
params = {
event = "keep-oilwell:client:add_employee",
args = {
oilrig_hash = oilrig_hash,
state_id = 1
}
}
}
for index, employee in ipairs(result) do
local name = employee.charinfo.firstname .. ' ' .. employee.charinfo.lastname
local gender = (employee.charinfo.gender == 0 and 'Mand' or employee.charinfo.gender ~= 0 and 'Kvinde')
local information = 'Navn: %s </br> Telefon: %s </br> Køn: %s </br>'
local other = ' (Online: %s)'
local online = (employee.online and '🟢' or not employee.online and '🔴')
Menu[#Menu + 1] = {
header = 'Ansat #' .. index .. string.format(other, online),
txt = string.format(information, name, employee.charinfo.phone, gender),
icon = 'fa-solid fa-person',
params = {
event = "keep-oilwell:menu:remove_employee",
args = {
employee = employee,
oilrig_hash = oilrig_hash
}
}
}
end
Menu[#Menu + 1] = {
header = 'Forlad',
icon = 'fa-solid fa-circle-xmark',
params = {
event = "qb-menu:closeMenu"
}
}
exports['qb-menu']:openMenu(Menu)
end, oilrig_hash)
end)
RegisterNetEvent('keep-oilwell:client:add_employee', function(data)
local inputData = exports['qb-input']:ShowInput({
header = 'BorgerID',
inputs = {
{
type = 'number',
isRequired = true,
name = 'BorgerID',
text = 'Skriv BorgerID'
},
}
})
if inputData then
if not inputData.stateId then return end
inputData.stateId = tonumber(inputData.stateId)
TriggerServerEvent('keep-oilwell:server:add_employee', data.oilrig_hash, inputData.stateId)
end
end)
RegisterNetEvent('keep-oilwell:menu:remove_employee', function(data)
local employee = data.employee
local name = employee.charinfo.firstname .. ' ' .. employee.charinfo.lastname
-- header
local Menu = {
{
header = 'Tilbage',
icon = 'fa-solid fa-angle-left',
params = {
event = "keep-oilwell:menu:ManageEmployees",
args = data.oilrig_hash
}
},
{
header = 'Fyr ansat',
txt = 'Name: ' .. name,
isMenuHeader = true,
icon = 'fa-solid fa-vest'
},
{
header = 'Ja',
icon = 'fa-solid fa-circle-check',
params = {
event = "keep-oilwell:menu:fire_employee",
args = {
employee = data.employee,
oilrig_hash = data.oilrig_hash
}
}
}
}
Menu[#Menu + 1] = {
header = 'Annuller',
icon = 'fa-solid fa-circle-xmark',
params = {
event = "qb-menu:closeMenu"
}
}
exports['qb-menu']:openMenu(Menu)
end)
RegisterNetEvent('keep-oilwell:menu:fire_employee', function(data)
TriggerServerEvent('keep-oilwell:server:remove_employee', data.oilrig_hash, data.employee.citizenid)
end)
local function show_oilwell_stash(data)
QBCore.Functions.TriggerCallback('keep-oilwell:server:oilwell_metadata', function(selected_oilrig)
local header = "Navn: " .. data.name
local partInfoString = "Bælte: " ..
selected_oilrig.part_info.belt ..
" Polish: " .. selected_oilrig.part_info.polish .. " Clutch: " .. selected_oilrig.part_info.clutch
-- header
local openMenu = {
{
header = header,
isMenuHeader = true,
icon = 'fa-solid fa-oil-well'
},
{
header = 'Part Info',
icon = 'fa-solid fa-oil-can',
txt = partInfoString,
disabled = true,
},
{
header = 'Åben stash',
icon = 'fa-solid fa-cart-flatbed',
params = {
event = 'keep-oilwell:client:openOilPump',
args = {
oilrig_hash = data.oilrig_hash
}
}
},
{
header = 'Fiks oliebrønd',
icon = 'fa-solid fa-screwdriver-wrench',
params = {
event = 'keep-oilwell:client:fix_oilwell',
args = {
oilrig_hash = data.oilrig_hash
}
}
},
{
header = 'Forlad',
icon = 'fa-solid fa-circle-xmark',
params = {
event = "qb-menu:closeMenu"
}
}
}
exports['qb-menu']:openMenu(openMenu)
end, data.oilrig_hash)
end
-- Events
AddEventHandler('keep-oilrig:storage_menu:PumpOilToStorage', function(data)
QBCore.Functions.TriggerCallback('keep-oilrig:server:PumpOilToStorageCallback', function(result)
end, data.oilrig_hash)
end)
AddEventHandler('keep-oilrig:client:viewPumpInfo', function(qbtarget)
-- ask for updated data
OilRigs:startUpdate(function()
showInfo(OilRigs:getByEntityHandle(qbtarget.entity))
end)
end)
AddEventHandler('keep-oilrig:client:show_oilwell_stash', function(qbtarget)
-- ask for updated data
OilRigs:startUpdate(function()
show_oilwell_stash(OilRigs:getByEntityHandle(qbtarget.entity))
end)
end)
-- Open oil pump stash.
RegisterNetEvent("keep-oilwell:client:openOilPump", function(data)
if not data then return end
TriggerServerEvent("inventory:server:OpenInventory", "stash", "oilPump_" .. data.oilrig_hash,
{ maxweight = 100000, slots = 5 })
TriggerEvent("inventory:client:SetCurrentStash", "oilPump_" .. data.oilrig_hash)
end)
AddEventHandler('keep-oilwell:client:fix_oilwell', function(data)
-- ask for updated data
QBCore.Functions.TriggerCallback('keep-oilwell:server:fix_oil_well', function(result)
-- print(result)
end, data.oilrig_hash)
end)

View File

@ -0,0 +1,322 @@
local QBCore = exports['qb-core']:GetCoreObject()
local function showStorage(storage_data)
local header = storage_data.name
-- header
local openMenu = {
{
header = header,
isMenuHeader = true,
icon = 'fa-solid fa-warehouse'
}, {
header = 'Råoile',
icon = 'fa-solid fa-oil-can',
txt = "" .. storage_data.metadata.crudeOil .. " /l",
params = {
event = 'keep-oilrig:storage_menu:StorageActions',
args = {
type = 'crudeOil',
storage_data = storage_data
}
}
},
{
header = 'Brændstof',
icon = 'fa-solid fa-oil-can',
txt = "" .. storage_data.metadata.gasoline .. " /l | Oktan: " .. storage_data.metadata.avg_gas_octane,
params = {
event = 'keep-oilrig:storage_menu:StorageActions',
args = {
type = 'gasoline',
storage_data = storage_data
}
}
},
}
if storage_data.metadata.fuel_oil then
openMenu[#openMenu + 1] = {
header = 'Brændselsolie',
icon = 'fa-solid fa-oil-can',
txt = "" .. storage_data.metadata.fuel_oil .. " /l",
params = {
event = 'keep-oilrig:storage_menu:StorageActions',
args = {
type = 'fuel_oil',
storage_data = storage_data
}
}
}
end
openMenu[#openMenu + 1] = {
header = 'Forlad',
icon = 'fa-solid fa-circle-xmark',
params = {
event = "qb-menu:closeMenu"
}
}
exports['qb-menu']:openMenu(openMenu)
end
local function showStorageActions(data)
local header = "Actions " .. data.type
local storage_data = data.storage_data
-- header
local openMenu = {
{
header = header,
isMenuHeader = true,
icon = 'fa-solid fa-pump'
}, {
header = 'Tag fra lager',
icon = 'fa-solid fa-truck-ramp-box',
txt = "",
params = {
event = 'keep-oilrig:storage_menu:StorageWithdraw',
args = data
}
},
{
header = 'Lagerhandling',
icon = 'fa-solid fa-arrow-right-arrow-left',
params = {
event = '',
}
},
{
header = 'Tilbage',
icon = 'fa-solid fa-angle-left',
params = {
event = "keep-oilrig:storage_menu:ShowStorage"
}
}
}
exports['qb-menu']:openMenu(openMenu)
end
local function showStorageWithdraw(data)
local header = "Tag fra lager (" .. data.type .. ")"
local currentWithdrawTarget = data.storage_data.metadata[data.type] -- oil or gas
-- header
local openMenu = {
{
header = header,
isMenuHeader = true,
icon = 'fa-solid fa-boxes-packing'
},
{
header = 'Du har ' .. currentWithdrawTarget .. ' liter ' .. data.type,
isMenuHeader = true,
icon = 'fa-solid fa-boxes-packing'
}, {
header = 'Gem i tønde',
icon = 'fa-solid fa-bottle-droplet',
txt = "Depositum: 500,- Kapacitet: 5000 /l",
params = {
event = 'keep-oilrig:storage_menu:Callback',
args = {
eventName = 'keep-oilrig:server:Withdraw',
citizenid = data.storage_data.citizenid,
type = data.type,
truck = false
}
}
},
{
header = 'Fyld tankbil',
icon = 'fa-solid fa-truck-droplet',
txt = "Depositum: 25.000,- Kapacitet: 100.000 /l",
params = {
event = 'keep-oilrig:storage_menu:Callback',
args = {
eventName = 'keep-oilrig:server:Withdraw',
citizenid = data.storage_data.citizenid,
type = data.type,
truck = true
}
}
},
{
header = 'Tilbage',
icon = 'fa-solid fa-angle-left',
params = {
event = "keep-oilrig:storage_menu:StorageActions",
args = data
}
}
}
exports['qb-menu']:openMenu(openMenu)
end
MakeVehicle = function(model, Coord, TriggerLocation, DinstanceToTrigger, items)
local plyped = PlayerPedId()
local pedCoord = GetEntityCoords(plyped)
local finished = false
local distance = GetDistanceBetweenCoords(pedCoord.x, pedCoord.y, pedCoord.z, TriggerLocation.x, TriggerLocation.y,
TriggerLocation.z, true)
CreateThread(function()
while distance > DinstanceToTrigger do
local pedCoord = GetEntityCoords(plyped)
distance = GetDistanceBetweenCoords(pedCoord.x, pedCoord.y, pedCoord.z, TriggerLocation.x,
TriggerLocation.y, TriggerLocation.z, true)
Wait(1000)
end
finished = true
end)
-- wait for player at delivery coord
while finished == false do
DrawMarker(2, TriggerLocation.x, TriggerLocation.y, TriggerLocation.z + 2, 0.0, 0.0, 0.0, 0.0, 180.0, 0.0, 1.0
, 1.0,
1.0, 255, 128, 0, 50, false, true, 2, nil, nil, false)
Wait(0)
end
local vehiclePlate = "HPO" .. math.random(1, 9) .. math.random(1, 9) .. math.random(1, 9)
model = GetHashKey(model)
RequestModel(model)
while not HasModelLoaded(model) do
Wait(10)
end
local veh = CreateVehicle(model, Coord.x, Coord.y, Coord.z, Coord.w, true, false)
local netid = NetworkGetNetworkIdFromEntity(veh)
SetVehicleHasBeenOwnedByPlayer(veh, true)
SetNetworkIdCanMigrate(netid, true)
SetVehicleNeedsToBeHotwired(veh, false)
SetVehRadioStation(veh, "OFF")
SetVehicleNumberPlateText(veh, vehiclePlate)
exports[Oilwell_config.fuel_script]:SetFuel(veh, math.random(80, 90))
SetVehicleEngineOn(veh, true, true)
SetNetworkIdAlwaysExistsForPlayer(NetworkGetNetworkIdFromEntity(veh), PlayerPedId(), true)
TriggerEvent("vehiclekeys:client:SetOwner", QBCore.Functions.GetPlate(veh))
TriggerEvent("vehiclekeys:client:SetOwner", vehiclePlate)
SetModelAsNoLongerNeeded(model)
Targets.qb_target.truck(vehiclePlate, veh)
TriggerServerEvent('keep-oilwell:server_lib:update_vehicle', vehiclePlate, items)
end
RegisterNetEvent('keep-oilrig:client_lib:withdraw_from_queue', function(data)
QBCore.Functions.TriggerCallback('keep-oilrig:server:withdraw_from_queue', function(result)
-- res >> table of items
if result == false then
return
end
if not result.truck then
return
end
local SpawnLocation = Oilwell_config.Delivery.SpawnLocation
local TriggerLocation = Oilwell_config.Delivery.TriggerLocation
local DinstanceToTrigger = Oilwell_config.Delivery.DinstanceToTrigger
local model = Oilwell_config.Delivery.vehicleModel
MakeVehicle(model, SpawnLocation, TriggerLocation, DinstanceToTrigger, result)
end, data.truck)
end)
-- Events
AddEventHandler('keep-oilrig:storage_menu:ShowStorage', function(data)
QBCore.Functions.TriggerCallback('keep-oilrig:server:getStorageData', function(result)
showStorage(result)
end)
end)
AddEventHandler('keep-oilrig:storage_menu:StorageActions', function(storage_data)
showStorageActions(storage_data)
end)
AddEventHandler('keep-oilrig:storage_menu:StorageWithdraw', function(data)
showStorageWithdraw(data)
end)
AddEventHandler('keep-oilrig:storage_menu:Callback', function(data)
local inputData = exports['qb-input']:ShowInput({
header = "Angiv mængde",
submitText = "Bekræft",
inputs = {
{
type = 'number',
isRequired = true,
name = 'Mængde',
text = "Mængde"
},
}
})
if inputData then
if not inputData.amount then
return
end
data.amount = inputData.amount
QBCore.Functions.TriggerCallback(data.eventName, function(res)
end, data)
end
end)
-- withdraw spot
AddEventHandler("keep-oilwell:client:openWithdrawStash", function(data)
local player = QBCore.Functions.GetPlayerData()
if not data then return end
local settings = { maxweight = 100000, slots = 5 }
TriggerServerEvent("inventory:server:OpenInventory", "stash", "Withdraw_" .. player.citizenid, settings)
TriggerEvent("inventory:client:SetCurrentStash", "Withdraw_" .. player.citizenid)
end)
-- purge menu
local function purge_menu()
local openMenu = {
{
header = 'TØM',
txt = 'Ønsker du at tømme lageret?',
icon = 'fa-solid fa-trash-can',
isMenuHeader = true,
},
{
header = 'Bekræft',
icon = 'fa-solid fa-square-check',
params = {
event = 'keep-oilwell:client:purgeWithdrawStash',
}
},
{
header = 'Annuller',
icon = 'fa-solid fa-circle-xmark',
params = {
event = "qb-menu:closeMenu"
}
}
}
exports['qb-menu']:openMenu(openMenu)
end
AddEventHandler('keep-oilwell:client:open_purge_menu', function()
purge_menu()
end)
local purge_conf = 0
AddEventHandler('keep-oilwell:client:purgeWithdrawStash', function()
if purge_conf == 0 then
QBCore.Functions.Notify('Prøv igen! (Resetter om 5 sekunder)', "primary")
purge_conf = purge_conf + 1
SetTimeout(5000, function()
purge_conf = 0
end)
purge_menu()
return
end
purge_conf = 0
TriggerServerEvent('keep-oilwell:server:purgeWithdrawStash')
end)

View File

@ -0,0 +1,205 @@
local QBCore = exports['qb-core']:GetCoreObject()
local function show_transport_menu()
-- header
local openMenu = {
{
header = 'Transport',
txt = "Sælg råoile for at tjene penge",
isMenuHeader = true,
icon = 'fa-solid fa-ship'
},
{
header = 'Kontroller nuværende pris/lager',
icon = 'fa-solid fa-hand-holding-dollar',
txt = "",
params = {
event = 'keep-oilwell:menu:show_transport_menu:ask_stock_price',
}
},
{
header = 'Anmod om salgsorder',
icon = 'fa-solid fa-diagram-successor',
txt = "",
params = {
event = 'keep-oilwell:menu:show_transport_menu:ask_to_sell_amount',
}
},
{
header = 'Forlad',
icon = 'fa-solid fa-circle-xmark',
params = {
event = "qb-menu:closeMenu"
}
}
}
exports['qb-menu']:openMenu(openMenu)
end
AddEventHandler('keep-oilwell:menu:show_transport_menu', function()
show_transport_menu()
end)
AddEventHandler('keep-oilwell:menu:show_transport_menu:ask_stock_price', function()
TriggerServerEvent('keep-oilrig:server:oil_transport:checkPrice')
end)
local function disableCombat()
DisablePlayerFiring(PlayerId(), true) -- Disable weapon firing
DisableControlAction(0, 24, true) -- disable attack
DisableControlAction(0, 25, true) -- disable aim
DisableControlAction(1, 37, true) -- disable weapon select
DisableControlAction(0, 47, true) -- disable weapon
DisableControlAction(0, 58, true) -- disable weapon
DisableControlAction(0, 140, true) -- disable melee
DisableControlAction(0, 141, true) -- disable melee
DisableControlAction(0, 142, true) -- disable melee
DisableControlAction(0, 143, true) -- disable melee
DisableControlAction(0, 263, true) -- disable melee
DisableControlAction(0, 264, true) -- disable melee
DisableControlAction(0, 257, true) -- disable melee
end
function LoadAnim(dict)
while not HasAnimDictLoaded(dict) do
RequestAnimDict(dict)
Wait(10)
end
end
function LoadPropDict(model)
while not HasModelLoaded(GetHashKey(model)) do
RequestModel(GetHashKey(model))
Wait(10)
end
end
local active_prop = nil
function AttachProp(model, bone, x, y, z, rot1, rot2, rot3)
local playerped = PlayerPedId()
local model_hash = GetHashKey(model)
local playercoord = GetEntityCoords(playerped)
local bone_index = GetPedBoneIndex(playerped, bone)
local _x, _y, _z = table.unpack(playercoord)
if not HasModelLoaded(model) then
LoadPropDict(model)
end
active_prop = CreateObject(model_hash, _x, _y, _z + 0.2, true, true, true)
AttachEntityToEntity(active_prop, playerped, bone_index, x, y, z, rot1, rot2, rot3, true, true, false, true, 1, true)
SetModelAsNoLongerNeeded(model)
end
local function start_barell_animation()
local playerped = PlayerPedId()
local dict = 'anim@heists@box_carry@'
local anim = 'idle'
local PropName = 'prop_barrel_exp_01a'
local PropBone = 60309
LoadAnim(dict)
ClearPedTasks(playerped)
RemoveAnimDict(dict)
Wait(250)
AttachProp(PropName, PropBone, 0.0, 0.41, 0.3, 130.0, 290.0, 0.0)
CreateThread(function()
while active_prop do
local not_animation = IsEntityPlayingAnim(playerped, dict, anim, 3)
if not_animation ~= 1 then
TaskPlayAnim(playerped, dict, anim, 2.0, 2.0, -1, 51, 0, false, false, false)
DisableControlAction(0, 22, true)
end
Wait(1500)
end
end)
CreateThread(function()
while active_prop do
--disable combat while player have barell in their hands
disableCombat()
Wait(1)
end
end)
end
local function end_barell_animaiton()
local playerped = PlayerPedId()
local dict = 'anim@heists@box_carry@'
local anim = 'idle'
if active_prop then
DeleteObject(active_prop)
active_prop = nil
end
StopAnimTask(playerped, dict, anim, 1.0)
end
AddEventHandler('keep-oilwell:menu:show_transport_menu:ask_to_sell_amount', function()
local inputData = exports['qb-input']:ShowInput({
header = "Antal tønder",
submitText = "Sælg",
inputs = {
{
type = 'number',
isRequired = true,
name = 'Mængde',
text = "Mængde"
},
}
})
if inputData then
if not inputData.amount then
return
end
if type(inputData.amount) == 'string' then
inputData.amount = math.floor(tonumber(inputData.amount))
end
-- start_barell_animation()
QBCore.Functions.Progressbar("keep_oilwell_transport", 'Fylder', Oilwell_config.Transport.duration * 1000,
false, false, {
disableMovement = true,
disableCarMovement = false,
disableMouse = false,
disableCombat = true
}, {}, {}, {}, function()
QBCore.Functions.TriggerCallback('keep-oilrig:server:oil_transport:fillTransportWell', function(res)
-- end_barell_animaiton()
end, inputData.amount)
end)
end
end)
local inventory_max_size = Oilwell_config.inventory_max_size
local function isBarellInInventory()
local items = QBCore.Functions.GetPlayerData().items
for slot = 1, inventory_max_size, 1 do
if items[slot] and items[slot].name == 'oilbarell' then
return true
end
end
return false
end
local already_started = false
function StartBarellAnimation()
if already_started then return end
already_started = true
CreateThread(function()
while true do
local b = isBarellInInventory()
if b then
if not active_prop then
start_barell_animation()
end
else
if active_prop then
end_barell_animaiton()
end
end
Wait(1500)
end
end)
end

View File

@ -0,0 +1,285 @@
local QBCore = exports['qb-core']:GetCoreObject()
local debugPoly = false
Targets['qb_target'] = {}
function Targets.qb_target.storage(coords, name)
local tmp_coord = vector3(coords.x, coords.y, coords.z + 2)
exports['qb-target']:AddCircleZone(name, tmp_coord, 1, {
name = name,
debugPoly = debugPoly,
useZ = true
}, {
options = {
{
type = "client",
event = "keep-oilrig:storage_menu:ShowStorage",
icon = "fa-solid fa-arrows-spin",
label = "Vis lager",
canInteract = function(entity)
if not CheckJob() then return false end
if not CheckOnduty() then
QBCore.Functions.Notify('Du skal være på job!', "error")
Wait(2000)
return false
end
return true
end,
},
},
distance = 2.5
})
end
function Targets.qb_target.distillation(coords, name)
local tmp_coord = vector3(coords.x, coords.y, coords.z + 1.1)
exports['qb-target']:AddCircleZone(name, tmp_coord, 1.2, {
name = name,
debugPoly = debugPoly,
useZ = true
}, {
options = {
{
type = "client",
event = "keep-oilrig:CDU_menu:ShowCDU",
icon = "fa-solid fa-gear",
label = "Åben CDU panel",
canInteract = function(entity)
if not CheckJob() then return false end
if not CheckOnduty() then
QBCore.Functions.Notify('Du skal være på job!', "error")
Wait(2000)
return false
end
return true
end,
},
},
distance = 1.5
})
end
function Targets.qb_target.toggle_job(coords, name)
local tmp_coord = vector3(coords.x, coords.y, coords.z + 1.1)
exports['qb-target']:AddCircleZone(name, tmp_coord, 0.75, {
name = name,
debugPoly = debugPoly,
useZ = true
}, {
options = {
{
type = "client",
event = "keep-oilrig:client:goOnDuty",
icon = "fa-solid fa-boxes-packing",
label = "Gå hjem/på arbejde",
canInteract = function(entity)
if not CheckJob() then return false end
return true
end,
},
},
distance = 2.5
})
end
function Targets.qb_target.barrel_withdraw(coords, name)
local tmp_coord = vector3(coords.x, coords.y, coords.z + 1.1)
exports['qb-target']:AddCircleZone(name, tmp_coord, 1.0, {
name = name,
debugPoly = debugPoly,
useZ = true
}, {
options = {
{
type = "client",
event = "keep-oilrig:client_lib:withdraw_from_queue",
icon = "fa-solid fa-boxes-packing",
label = "Overfør til lager",
truck = false,
canInteract = function(entity)
if not CheckJob() then return false end
if not CheckOnduty() then
QBCore.Functions.Notify('Du skal være på job!', "error")
Wait(2000)
return false
end
return true
end,
},
{
type = "client",
event = "keep-oilwell:client:openWithdrawStash",
icon = "fa-solid fa-boxes-packing",
label = "Open Withdraw Stash",
canInteract = function(entity)
if not CheckJob() then return false end
if not CheckOnduty() then
QBCore.Functions.Notify('Du skal være på job!', "error")
Wait(2000)
return false
end
return true
end,
},
{
type = "client",
event = "keep-oilwell:client:open_purge_menu",
icon = "fa-solid fa-trash-can",
label = "Tøm lager",
canInteract = function(entity)
if not CheckJob() then return false end
if not CheckOnduty() then
QBCore.Functions.Notify('Du skal være på job!', "error")
Wait(2000)
return false
end
return true
end,
},
},
distance = 2.5
})
end
function Targets.qb_target.blender(coords, name)
local tmp_coord = vector3(coords.x, coords.y, coords.z + 2.5)
exports['qb-target']:AddCircleZone(name, tmp_coord, 3.5, {
name = name,
debugPoly = debugPoly,
useZ = true
}, {
options = {
{
type = "client",
event = "keep-oilrig:blender_menu:ShowBlender",
icon = "fa-solid fa-gear",
label = "Åben blandingspanel",
canInteract = function(entity)
if not CheckJob() then return false end
if not CheckOnduty() then
QBCore.Functions.Notify('Du skal være på job!', "error")
Wait(2000)
return false
end
return true
end,
},
},
distance = 2.5
})
end
function Targets.qb_target.crude_oil_transport(coords, name)
local tmp_coord = vector3(coords.x, coords.y, coords.z + 2.5)
exports['qb-target']:AddCircleZone(name, tmp_coord, 2, {
name = name,
debugPoly = debugPoly,
useZ = true
}, {
options = {
{
type = "client",
event = "keep-oilwell:menu:show_transport_menu",
icon = "fa-solid fa-boxes-packing",
label = "Fyld transportbrønd",
canInteract = function(entity)
if not CheckJob() then return false end
if not CheckOnduty() then
QBCore.Functions.Notify('Du skal være på job!', "error")
Wait(2000)
return false
end
return true
end,
},
},
distance = 2.5
})
end
function Targets.qb_target.oilwell(coords, name)
local coord = vector3(coords.x, coords.y, coords.z + 2.5)
exports['qb-target']:AddCircleZone("oil-rig-" .. name, coord, 3.5, {
name = "oil-rig-" .. name,
debugPoly = false,
useZ = true,
}, {
options = {
{
type = "client",
event = "keep-oilrig:client:viewPumpInfo",
icon = "fa-solid fa-info",
label = "Se pumpe info",
canInteract = function(entity)
return true
end,
},
{
type = "client",
event = "keep-oilrig:client:changeRigSpeed",
icon = "fa-solid fa-gauge-high",
label = "Modificer pumpe indstillinger",
canInteract = function(entity)
if not CheckJob() then return false end
if not CheckOnduty() then return false end
return isOwner(entity)
end,
},
{
type = "client",
event = "keep-oilrig:client:show_oilwell_stash",
icon = "fa-solid fa-gears",
label = "Håndter dele",
canInteract = function(entity)
if not CheckJob() then return false end
if not CheckOnduty() then return false end
return isOwner(entity)
end,
},
{
type = "client",
event = "keep-oilwell:client:remove_oilwell",
icon = "fa-regular fa-file-lines",
label = "Fjern oliebrønd",
canInteract = function(entity)
if not CheckJob() then
return false
end
if not (PlayerJob.grade.level == 4) then
return false
end
if not CheckOnduty() then
return false
end
return true
end,
},
},
distance = 2.5
})
end
function Targets.qb_target.truck(plate, truck)
exports['qb-target']:AddEntityZone("device-" .. plate, truck, {
name = "device-" .. plate,
debugPoly = false,
}, {
options = {
{
type = "client",
event = "keep-oilwell:client:refund_truck",
icon = "fa-solid fa-location-arrow",
label = "Refunder køretøj",
vehiclePlate = plate
},
},
distance = 2.5
})
end

View File

@ -0,0 +1,137 @@
Targets = {}
local QBCore = exports['qb-core']:GetCoreObject()
local loaded = false
local PED = nil
local function setPedVariation(pedHnadle, variation)
for componentId, v in pairs(variation) do
if IsPedComponentVariationValid(pedHnadle, componentId, v.drawableId, v.textureId) then
SetPedComponentVariation(pedHnadle, componentId, v.drawableId, v.textureId)
end
end
end
function GETPED()
return PED
end
function SETPED(ped)
PED = ped
end
local function spawn_ped(data)
RequestModel(data.model)
while not HasModelLoaded(data.model) do
Wait(0)
end
if type(data.model) == 'string' then data.model = GetHashKey(data.model) end
local ped = CreatePed(1, data.model, data.coords, data.networked or false, true)
if data.variant then setPedVariation(ped, data.variant) end
if data.freeze then FreezeEntityPosition(ped, true) end
if data.invincible then SetEntityInvincible(ped, true) end
if data.blockevents then SetBlockingOfNonTemporaryEvents(ped, true) end
if data.animDict and data.anim then
RequestAnimDict(data.animDict)
while not HasAnimDictLoaded(data.animDict) do
Wait(0)
end
if type(data.anim) == "table" then
CreateThread(function()
while true do
local anim = data.anim[math.random(0, #data.anim)]
ClearPedTasks(ped)
TaskPlayAnim(ped, data.animDict, anim, 8.0, 0, -1, data.flag or 1, 0, 0, 0, 0)
SETPED(ped)
Wait(7000)
end
end)
else
TaskPlayAnim(ped, data.animDict, data.anim, 8.0, 0, -1, data.flag or 1, 0, 0, 0, 0)
end
end
if data.scenario then
SetPedCanPlayAmbientAnims(ped, true)
TaskStartScenarioInPlace(ped, data.scenario, 0, true)
end
if data.voice then
SetAmbientVoiceName(ped, 'A_F_Y_BUSINESS_01_WHITE_FULL_01')
end
SETPED(ped)
end
local function makeCore()
if loaded then return end
Citizen.CreateThread(function()
local c = Oilwell_config.TruckWithdraw.npc.coords
local vec3_coord = vector3(c.x, c.y, c.z)
PED = spawn_ped(Oilwell_config.TruckWithdraw.npc)
exports['qb-target']:AddBoxZone("keep_oilwell_withdraw_truck_target", vec3_coord,
Oilwell_config.TruckWithdraw.box.l,
Oilwell_config.TruckWithdraw.box.w,
{
name = "keep_oilwell_withdraw_truck_target",
heading = Oilwell_config.TruckWithdraw.box.heading,
debugPoly = false,
minZ = vec3_coord.z + Oilwell_config.TruckWithdraw.box.minz_offset,
maxZ = vec3_coord.z + Oilwell_config.TruckWithdraw.box.maxz_offset,
}, {
options = {
{
event = "keep-oilrig:client_lib:withdraw_from_queue",
icon = "fa-solid fa-truck-droplet",
label = 'Tag lastbil',
truck = true
},
},
distance = 2.0
})
loaded = true
end)
end
AddEventHandler('keep-oilwell:client:refund_truck', function(data)
local coord = GetEntityCoords(data.entity)
local spawnLocation = vector3(Oilwell_config.Delivery.SpawnLocation.x, Oilwell_config.Delivery.SpawnLocation.y,
Oilwell_config.Delivery.SpawnLocation.z)
local plate = data.vehiclePlate
if #(coord - spawnLocation) > 5.0 then
QBCore.Functions.Notify('Du er ikke tæt nok på, for at kunne refundere', "primary")
return
end
QBCore.Functions.TriggerCallback('keep-oilwell:server:refund_truck', function(result)
if result == true then
local netId = NetworkGetNetworkIdFromEntity(data.entity)
local entity = NetworkGetEntityFromNetworkId(netId)
NetworkRequestControlOfEntity(entity)
DeleteEntity(entity)
end
end, plate)
end)
AddEventHandler('onResourceStart', function(resourceName)
if (GetCurrentResourceName() ~= resourceName) then return end
Wait(1000)
makeCore()
end)
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
Wait(1000)
makeCore()
end)
AddEventHandler('onResourceStop', function(resourceName)
if resourceName ~= GetCurrentResourceName() then
return
end
DeleteEntity(GETPED())
end)

View File

@ -0,0 +1,167 @@
Oilwell_config = Oilwell_config or {}
Oilwell_config.inventory_max_size = 41
Oilwell_config.AnimationSpeedDivider = 20 -- higher value => less animation speed at 100%
Oilwell_config.actionSpeed = 5 -- how fast oilpump actionspeed is updated to new action speed / just visual
Oilwell_config.fuel_script = 'qb-fuel'
Oilwell_config.Settings = {
size = {
oilwell_storage = 10000,
},
oil_well = {
blip = {
sprite = 436,
colour = 5,
range = 'short',
-- CITIZENID | OILWELLNAME | DB_ID_RAW | TYPE | OILWELL_HASH
-- if scirpt detect this keywords inside string it will replace them.
name = 'Oil DB_ID_RAW'
}
},
capacity = {
oilbarell = {
size = 5000, -- gal
cost = 500
},
truck = {
size = 5000, -- gal placeholder
cost = 25000
}
}
}
Oilwell_config.locations = {
storage = {
position = vector4(1710.67, -1662.0, 110.8, 325.22),
rotation = vector3(0.0, 0.0, 0.0),
model = 'prop_storagetank_06',
blip = {
sprite = 478,
colour = 5,
range = 'short',
name = 'Olie-type'
}
},
distillation = {
position = vector4(1674, -1650.5, 110.2, 10),
rotation = vector3(0.0, 0.0, 10.0),
model = 'prop_gas_tank_01a',
blip = {
sprite = 467,
colour = 5,
range = 'short',
name = 'Olie-type'
}
},
blender = {
position = vector4(1737.56, -1635.58, 110.88, 190),
rotation = vector3(0.0, 0.0, 190.0),
model = 'prop_storagetank_01',
blip = {
sprite = 365,
colour = 5,
range = 'short',
name = 'Olie-type'
}
},
barrel_withdraw = {
position = vector4(1712.23, -1622.53, 111.48, 214.88),
rotation = vector3(0.0, 0.0, 0.0),
model = 'imp_prop_groupbarrel_03',
blip = {
sprite = 549,
colour = 5,
range = 'short',
name = 'Olie-type'
}
},
-- placeholder
-- oil_wellhead = {
-- position = vector4(1480.9, -1850.85, 70.1, 246.85),
-- rotation = vector3(0.0, 0.0, 0.0),
-- model = 'prop_oil_wellhead_01',
-- },
toggle_job = {
position = vector4(1703.5, -1635, 111.49, 100.11),
rotation = vector3(0.0, 0.0, 100.0),
model = 'xm_base_cia_server_02',
blip = {
sprite = 306,
colour = 5,
range = 'short',
name = 'Olie-type'
}
},
crude_oil_transport = {
position = vector4(1220.0, -2986.0, 4.7, 180),
rotation = vector3(0.0, 0.0, 180.0),
model = 'prop_oil_wellhead_04',
blip = {
sprite = 306,
colour = 5,
range = 'short',
name = 'Olie-type'
}
}
}
Oilwell_config.Delivery = {
refund = 20000,
TriggerLocation = vector3(1737.45, -1691.28, 112.73),
SpawnLocation = vector4(1741.19, -1694.61, 112.73, 125.57),
DinstanceToTrigger = 5.0,
vehicleModel = 'rallytruck'
}
Oilwell_config.Transport = {
max_stock = 20000, --gal per type
prices = {
crudeOil = 3,
gasoline = 7,
fuel_oil = 3.5
},
barell_refund = 200,
duration = 5 --sec
}
-- Make separate file for locale
Oilwell_config.Locale = {
mail = {
sender = 'Olie-firma',
subject = 'Betalings kvittering',
message = 'Kære %s %s, <br /><br />Denne email er en kopi af din kvittering.<br />Din betaling var: <strong>%.2f,-</strong><br />Solgt mængde : <strong> %d (liter)</strong><br />Tønde refundering : <strong> %d,-</strong>'
},
info = {
mr = 'Hr.',
mrs = 'Fr.',
}
}
Oilwell_config.TruckWithdraw = {
npc = {
model = 'S_M_Y_Construct_02',
variant = {},
coords = vector4(1737.49, -1691.76, 111.73, 116.07),
scenario = 'WORLD_HUMAN_CLIPBOARD',
flag = 1,
freeze = true,
invincible = true,
blockevents = true,
},
box = {
minz_offset = -1,
maxz_offset = 1.75,
w = 1.5,
l = 2.35,
heading = 160.0
}
}
-- prop_barrel_exp_01a.yft ron
-- prop_barrel_exp_01b.yft glob oil
-- prop_oil_wellhead_01
-- prop_oilcan_02a
-- vector3(998.08, -1859.08, 30.89)

View File

@ -0,0 +1,33 @@
fx_version 'cerulean'
games { 'gta5' }
author "Swkeep#7049"
shared_script { 'config.lua', 'shared/shared_main.lua' }
client_scripts {
'@menuv/menuv.lua',
'client/client.lua',
'client/client_lib/client_lib_entry.lua',
'client/client_lib/menu/CDU_menu.lua',
'client/client_lib/menu/edit_menu.lua',
'client/client_lib/menu/pump_menu.lua',
'client/client_lib/menu/storage_menu.lua',
'client/client_lib/menu/blender_menu.lua',
'client/client_lib/menu/transport_menu.lua',
'client/target/target.lua',
'client/target/qb_target.lua',
}
server_script {
'@oxmysql/lib/MySQL.lua',
'server/server_lib/server_lib_entry.lua',
'server/server_lib/Server_GlobalScirptData.lua',
'server/server_lib/refund.lua',
'server/server_main.lua',
}
dependency 'oxmysql'
lua54 'yes'

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -0,0 +1,715 @@
local QBCore = exports['qb-core']:GetCoreObject()
GlobalScirptData = {
oldTable = { 'deepcopy of oil_well' },
oil_well = {
['id'] = {
id = 'integer',
citizenid = 'string',
position = {
coord = { 'table' },
rotation = { 'table' }
},
name = 'string',
metadata = {
temp = 'float',
secduration = 'integer',
speed = 'integer',
oil_storage = 'float',
part_info = {
belt = 'float',
clutch = 'float',
polish = 'float'
}
},
state = 'bool',
oilrig_hash = 'string'
}
},
devices = {
oilrig_storage = {
{
id = 0,
citizenid = '',
name = '',
metadata = {
avg_gas_octane = 0,
gasoline = 0.0,
crudeOil = 0.0
},
}
},
oilrig_cdu = {
{
id = 0,
citizenid = '',
metadata = {
temp = 0.0,
req_temp = 0.0,
state = false,
oil_storage = 0.0,
},
}
},
oilrig_blender = {
{
id = 0,
citizenid = '',
metadata = {
heavy_naphtha = 0.0,
light_naphtha = 0.0,
other_gases = 0.0,
state = false,
recipe = {
heavy_naphtha = 0.0,
light_naphtha = 0.0,
other_gases = 0.0,
}
},
}
},
}
}
local serverUpdateInterval = 10000 -- database update interval
function GlobalScirptData:newOilwell(oilwell, employees)
if self.oil_well[oilwell] ~= nil then return end
local id = #employees + 1
employees[id] = {
id = id,
oilrig_hash = oilwell.oilrig_hash,
citizenid = oilwell.citizenid
}
self.oil_well[oilwell.id] = {}
self.oil_well[oilwell.id] = oilwell
-- last employee is owner of oilwell
self.oil_well[oilwell.id].employees = employees
self.oil_well[oilwell.id].is_employee = function(citizenid)
for key, value in ipairs(self.oil_well[oilwell.id].employees) do
if value.citizenid == citizenid then
if self.oil_well[oilwell.id].citizenid == citizenid then
return true, true
end
return true, false
end
end
return false, false
end
self.oil_well[oilwell.id].employees_list = function()
return self.oil_well[oilwell.id].employees
end
end
function GlobalScirptData:newDevice(device, Type)
if self.devices[Type][device.id] == nil then
self.devices[Type][device.id] = {}
end
if Type == 'oilrig_storage' then
device.metadata = json.decode(device.metadata)
self.devices.oilrig_storage[device.id] = device
elseif Type == 'oilrig_cdu' then
device.metadata = json.decode(device.metadata)
self.devices.oilrig_cdu[device.id] = device
elseif Type == 'oilrig_blender' then
device.metadata = json.decode(device.metadata)
self.devices.oilrig_blender[device.id] = device
end
end
function GlobalScirptData:saveThread()
CreateThread(function()
while true do
self.oldTable_oilwells = deepcopy(self.oil_well)
self.oldTable_oilrig_storage = deepcopy(self.devices.oilrig_storage)
self.oldTable_oilrig_cdu = deepcopy(self.devices.oilrig_cdu)
self.oldTable_oilrig_blender = deepcopy(self.devices.oilrig_blender)
Wait(serverUpdateInterval)
for id, value in pairs(self.oil_well) do
if not equals(self.oldTable_oilwells[id], self.oil_well[id]) then
GeneralUpdate_2({
type = 'oilrig_oilwell',
citizenid = value.citizenid,
oilrig_hash = value.oilrig_hash,
metadata = value.metadata
})
end
end
-- save storage data
for id, storage in pairs(self.devices.oilrig_storage) do
if not equals(self.oldTable_oilrig_storage[id], self.devices.oilrig_storage[id]) then
GeneralUpdate_2({
type = 'oilrig_storage',
citizenid = storage.citizenid,
metadata = storage.metadata
})
end
end
-- save CDU data
for id, storage in pairs(self.devices.oilrig_cdu) do
if not equals(self.oldTable_oilrig_cdu[id], self.devices.oilrig_cdu[id]) then
GeneralUpdate_2({
type = 'oilrig_cdu',
citizenid = storage.citizenid,
metadata = storage.metadata
})
end
end
for id, blender in pairs(self.devices.oilrig_blender) do
if not equals(self.oldTable_oilrig_blender[id], self.devices.oilrig_blender[id]) then
GeneralUpdate_2({
type = 'oilrig_blender',
citizenid = blender.citizenid,
metadata = blender.metadata
})
end
end
end
end)
end
--- wipes all data
function GlobalScirptData:wipeALL()
self.oil_well = {}
self.devices = {
oilrig_storage = {},
oilrig_cdu = {},
oilrig_blender = {},
}
self.oldTable_oilwells = {}
self.oldTable_oilrig_storage = {}
self.oldTable_oilrig_cdu = {}
self.oldTable_oilrig_blender = {}
end
function GlobalScirptData:getByHash(oilrig_hash)
for key, value in pairs(self.oil_well) do
if value.oilrig_hash == oilrig_hash then
return value, key
end
end
return false
end
function GlobalScirptData:read(id)
return self.oil_well[id]
end
function GlobalScirptData:readAll()
return self.oil_well
end
function GlobalScirptData:getDeviceById(Type, id)
return self.devices[Type][id]
end
function GlobalScirptData:getDeviceByCitizenId(Type, citizenid)
for key, value in pairs(self.devices[Type]) do
if value.citizenid == citizenid then
return value
end
end
return false
end
local function cal_avg_octane(res)
local avg = 0
for key, Type in pairs(res) do
avg = avg + Type.octane
end
return math.ceil((avg / 5) + 0.5)
end
local function blender_calculations(blender)
if blender.metadata.state == false then
return
end
local storage = GlobalScirptData:getDeviceByCitizenId('oilrig_storage', blender.citizenid)
if storage == false then
-- failsafe
local player = QBCore.Functions.GetPlayerByCitizenId(blender.citizenid)
TriggerClientEvent('QBCore:Notify', player.PlayerData.source, "Fatal fejl!", 'error')
TriggerClientEvent('QBCore:Notify', player.PlayerData.source, "Nødsikring aktiveret. Lukker ned!", 'primary')
blender.metadata.state = false
return
end
if blender.metadata.heavy_naphtha <= 0.0 then
blender.metadata.heavy_naphtha = 0.0
blender.metadata.state = false
return
end
-- blender.metadata.diesel
-- blender.metadata.kerosene
if blender.metadata.light_naphtha <= 0.0 then
blender.metadata.light_naphtha = 0.0
blender.metadata.state = false
return
end
if blender.metadata.other_gases <= 0.0 then
blender.metadata.other_gases = 0.0
blender.metadata.state = false
return
end
if blender.metadata.diesel <= 0.0 then
blender.metadata.diesel = 0.0
blender.metadata.state = false
return
end
if blender.metadata.kerosene <= 0.0 then
blender.metadata.kerosene = 0.0
blender.metadata.state = false
return
end
if not blender.metadata.recipe.diesel then
blender.metadata.recipe.diesel = 0
end
if not blender.metadata.recipe.kerosene then
blender.metadata.recipe.kerosene = 0
end
local res = {
light_naphtha = BalanceRecipe:Blender(tonumber(blender.metadata.recipe.light_naphtha), 'light_naphtha'),
heavy_naphtha = BalanceRecipe:Blender(tonumber(blender.metadata.recipe.heavy_naphtha), 'heavy_naphtha'),
other_gases = BalanceRecipe:Blender(tonumber(blender.metadata.recipe.other_gases), 'other_gases'),
--new elements
diesel = BalanceRecipe:Blender(tonumber(blender.metadata.recipe.diesel), 'diesel'),
kerosene = BalanceRecipe:Blender(tonumber(blender.metadata.recipe.kerosene), 'kerosene'),
}
blender.metadata.light_naphtha = blender.metadata.light_naphtha - res.light_naphtha.usage
blender.metadata.heavy_naphtha = blender.metadata.heavy_naphtha - res.heavy_naphtha.usage
blender.metadata.other_gases = blender.metadata.other_gases - res.other_gases.usage
-- new elements
blender.metadata.diesel = blender.metadata.diesel - res.diesel.usage
blender.metadata.kerosene = blender.metadata.kerosene - res.kerosene.usage
res.avg_octane = cal_avg_octane(res)
storage.metadata.avg_gas_octane = math.ceil((storage.metadata.avg_gas_octane + res.avg_octane) / 2)
storage.metadata.gasoline = Round(storage.metadata.gasoline + 0.75, 2)
end
local function CDUs_calculations(CDU)
if CDU.metadata.state == false then
if CDU.metadata.temp > 0 then
CDU.metadata.temp = CDU.metadata.temp - 15.0
else
CDU.metadata.temp = 0.0
end
return
end
-- increase temp until reach requestd temp
if CDU.metadata.req_temp > CDU.metadata.temp then
CDU.metadata.temp = CDU.metadata.temp + 15.0
elseif CDU.metadata.req_temp == CDU.metadata.temp then
CDU.metadata.temp = CDU.metadata.req_temp
end
-- a little bit of fun xd
if CDU.metadata.temp >= 1000 then
local player = QBCore.Functions.GetPlayerByCitizenId(CDU.citizenid)
CDU.metadata.temp = 0
CDU.metadata.state = false
TriggerClientEvent('keep-oilwell:server_lib:AddExplosion', player.PlayerData.source, 'distillation')
return
end
-- oil_storage > 1.0 min buffer
-- CDU functions on current temp if we have something in oil_storage
if CDU.metadata.oil_storage > 1.0 then
-- get storage to export CDU products
local blender = GlobalScirptData:getDeviceByCitizenId('oilrig_blender', CDU.citizenid)
if blender == false then
-- CUD's failsafe
local player = QBCore.Functions.GetPlayerByCitizenId(CDU.citizenid)
local source = player.PlayerData.source
TriggerClientEvent('QBCore:Notify', source, "Fatal fejl!", 'error')
TriggerClientEvent('QBCore:Notify', source, "Nødsikring aktiveret. Lukker ned!", 'primary')
CDU.metadata.state = false
return
end
local multi, o_type = BalanceRecipe:CDU(CDU.metadata.temp)
if multi and o_type then
CDU.metadata.oil_storage = CDU.metadata.oil_storage - multi
if blender.metadata[o_type] == nil then
blender.metadata[o_type] = 0
end
blender.metadata[o_type] = blender.metadata[o_type] + multi
end
end
end
local function oilwell_calculations(oil_well)
local pumpOverHeat = 327
local sotrage_size = Oilwell_config.Settings.size.oilwell_storage
if oil_well.metadata.speed > 0 then
oil_well.metadata.duration = oil_well.metadata.duration + 1
oil_well.metadata.secduration = oil_well.metadata.duration
if oil_well.metadata.temp ~= nil and pumpOverHeat >= oil_well.metadata.temp then
local temp = oil_well.metadata.temp
local speed = oil_well.metadata.speed
oil_well.metadata.temp = Round(tempGrowth(temp, speed, 'increase', pumpOverHeat), 2)
else
oil_well.metadata.temp = pumpOverHeat
end
if oil_well.metadata.speed <= 0 then return end
-- parts functions
if oil_well.metadata.part_info.belt > 0 then
local res = BalanceRecipe:SpeedRelated('OilwellBeltDegradation', oil_well.metadata.speed)
oil_well.metadata.part_info.belt = Round((oil_well.metadata.part_info.belt - res), 2)
elseif oil_well.metadata.part_info.belt <= 0 then
oil_well.metadata.part_info.belt = 0
oil_well.metadata.speed = 0
local player = QBCore.Functions.GetPlayerByCitizenId(oil_well.citizenid)
TriggerClientEvent('QBCore:Notify', player.PlayerData.source, 'Lukker ned. Ødelagt bælte', 'error')
TriggerClientEvent('keep-oilrig:client:syncSpeed', -1, oil_well.id, 0)
end
if oil_well.metadata.part_info.polish > 0 then
local res = BalanceRecipe:SpeedRelated('OilwellPolishDegradation', oil_well.metadata.speed)
oil_well.metadata.part_info.polish = Round((oil_well.metadata.part_info.polish - res), 2)
elseif oil_well.metadata.part_info.polish <= 0 then
oil_well.metadata.part_info.polish = 0
oil_well.metadata.speed = 0
local player = QBCore.Functions.GetPlayerByCitizenId(oil_well.citizenid)
TriggerClientEvent('QBCore:Notify', player.PlayerData.source, 'Lukker ned. Polish-værdi ramte 0', 'error')
TriggerClientEvent('keep-oilrig:client:syncSpeed', -1, oil_well.id, 0)
end
if oil_well.metadata.part_info.clutch > 0 then
local res = BalanceRecipe:SpeedRelated('OilwellClutchDegradation', oil_well.metadata.speed)
oil_well.metadata.part_info.clutch = Round((oil_well.metadata.part_info.clutch - res), 2)
elseif oil_well.metadata.part_info.clutch <= 0 then
oil_well.metadata.part_info.clutch = 0
oil_well.metadata.speed = 0
local player = QBCore.Functions.GetPlayerByCitizenId(oil_well.citizenid)
TriggerClientEvent('QBCore:Notify', player.PlayerData.source, 'Lukker ned. Ødelagt kobling', 'error')
TriggerClientEvent('keep-oilrig:client:syncSpeed', -1, oil_well.id, 0)
end
-- skip player oil if player one part is 0
if oil_well.metadata.part_info.clutch == 0 or oil_well.metadata.part_info.polish == 0 or
oil_well.metadata.part_info.belt == 0 then
return
end
if oil_well.metadata.temp > 0 and oil_well.metadata.temp < pumpOverHeat and
oil_well.metadata.oil_storage <= sotrage_size then
local res = BalanceRecipe:SpeedRelated('OilwellProdoction', oil_well.metadata.speed)
oil_well.metadata.oil_storage = oil_well.metadata.oil_storage + res
end
else
-- reset duration
oil_well.metadata.duration = 0
-- start cooling procces
if oil_well.metadata.secduration > 0 then
local temp = oil_well.metadata.temp
local speed = oil_well.metadata.speed
oil_well.metadata.secduration = oil_well.metadata.secduration - 1
oil_well.metadata.temp = Round(tempGrowth(temp, speed, 'decrease', pumpOverHeat), 2)
elseif oil_well.metadata.secduration == 0 then
oil_well.metadata.temp = 0
end
if oil_well.metadata.secduration > 0 and oil_well.metadata.temp == 0 then
oil_well.metadata.secduration = 0
end
end
end
-- Storage
function SendOilToStorage(oilrig, src, cb)
local storage = GlobalScirptData:getDeviceByCitizenId('oilrig_storage', oilrig.citizenid)
if storage == false then
InitStorage({
citizenid = oilrig.citizenid,
name = "'s inventar",
})
TriggerClientEvent('QBCore:Notify', src, "Kunne ikke tilgå inventar. Prøv igen!", 'error')
cb(false)
return
end
-- add to storage
if not storage then
TriggerClientEvent('QBCore:Notify', src, "Kunne ikke tilgå inventar. Prøv igen!", 'error')
return
end
storage.metadata.crudeOil = Round(storage.metadata.crudeOil + oilrig.metadata.oil_storage, 2)
TriggerClientEvent('QBCore:Notify', src, oilrig.metadata.oil_storage .. " liter råoile pumpet til lager")
-- remove from oilwell
oilrig.metadata.oil_storage = 0.0
cb(true)
end
function SendOilFuelToStorage(player, src, cb)
local citizenid = player.PlayerData.citizenid
local blender = GlobalScirptData:getDeviceByCitizenId('oilrig_blender', citizenid)
local storage = GlobalScirptData:getDeviceByCitizenId('oilrig_storage', citizenid)
if storage == false then
InitStorage({
citizenid = citizenid,
name = player.PlayerData.name .. "'s inventar",
})
TriggerClientEvent('QBCore:Notify', src, "Kunne ikke tilgå inventar. Prøv igen!", 'error')
cb(false)
return
end
if not blender then
TriggerClientEvent('QBCore:Notify', src, "Kunne ikke tilgå inventar. Prøv igen!", 'error')
cb(false)
return
end
if not storage.metadata.fuel_oil then
storage.metadata.fuel_oil = 0
end
if not blender.metadata.fuel_oil then
blender.metadata.fuel_oil = 0
end
if blender.metadata.fuel_oil == 0 then
TriggerClientEvent('QBCore:Notify', src, "Du har ingen brændselsolie!", 'error')
return
end
-- add to storage
storage.metadata.fuel_oil = Round((storage.metadata.fuel_oil + blender.metadata.fuel_oil), 2)
TriggerClientEvent('QBCore:Notify', src, blender.metadata.fuel_oil .. " liter brændselsolie pumpet til lager")
-- remove from oilwell
blender.metadata.fuel_oil = 0.0
cb(true)
end
function InitStorage(o, cb)
local sqlQuery = 'INSERT INTO oilrig_storage (citizenid,name,metadata) VALUES (?,?,?)'
local metadata = {
queue = {},
avg_gas_octane = 0,
gasoline = 0.0,
crudeOil = 0.0
}
MySQL.Async.fetchAll('SELECT * FROM oilrig_storage WHERE citizenid = ?', { o.citizenid }, function(res)
if next(res) then cb(false) return false end
local QueryData = {
o.citizenid,
o.name,
json.encode(metadata),
}
res = MySQL.Sync.insert(sqlQuery, QueryData)
if res ~= 0 then
-- inject into runtime
GlobalScirptData:newDevice({
id = res,
citizenid = o.citizenid,
name = o.name,
metadata = json.encode(metadata)
}, 'oilrig_storage')
if cb then
cb(GlobalScirptData:getDeviceByCitizenId('oilrig_storage', o.citizenid))
end
return true
end
cb(false)
return false
end)
end
-- End Storage
-- CDU
function Init_CDU(citizenid, cb)
local sqlQuery = 'INSERT INTO oilrig_cdu (citizenid,metadata) VALUES (?,?)'
local metadata = {
temp = 0.0,
req_temp = 0.0,
state = false,
oil_storage = 0.0
}
MySQL.Async.fetchAll('SELECT * FROM oilrig_cdu WHERE citizenid = ?', { citizenid }, function(res)
if next(res) then cb(false) return end
local QueryData = { citizenid, json.encode(metadata) }
res = MySQL.Sync.insert(sqlQuery, QueryData)
if res ~= 0 then
-- inject into runtime
GlobalScirptData:newDevice({
id = res,
citizenid = citizenid,
metadata = json.encode(metadata)
}, 'oilrig_cdu')
cb(GlobalScirptData:getDeviceByCitizenId('oilrig_cdu', citizenid))
return
end
cb(false)
end)
end
-- End CDU
-- Blender
function Init_Blender(citizenid, cb)
local sqlQuery = 'INSERT INTO oilrig_blender (citizenid,metadata) VALUES (?,?)'
local metadata = {
heavy_naphtha = 0.0,
light_naphtha = 0.0,
other_gases = 0.0,
state = false,
recipe = {
heavy_naphtha = 0.0,
light_naphtha = 0.0,
other_gases = 0.0,
}
}
MySQL.Async.fetchAll('SELECT * FROM oilrig_blender WHERE citizenid = ?', { citizenid }, function(res)
if next(res) then cb(false) end
local QueryData = {
citizenid,
json.encode(metadata),
}
res = MySQL.Sync.insert(sqlQuery, QueryData)
if res ~= 0 then
-- inject into runtime
GlobalScirptData:newDevice({
id = res,
citizenid = citizenid,
metadata = json.encode(metadata)
}, 'oilrig_blender')
cb(GlobalScirptData:getDeviceByCitizenId('oilrig_blender', citizenid))
return
end
cb(false)
end)
end
-- End Blender
----------------------
-- Data Manipulations
----------------------
local function startServerTick()
CreateThread(function()
while true do
for _, oil_well in pairs(GlobalScirptData.oil_well) do
oilwell_calculations(oil_well)
end
for _, CDU in pairs(GlobalScirptData.devices.oilrig_cdu) do
CDUs_calculations(CDU)
end
for _, blender in pairs(GlobalScirptData.devices.oilrig_blender) do
blender_calculations(blender)
end
Wait(1000)
end
end)
end
--------------------
-- DATABASE WRAPPER
--------------------
function Sync_with_database()
local o_w_sql = 'SELECT * FROM oilrig_position WHERE id = ? and deleted = false'
local e_sql = 'SELECT * FROM oilcompany_employees WHERE oilrig_hash = ?'
local fetch_oil_well = function(id)
local oil_well = {}
local oil_well_employees = {}
oil_well = MySQL.Sync.fetchAll(o_w_sql, { id })
oil_well_employees = MySQL.Sync.fetchAll(e_sql, { oil_well[1].oilrig_hash })
-- -- convert strings to josn type
oil_well[1].position = json.decode(oil_well[1].position)
oil_well[1].metadata = json.decode(oil_well[1].metadata)
return oil_well[1], oil_well_employees
end
local oil_wells = MySQL.Sync.fetchAll('SELECT id FROM `oilrig_position` WHERE deleted = false', {})
local oilrig_storage = {}
local oilrig_cdu = {}
local oilrig_blender = {}
for _, well in ipairs(oil_wells) do
local oil_well, employees = fetch_oil_well(well.id)
GlobalScirptData:newOilwell(oil_well, employees)
end
oilrig_storage = MySQL.Sync.fetchAll('SELECT * FROM oilrig_storage', {})
for _, value in ipairs(oilrig_storage) do
GlobalScirptData:newDevice(value, 'oilrig_storage')
end
oilrig_cdu = MySQL.Sync.fetchAll('SELECT * FROM oilrig_cdu', {})
for _, value in ipairs(oilrig_cdu) do
GlobalScirptData:newDevice(value, 'oilrig_cdu')
end
oilrig_blender = MySQL.Sync.fetchAll('SELECT * FROM oilrig_blender', {})
for _, value in ipairs(oilrig_blender) do
GlobalScirptData:newDevice(value, 'oilrig_blender')
end
-- print(Colors.blue .. 'Indlæser rapport (' .. GetCurrentResourceName() .. ')')
-- print(Colors.green .. '' .. #oil_wells .. ' oilebrønde')
-- print(Colors.green .. '' .. #oilrig_storage .. ' lagre')
-- print(Colors.green .. '' .. #oilrig_cdu .. ' CDU\'er')
-- print(Colors.green .. '' .. #oilrig_blender .. ' Blandere')
-- print(Colors.blue .. 'End of loading (' .. GetCurrentResourceName() .. ')')
GlobalScirptData:saveThread()
startServerTick()
end
function GeneralUpdate_2(options)
if options.type == nil then return end
local sqlQuery = ''
local QueryData = {}
for key, value in pairs(options.metadata) do
if type(value) == "number" then
options.metadata[key] = Round(value, 2)
end
end
if options.type == 'oilrig_storage' or options.type == 'oilrig_cdu' or options.type == 'oilrig_blender' then
sqlQuery = 'UPDATE ' .. options.type .. ' SET metadata = ? WHERE citizenid = ? AND metadata <> ?'
QueryData = {
json.encode(options.metadata), -- check if data is cahnged
options.citizenid,
json.encode(options.metadata) -- check if data is cahnged
}
elseif options.type == 'oilrig_oilwell' then
sqlQuery = 'UPDATE oilrig_position SET metadata = ? WHERE citizenid = ? AND oilrig_hash = ? AND metadata <> ?'
QueryData = {
json.encode(options.metadata), -- check if data is cahnged
options.citizenid,
options.oilrig_hash,
json.encode(options.metadata) -- check if data is cahnged
}
end
MySQL.Async.execute(sqlQuery, QueryData, function(e)
end)
end

View File

@ -0,0 +1,24 @@
local QBCore = exports['qb-core']:GetCoreObject()
local vehicles = {}
RegisterNetEvent('keep-oilwell:server_lib:update_vehicle', function(vehiclePlate, items)
local src = source
if not vehicles[src] then
vehicles[src] = {}
end
vehicles[src][vehiclePlate] = vehiclePlate
exports['ps-inventory']:addTrunkItems(vehiclePlate, items)
end)
QBCore.Functions.CreateCallback('keep-oilwell:server:refund_truck', function(source, cb, vehiclePlate)
if vehicles[source] then
if vehicles[source][vehiclePlate] then
local player = QBCore.Functions.GetPlayer(source)
player.Functions.AddMoney('bank', Oilwell_config.Delivery.refund, 'oil_barells')
vehicles[source][vehiclePlate] = nil
cb(true)
return
end
end
cb(false)
end)

View File

@ -0,0 +1,294 @@
BalanceRecipe = {}
function GeneralInsert(options)
local sqlQuery = 'INSERT INTO oilrig_position (citizenid,name,oilrig_hash,position,metadata,state) VALUES (?,?,?,?,?,?)'
local QueryData = {
options.citizenid,
options.name,
options.oilrig_hash,
json.encode(options.position),
json.encode(options.metadata),
options.state
}
return MySQL.Sync.insert(sqlQuery, QueryData)
end
function isTableChanged(oldTable, newTable)
if equals(oldTable, newTable, true) == false then
return true
else
return false
end
end
function equals(o1, o2, ignore_mt)
if o1 == o2 then return true end
local o1Type = type(o1)
local o2Type = type(o2)
if o1Type ~= o2Type then return false end
if o1Type ~= 'table' then return false end
if not ignore_mt then
local mt1 = getmetatable(o1)
if mt1 and mt1.__eq then
--compare using built in method
return o1 == o2
end
end
local keySet = {}
for key1, value1 in pairs(o1) do
local value2 = o2[key1]
if value2 == nil or equals(value1, value2, ignore_mt) == false then
return false
end
keySet[key1] = true
end
for key2, _ in pairs(o2) do
if not keySet[key2] then return false end
end
return true
end
function deepcopy(orig, copies)
copies = copies or {}
local orig_type = type(orig)
local copy
if orig_type == 'table' then
if copies[orig] then
copy = copies[orig]
else
copy = {}
copies[orig] = copy
for orig_key, orig_value in next, orig, nil do
copy[deepcopy(orig_key, copies)] = deepcopy(orig_value, copies)
end
setmetatable(copy, deepcopy(getmetatable(orig), copies))
end
else -- number, string, boolean, etc
copy = orig
end
return copy
end
local function inRange(x, min, max)
return (x >= min and x <= max)
end
local function getCurrentSpeed_maxTemp(speed)
if inRange(speed, 0, 10) then return 75
elseif inRange(speed, 10, 20) then return 100
elseif inRange(speed, 30, 40) then return 125
elseif inRange(speed, 40, 50) then return 170
elseif inRange(speed, 50, 60) then return 215
elseif inRange(speed, 60, 70) then return 260
elseif inRange(speed, 70, 80) then return 305
elseif inRange(speed, 80, 100) then return 327
else return 0
end
end
local function isOverHeatTemp(temp, max)
return (temp >= max)
end
function GetSpeedProdoctionMulti(speed)
local logic = {
[1] = { range = { 0, 10 }, multi = 0.02 },
[2] = { range = { 10, 20 }, multi = 0.03 },
[3] = { range = { 20, 30 }, multi = 0.04 },
[4] = { range = { 30, 40 }, multi = 0.05 },
[5] = { range = { 40, 50 }, multi = 0.06 },
[6] = { range = { 50, 60 }, multi = 0.07 },
[7] = { range = { 60, 70 }, multi = 0.08 },
[8] = { range = { 70, 80 }, multi = 0.09 },
[9] = { range = { 80, 90 }, multi = 0.1 },
[10] = { range = { 90, 100 }, multi = 0.12 },
}
for key, value in pairs(logic) do
if inRange(speed, value.range[1], value.range[2]) then
return value.multi
end
end
return 0
end
function GetSpeed_degradationMulti(speed)
local logic = {
[1] = { range = { 0, 10 }, multi = 0.025 },
[2] = { range = { 10, 20 }, multi = 0.03 },
[3] = { range = { 20, 30 }, multi = 0.035 },
[4] = { range = { 30, 40 }, multi = 0.040 },
[5] = { range = { 40, 50 }, multi = 0.045 },
[6] = { range = { 50, 60 }, multi = 0.050 },
[7] = { range = { 60, 70 }, multi = 0.055 },
[8] = { range = { 70, 80 }, multi = 0.06 },
[9] = { range = { 80, 90 }, multi = 0.068 },
[10] = { range = { 90, 100 }, multi = 0.075 },
}
for key, value in pairs(logic) do
if inRange(speed, value.range[1], value.range[2]) then
return value.multi
end
end
return 0
end
function BalanceRecipe:SpeedRelated(type, condition)
local data = {
['OilwellTemperatureGrowth'] = {
[1] = { range = { 0, 10 }, multi = 0.02 },
[2] = { range = { 10, 20 }, multi = 0.03 },
[3] = { range = { 20, 30 }, multi = 0.04 },
[4] = { range = { 30, 40 }, multi = 0.05 },
[5] = { range = { 40, 50 }, multi = 0.06 },
[6] = { range = { 50, 60 }, multi = 0.07 },
[7] = { range = { 60, 70 }, multi = 0.08 },
[8] = { range = { 70, 80 }, multi = 0.09 },
[9] = { range = { 80, 90 }, multi = 0.1 },
[10] = { range = { 90, 100 }, multi = 0.12 },
},
['OilwellProdoction'] = {
[1] = { range = { 0, 10 }, multi = 0.02 },
[2] = { range = { 10, 20 }, multi = 0.03 },
[3] = { range = { 20, 30 }, multi = 0.04 },
[4] = { range = { 30, 40 }, multi = 0.05 },
[5] = { range = { 40, 50 }, multi = 0.06 },
[6] = { range = { 50, 60 }, multi = 0.07 },
[7] = { range = { 60, 70 }, multi = 0.08 },
[8] = { range = { 70, 80 }, multi = 0.09 },
[9] = { range = { 80, 90 }, multi = 0.1 },
[10] = { range = { 90, 100 }, multi = 0.12 },
},
['OilwellClutchDegradation'] = {
[1] = { range = { 0, 10 }, multi = 0.025 },
[2] = { range = { 10, 20 }, multi = 0.03 },
[3] = { range = { 20, 30 }, multi = 0.035 },
[4] = { range = { 30, 40 }, multi = 0.040 },
[5] = { range = { 40, 50 }, multi = 0.045 },
[6] = { range = { 50, 60 }, multi = 0.050 },
[7] = { range = { 60, 70 }, multi = 0.055 },
[8] = { range = { 70, 80 }, multi = 0.06 },
[9] = { range = { 80, 90 }, multi = 0.065 },
[10] = { range = { 90, 100 }, multi = 0.07 },
},
['OilwellPolishDegradation'] = {
[1] = { range = { 0, 10 }, multi = 0.02 },
[2] = { range = { 10, 20 }, multi = 0.025 },
[3] = { range = { 20, 30 }, multi = 0.03 },
[4] = { range = { 30, 40 }, multi = 0.035 },
[5] = { range = { 40, 50 }, multi = 0.04 },
[6] = { range = { 50, 60 }, multi = 0.045 },
[7] = { range = { 60, 70 }, multi = 0.05 },
[8] = { range = { 70, 80 }, multi = 0.055 },
[9] = { range = { 80, 90 }, multi = 0.060 },
[10] = { range = { 90, 100 }, multi = 0.065 },
},
['OilwellBeltDegradation'] = {
[1] = { range = { 0, 10 }, multi = 0.025 },
[2] = { range = { 10, 20 }, multi = 0.03 },
[3] = { range = { 20, 30 }, multi = 0.035 },
[4] = { range = { 30, 40 }, multi = 0.040 },
[5] = { range = { 40, 50 }, multi = 0.045 },
[6] = { range = { 50, 60 }, multi = 0.050 },
[7] = { range = { 60, 70 }, multi = 0.055 },
[8] = { range = { 70, 80 }, multi = 0.06 },
[9] = { range = { 80, 90 }, multi = 0.065 },
[10] = { range = { 90, 100 }, multi = 0.07 },
},
}
for key, value in pairs(data[type]) do
if inRange(condition, value.range[1], value.range[2]) then
return value.multi
end
end
return 0
end
function BalanceRecipe:CDU(condition)
local data = {
[1] = { range = { 20, 50 }, multi = 0.65, o_type = 'other_gases' },
[2] = { range = { 50, 100 }, multi = 0.3, o_type = 'light_naphtha' },
[3] = { range = { 100, 150 }, multi = 0.5, o_type = 'light_naphtha' },
[4] = { range = { 150, 175 }, multi = 0.2, o_type = 'kerosene' },
[5] = { range = { 175, 200 }, multi = 0.25, o_type = 'heavy_naphtha' },
[6] = { range = { 200, 230 }, multi = 0.3, o_type = 'heavy_naphtha' },
[7] = { range = { 230, 260 }, multi = 0.35, o_type = 'diesel' },
[8] = { range = { 260, 30 }, multi = 0.4, o_type = 'diesel' },
[9] = { range = { 300, 600 }, multi = 0.8, o_type = 'fuel_oil' },
}
for key, value in pairs(data) do
if inRange(condition, value.range[1], value.range[2]) then
return value.multi, value.o_type
end
end
return 0, 'other_gases'
end
function BalanceRecipe:Blender(condition, Type)
local data = {
['other_gases'] = {
[1] = { range = { 0, 10 }, octane = 93, usage = 0.1 },
[2] = { range = { 10, 20 }, octane = 91, usage = 0.2 },
[3] = { range = { 20, 25 }, octane = 89, usage = 0.25 },
},
['kerosene'] = {
[1] = { range = { 5, 10 }, octane = 89, usage = 0.1 },
[2] = { range = { 10, 15 }, octane = 91, usage = 0.15 },
[3] = { range = { 15, 25 }, octane = 93, usage = 0.25 },
},
['diesel'] = {
[1] = { range = { 0, 0 }, octane = 93, usage = 0.0 },
[2] = { range = { 10, 20 }, octane = 91, usage = 0.25 },
[3] = { range = { 15, 25 }, octane = 89, usage = 0.35 },
},
['light_naphtha'] = {
[1] = { range = { 10, 20 }, octane = 89, usage = 0.06 },
[2] = { range = { 20, 40 }, octane = 91, usage = 0.16 },
[3] = { range = { 40, 60 }, octane = 93, usage = 0.39 },
},
['heavy_naphtha'] = {
[1] = { range = { 80, 60 }, octane = 93, usage = 0.24 },
[2] = { range = { 60, 40 }, octane = 91, usage = 0.24 },
[3] = { range = { 40, 0 }, octane = 89, usage = 0.26 },
},
}
for key, value in pairs(data[Type]) do
if inRange(condition, value.range[1], value.range[2]) then
return { octane = value.octane, usage = value.usage }
end
end
return { octane = 87, usage = 0.4 }
end
function tempGrowth(tmp, speed, Type, max)
if tmp == nil then return 0 end
if Type == 'increase' then
if isOverHeatTemp(tmp, max) then return tmp end
if inRange(speed, 0, 100) then
local max_temp = getCurrentSpeed_maxTemp(speed)
tmp = tmp + BalanceRecipe:SpeedRelated('OilwellTemperatureGrowth', speed)
if tmp >= max_temp then
tmp = max_temp
end
return tmp
else
return 0
end
return 0
end
-- decrease
if tmp > 0 then
tmp = tmp - 10
else
tmp = 0
end
return tmp
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,120 @@
function RandomHash(length)
local res = ""
for i = 1, length do
res = res .. string.char(math.random(97, 122))
end
return res
end
---print tables : debug
---@param node table
function print_table(node)
local cache, stack, output = {}, {}, {}
local depth = 1
local output_str = "{\n"
while true do
local size = 0
for k, v in pairs(node) do
size = size + 1
end
local cur_index = 1
for k, v in pairs(node) do
if (cache[node] == nil) or (cur_index >= cache[node]) then
if (string.find(output_str, "}", output_str:len())) then
output_str = output_str .. ",\n"
elseif not (string.find(output_str, "\n", output_str:len())) then
output_str = output_str .. "\n"
end
-- This is necessary for working with HUGE tables otherwise we run out of memory using concat on huge strings
table.insert(output, output_str)
output_str = ""
local key
if (type(k) == "number" or type(k) == "boolean") then
key = "[" .. tostring(k) .. "]"
else
key = "['" .. tostring(k) .. "']"
end
if (type(v) == "number" or type(v) == "boolean") then
output_str = output_str .. string.rep('\t', depth) .. key .. " = " .. tostring(v)
elseif (type(v) == "table") then
output_str = output_str .. string.rep('\t', depth) .. key .. " = {\n"
table.insert(stack, node)
table.insert(stack, v)
cache[node] = cur_index + 1
break
else
output_str = output_str .. string.rep('\t', depth) .. key .. " = '" .. tostring(v) .. "'"
end
if (cur_index == size) then
output_str = output_str .. "\n" .. string.rep('\t', depth - 1) .. "}"
else
output_str = output_str .. ","
end
else
-- close the table
if (cur_index == size) then
output_str = output_str .. "\n" .. string.rep('\t', depth - 1) .. "}"
end
end
cur_index = cur_index + 1
end
if (size == 0) then
output_str = output_str .. "\n" .. string.rep('\t', depth - 1) .. "}"
end
if (#stack > 0) then
node = stack[#stack]
stack[#stack] = nil
depth = cache[node] == nil and depth + 1 or depth - 1
else
break
end
end
-- This is necessary for working with HUGE tables otherwise we run out of memory using concat on huge strings
table.insert(output, output_str)
output_str = table.concat(output)
-- print(output_str)
end
function Round(num, dp)
--[[
round a number to so-many decimal of places, which can be negative,
e.g. -1 places rounds to 10's,
examples
173.2562 rounded to 0 dps is 173.0
173.2562 rounded to 2 dps is 173.26
173.2562 rounded to -1 dps is 170.0
]] --
local mult = 10 ^ (dp or 0)
return math.floor(num * mult + 0.5) / mult
end
function Tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end
Colors = {
red = "\027[31m",
green = "\027[32m",
orange = "\027[33m",
cyan = "\027[36m",
gray = "\027[90m",
grey = "\027[90m",
light_green = "\027[92m",
yellow = "\027[93m",
blue = "\027[94m",
}

View File

@ -0,0 +1,49 @@
CREATE TABLE IF NOT EXISTS `oilrig_position` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`citizenid` varchar(50) DEFAULT NULL,
`name` varchar(50) DEFAULT NULL,
`oilrig_hash` varchar(50) DEFAULT NULL,
`position` TEXT NOT NULL DEFAULT '0',
`metadata` TEXT NOT NULL DEFAULT '0',
`state` BOOLEAN NOT NULL DEFAULT FALSE,
`deleted` BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY (`id`),
KEY `citizenid` (`citizenid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `oilrig_storage` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`citizenid` varchar(50) DEFAULT NULL,
`name` varchar(50) DEFAULT NULL,
`metadata` TEXT NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `citizenid` (`citizenid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `oilrig_cdu` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`citizenid` varchar(50) DEFAULT NULL,
`metadata` TEXT NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `citizenid` (`citizenid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `oilrig_blender` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`citizenid` varchar(50) DEFAULT NULL,
`metadata` TEXT NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `citizenid` (`citizenid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
-- Patch 1.1.0 new part
CREATE TABLE IF NOT EXISTS `oilcompany_employees` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`citizenid` varchar(50) DEFAULT NULL,
`oilrig_hash` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `citizenid` (`citizenid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
-- for pre exsting users to update their database don't use it on a fresh install
-- ALTER TABLE `oilrig_position` ADD `deleted` BOOLEAN NOT NULL DEFAULT FALSE;

View File

@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -0,0 +1,209 @@
# kloud-farmjob
Dive into the world of a simple farmer, gather crops and sell it for money!
# Features
* Highly Configurable
* Easily Add Locations
* Highly Optimized (0.00ms Idle & 0.00 ~ 0.09 ms Active)
* Usage of Targeting Script for more immersive experience
* Smooth Animations
# Preview
https://youtu.be/xaWnb6a1-Uc
# Dependencies
**Required**
* [ox_lib](https://github.com/overextended/ox_lib)
**Framework**
- [qb-core](https://github.com/qbcore-framework/qb-core)
- [qbx-core](https://github.com/Qbox-project/qbx-core)
- [es_extended](https://github.com/esx-framework/esx_core)
**Target**
- [qb-target](https://github.com/qbcore-framework/qb-target)
- [ox_target](https://github.com/overextended/ox_target)
**Inventory**
- [qb-inventory](https://github.com/qbcore-framework/qb-inventory)
- [lj-inventory](https://github.com/loljoshie/lj-inventory)
- [ps-inventoy](https://github.com/Project-Sloth/ps-inventory)
- [ox_inventory](https://overextended.dev/ox_inventory)
# Installation
Join my [Discord Server](https://discord.gg/DbqC2SWzJk) for updates
## Configuration
### Language
Add this to your server.cfg
```cfg
setr ox:locale en
```
## server.cfg
```cfg
ensure FRAMEWORK # es_extended / qb-core
ensure ox_lib
ensure TARGET # ox_target / qb-target
ensure INVENTORY # ox_inventory / qb-inventory / lj-inventory
ensure kloud-farm
```
## For qb-core
### qb-core\shared\items.lua
```lua
['potato'] = {['name'] = 'potato', ['label'] = 'Potato', ['weight'] = 350, ['type'] = 'item', ['image'] = 'potato.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Po-ta-to'},
['dirty_potato'] = {['name'] = 'dirty_potato', ['label'] = 'Dirty Potato', ['weight'] = 350, ['type'] = 'item', ['image'] = 'dirty_potato.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Po-ta-to'},
['tomato'] = {['name'] = 'tomato', ['label'] = 'Tomato', ['weight'] = 350, ['type'] = 'item', ['image'] = 'tomato.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'To-ma-to'},
['dirty_tomato'] = {['name'] = 'dirty_tomato', ['label'] = 'Dirty Tomato', ['weight'] = 350, ['type'] = 'item', ['image'] = 'dirty_tomato.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'To-ma-to'},
['coffee_beans'] = {['name'] = 'coffee_beans', ['label'] = 'Coffee Beans', ['weight'] = 350, ['type'] = 'item', ['image'] = 'coffee_beans.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Wakey wakey!'},
['dirty_coffee_beans'] = {['name'] = 'dirty_coffee_beans', ['label'] = 'Dirty Coffee Beans', ['weight'] = 350, ['type'] = 'item', ['image'] = 'dirty_coffee_beans.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Wakey wakey!'},
['cabbage'] = {['name'] = 'cabbage', ['label'] = 'Cabbage', ['weight'] = 350, ['type'] = 'item', ['image'] = 'cabbage.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Let-tuce? No!'},
['dirty_cabbage'] = {['name'] = 'dirty_cabbage', ['label'] = 'Dirty Cabbage', ['weight'] = 350, ['type'] = 'item', ['image'] = 'dirty_cabbage.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Let-tuce? No!'},
['orange'] = {['name'] = 'orange', ['label'] = 'Orange', ['weight'] = 350, ['type'] = 'item', ['image'] = 'orange.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'The talking orange!'},
['dirty_orange'] = {['name'] = 'dirty_orange', ['label'] = 'Dirty Orange', ['weight'] = 350, ['type'] = 'item', ['image'] = 'dirty_orange.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'The talking orange!'},
['trowel'] = {['name'] = 'trowel', ['label'] = 'Trowel', ['weight'] = 350, ['type'] = 'item', ['image'] = 'trowel.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Mini-shovel yes'},
['shovel'] = {['name'] = 'shovel', ['label'] = 'Shovel', ['weight'] = 350, ['type'] = 'item', ['image'] = 'shovel.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Legit shovel yes'},
```
## For ox_inventory
### ox_inventory\data\items.lua
```lua
['trowel'] = {
label = 'Trowel',
weight = 500,
decay = true,
stack = false,
close = false,
description = 'Diggy Diggy Diggy?',
},
['shovel'] = {
label = 'Shovel',
weight = 1000,
decay = true,
stack = false,
close = false,
description = 'Diggy Diggy Diggy?',
},
['dirty_potato'] = {
label = 'Dirty Potato',
weight = 250,
degrade = 7160,
decay = true,
stack = true,
close = false,
description = 'Potato potato but dirty dirty?',
},
['potato'] = {
label = 'Potato',
weight = 250,
degrade = 7160,
decay = true,
stack = true,
close = false,
description = 'Potato potato?',
},
['dirty_cabbage'] = {
label = 'Dirty Cabbage',
weight = 250,
degrade = 7160,
decay = true,
stack = true,
close = false,
description = 'Cabby cabby but dirty dirty?',
},
['cabbage'] = {
label = 'Cabbage',
weight = 250,
degrade = 7160,
decay = true,
stack = true,
close = false,
description = 'Cabby cabby?',
},
['dirty_tomato'] = {
label = 'Dirty Tomato',
weight = 250,
degrade = 7160,
decay = true,
stack = true,
close = false,
description = 'To-ma-to but dirty',
},
['tomato'] = {
label = 'Tomato',
weight = 250,
degrade = 7160,
decay = true,
stack = true,
close = false,
description = 'To-ma-to',
},
['dirty_orange'] = {
label = 'Dirty Orange',
weight = 250,
degrade = 7160,
decay = true,
stack = true,
close = false,
description = 'It talks!!!!',
},
['orange'] = {
label = 'Orange',
weight = 250,
degrade = 7160,
decay = true,
stack = true,
close = false,
description = 'It talks!!!!',
},
['dirty_coffee_beans'] = {
label = 'Dirty Coffee Beans',
weight = 250,
degrade = 7160,
decay = true,
stack = true,
close = false,
description = 'Ohh wakey wakey but dirty',
},
['coffee_beans'] = {
label = 'Coffee Beans',
weight = 250,
degrade = 7160,
decay = true,
stack = true,
close = false,
description = 'Ohh wakey wakey but dirty',
},
```
# Support & Suggestions
Contact me at my discord @ybarra. or join my Discord Server! <br>![Discord Server](https://discordapp.com/api/guilds/1131198002976014377/widget.png?style=shield)

View File

@ -0,0 +1,37 @@
if GetResourceState("es_extended") ~= "started" then return end
ESX = exports["es_extended"]:getSharedObject()
PlayerData = {}
PlayerJob = {}
PlayerLoaded = false
RegisterNetEvent('esx:playerLoaded', function(xPlayer)
JobInfo = xPlayer.job
UpdateJobInfo(JobInfo)
PlayerLoaded = true
end)
RegisterNetEvent('esx:onPlayerLogout', function()
table.wipe(PlayerData)
table.wipe(PlayerJob)
end)
RegisterNetEvent('esx:setJob', function(JobInfo)
UpdateJobInfo(JobInfo)
end)
AddEventHandler('onResourceStart', function(resourceName)
if GetCurrentResourceName() ~= resourceName then return end
PlayerData = ESX.GetPlayerData()
UpdateJobInfo(PlayerData.job)
PlayerLoaded = ESX.PlayerLoaded
end)
UpdateJobInfo = function(info)
PlayerJob.grade = {}
PlayerJob.name = info.name
PlayerJob.grade.level = info.grade
end

View File

@ -0,0 +1,52 @@
if GetResourceState("qb-core") ~= "started" then return end
QBCore = exports['qb-core']:GetCoreObject()
PlayerData = {}
PlayerJob = {}
PlayerLoaded = false
---@diagnostic disable-next-line: param-type-mismatch
AddStateBagChangeHandler('isLoggedIn', nil, function(_bagName, _key, value, _reserved, _replicated)
if value then
PlayerData = QBCore.Functions.GetPlayerData()
UpdateJobInfo(PlayerData.job)
else
table.wipe(PlayerData)
table.wipe(PlayerJob)
end
PlayerLoaded = value
end)
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
JobInfo = QBCore.Functions.GetPlayerData().job
UpdateJobInfo(JobInfo)
end)
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
table.wipe(PlayerData)
table.wipe(PlayerJob)
end)
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo)
UpdateJobInfo(JobInfo)
end)
RegisterNetEvent('QBCore:Player:SetPlayerData', function(newPlayerData)
local invokingResource = GetInvokingResource()
if invokingResource and invokingResource ~= 'qb-core' then return end
PlayerData = newPlayerData
end)
AddEventHandler('onResourceStart', function(resourceName)
if GetCurrentResourceName() ~= resourceName or not LocalPlayer.state.isLoggedIn then return end
PlayerData = QBCore.Functions.GetPlayerData()
UpdateJobInfo(PlayerData.job)
PlayerLoaded = true
end)
UpdateJobInfo = function(info)
PlayerJob.grade = {}
PlayerJob.name = info.name
PlayerJob.grade.level = info.grade.level
end

View File

@ -0,0 +1,47 @@
if GetResourceState("es_extended") ~= "started" then return end
CreateThread(function()
Wait(200)
-- print("^5ESX found! Loading ESX functions^0")
if GetResourceState("ox_inventory") ~= "started" then
-- print("^1Can't find ox_inventory, start it before this script^0")
end
end)
ESX = exports['es_extended']:getSharedObject()
GetPlayer = function(target)
local Player = ESX.GetPlayerFromId(target)
return Player
end
AddMoney = function(target, type, amount, reason)
local Player = GetPlayer(target)
if type == "cash" then
type = "money"
end
return Player.addAccountMoney(type, amount)
end
RemoveMoney = function(target, type, amount, reason)
local Player = GetPlayer(target)
if type == "cash" then
type = "money"
end
return Player.removeAccountMoney(type, amount)
end
GetMoney = function(target, type)
local Player = GetPlayer(target)
if type == "cash" then
type = "money"
end
return Player.getAccount(type).money
end

View File

@ -0,0 +1,26 @@
if GetResourceState("qb-core") ~= "started" then return end
QBCore = exports['qb-core']:GetCoreObject()
GetPlayer = function(target)
local Player = QBCore.Functions.GetPlayer(target)
return Player
end
AddMoney = function(target, type, amount, reason)
local Player = GetPlayer(target)
return Player.Functions.AddMoney(type, amount, reason)
end
RemoveMoney = function(target, type, amount, reason)
local Player = GetPlayer(target)
return Player.Functions.RemoveMoney(type, amount, reason)
end
GetMoney = function(target, type)
local Player = GetPlayer(target)
return Player.PlayerData.money[type]
end

View File

@ -0,0 +1,37 @@
fx_version 'cerulean'
game 'gta5'
lua54 'yes'
author 'kloud'
description 'Advanced Farming Job Made for QB/Qbox/ESX by Kloud'
version '1.0.0'
shared_scripts {
'@ox_lib/init.lua',
'shared/*.lua'
}
client_scripts {
'target/*.lua',
'modules/**/*.lua',
'inventory/client/*.lua',
'framework/client/*.lua',
'init.lua',
}
server_scripts {
'@oxmysql/lib/MySQL.lua',
'inventory/server/*.lua',
'framework/server/*.lua',
'server.lua',
}
files {
'locales/*.json'
}
dependencies {
'oxmysql',
'ox_lib'
}

View File

@ -0,0 +1,221 @@
_T = {
Zone = {},
Props = {},
Blip = {},
PickedTrees = {},
Peds = {},
}
_G = {
InZone = false,
IsBusy = false,
CurrentZone = nil,
Cooldown = false
}
Start = function()
for zone, info in pairs(KloudDev.Locations) do
_T.Zone[zone] = lib.zones.sphere({
coords = info.coords,
radius = info.zoneRadius,
debug = KloudDev.Debug,
onEnter = function()
if info.job and PlayerJob.name ~= info.job then return end
_G.InZone = true
_G.CurrentZone = zone
SpawnProps(zone)
end,
onExit = function()
_G.InZone = false
_G.CurrentZone = nil
ClearProps()
end
})
end
for zone, info in pairs(KloudDev.Trees) do
if info.zoneType == "sphere" then
_T.Zone[zone] = lib.zones.sphere({
coords = info.coords,
radius = info.zoneRadius,
debug = KloudDev.Debug,
onEnter = function()
if info.job and PlayerJob.name ~= info.job then return end
_G.InZone = true
_G.CurrentZone = zone
end,
onExit = function()
_G.InZone = false
_G.CurrentZone = nil
end
})
elseif info.zoneType == "poly" then
lib.zones.poly({
points = info.zonePoints,
thickness = 25,
debug = KloudDev.Debug,
onEnter = function()
if info.job and PlayerJob.name ~= info.job then return end
_G.InZone = true
_G.CurrentZone = zone
end,
onExit = function()
_G.InZone = false
_G.CurrentZone = nil
end
})
end
end
CreateBlips()
CreateTargets()
CreatePeds()
end
CreateBlips = function()
for zone, info in pairs(KloudDev.Locations) do
if info.blip.enabled then
_T.Blip[zone] = AddBlipForCoord(info.coords.x, info.coords.y, info.coords.z)
SetBlipSprite(_T.Blip[zone], info.blip.sprite)
SetBlipDisplay(_T.Blip[zone], 4)
SetBlipScale(_T.Blip[zone], info.blip.scale)
SetBlipColour(_T.Blip[zone], info.blip.colour)
SetBlipAsShortRange(_T.Blip[zone], true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(info.blip.label)
EndTextCommandSetBlipName(_T.Blip[zone])
end
end
for zone, info in pairs(KloudDev.Trees) do
if info.blip.enabled then
_T.Blip[zone] = AddBlipForCoord(info.coords.x, info.coords.y, info.coords.z)
SetBlipSprite(_T.Blip[zone], info.blip.sprite)
SetBlipDisplay(_T.Blip[zone], 4)
SetBlipScale(_T.Blip[zone], info.blip.scale)
SetBlipColour(_T.Blip[zone], info.blip.colour)
SetBlipAsShortRange(_T.Blip[zone], true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(info.blip.label)
EndTextCommandSetBlipName(_T.Blip[zone])
end
end
for zone, info in pairs(KloudDev.Shops) do
if info.blip.enabled then
for _, coords in pairs(info.coords) do
_T.Blip[zone] = AddBlipForCoord(coords.x, coords.y, coords.z)
SetBlipSprite(_T.Blip[zone], info.blip.sprite)
SetBlipDisplay(_T.Blip[zone], 4)
SetBlipScale(_T.Blip[zone], info.blip.scale)
SetBlipColour(_T.Blip[zone], info.blip.colour)
SetBlipAsShortRange(_T.Blip[zone], true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(info.blip.label)
EndTextCommandSetBlipName(_T.Blip[zone])
end
end
end
if KloudDev.WashLocations.blip.enabled then
for k, coords in pairs(KloudDev.WashLocations.coords) do
_T.Blip["Wash"..k] = AddBlipForCoord(coords.x, coords.y, coords.z)
SetBlipSprite(_T.Blip["Wash"..k], KloudDev.WashLocations.blip.sprite)
SetBlipDisplay(_T.Blip["Wash"..k], 4)
SetBlipScale(_T.Blip["Wash"..k], KloudDev.WashLocations.blip.scale)
SetBlipColour(_T.Blip["Wash"..k], KloudDev.WashLocations.blip.colour)
SetBlipAsShortRange(_T.Blip["Wash"..k], true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(KloudDev.WashLocations.blip.label)
EndTextCommandSetBlipName(_T.Blip["Wash"..k])
end
end
end
CreateTargets = function()
for zone, info in pairs(KloudDev.Trees) do
if info.job and PlayerJob.name ~= info.job then return end
AddTargetModel(info.prop, {
{
event = 'kloud-farm:client:pickTree',
label = info.target.label,
name = "PickTrees",
icon = info.target.icon,
currentZone = zone,
canInteract = function(entity)
if not _G.IsBusy and _G.InZone and CanPick(entity) and _G.CurrentZone == zone then return true end
return false
end,
distance = 2,
}
})
end
for _, coords in pairs(KloudDev.WashLocations.coords) do
lib.zones.sphere({
coords = coords,
radius = 4.5,
debug = KloudDev.Debug,
onEnter = function()
DrawText(locale("press_wash_crops", "[E]"))
end,
onExit = function()
HideText()
end,
inside = function ()
if not _G.IsBusy and IsControlJustPressed(0, 38) then
TriggerEvent("kloud-farm:client:wash")
end
if _G.IsBusy then
HideText()
end
end
})
end
end
CreatePeds = function()
while not PlayerLoaded do Wait(100) end
for k, v in pairs(KloudDev.Shops) do
for _, coords in pairs(v.coords) do
if k == "sell" then
local model = v.pedModels[math.random(1, #v.pedModels)]
lib.requestModel(model, 10000)
_T.Peds[k] = CreatePed(5, joaat(model), coords.x, coords.y, coords.z, coords.w, false, false)
FreezeEntityPosition(_T.Peds[k], true)
SetBlockingOfNonTemporaryEvents(_T.Peds[k], true)
SetEntityInvincible(_T.Peds[k], true)
AddEntityTarget(_T.Peds[k], {
{
event = 'kloud-farm:client:openSell',
label = locale('open_sell'),
name = "kloud-farm:openSell",
icon = "fas fa-basket-shopping",
distance = 2.5,
},
})
SetModelAsNoLongerNeeded(model)
end
if k == "shop" then
local model = v.pedModels[math.random(1, #v.pedModels)]
lib.requestModel(model, 10000)
_T.Peds[k] = CreatePed(5, joaat(model), coords.x, coords.y, coords.z, coords.w, false, false)
FreezeEntityPosition(_T.Peds[k], true)
SetBlockingOfNonTemporaryEvents(_T.Peds[k], true)
SetEntityInvincible(_T.Peds[k], true)
AddEntityTarget(_T.Peds[k], {
{
event = 'kloud-farm:client:openShop',
label = locale('open_shop'),
name = "kloud-farm:openShop",
icon = "fas fa-basket-shopping",
distance = 2.5,
},
})
SetModelAsNoLongerNeeded(model)
end
end
end
end
CreateThread(Start)

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

@ -0,0 +1,7 @@
if GetResourceState("ox_inventory") ~= "started" then return end
Inventory = exports.ox_inventory
GetItemCount = function(itemName, metadata, strict)
return Inventory:GetItemCount(itemName, metadata, strict)
end

View File

@ -0,0 +1,23 @@
local qbVariations = {"qb-inventory", "ps-inventory", "lj-inventory"}
local Inventory = exports["qb-inventory"]
local foundInv = false
for i = 1, #qbVariations do
if GetResourceState(qbVariations[i]) ~= "started" then
if i == #qbVariations then
if not foundInv then
return
end
end
else
foundInv = true
Inventory = exports[qbVariations[i]]
KloudDev.ImagePath = "https://cfx-nui-".. qbVariations[i] .. "/html/images/"
end
end
GetItemCount = function(itemName, metadata, strict)
local count = lib.callback.await("GetItemCount", false, itemName)
return count
end

View File

@ -0,0 +1,8 @@
if GetResourceState("qs-inventory") ~= "started" then return end
Inventory = exports["qs-inventory"]
GetItemCount = function(itemName, metadata, strict)
local count = lib.callback.await("GetItemCount", false, itemName)
return count
end

View File

@ -0,0 +1,28 @@
if GetResourceState("ox_inventory") ~= "started" then return end
Inventory = exports.ox_inventory
AddItem = function(inv, item, amount, metadata)
return Inventory:AddItem(inv, item, amount, metadata)
end
RemoveItem = function(inv, item, amount, metadata, slot)
return Inventory:RemoveItem(inv, item, amount, metadata, slot)
end
CanCarryItem = function(inv, item, amount)
return Inventory:CanCarryItem(inv, item, amount)
end
GetItemCount = function(inv, item)
if Inventory:GetItemCount(inv, item, nil, false) >= 1 then return true end
return false
end
GetSlotWithItem = function(inv, item, metadata, strict)
return Inventory:GetSlotWithItem(inv, item, metadata, strict)
end
SetDurability = function(inv, slot, durability)
return Inventory:SetDurability(inv, slot, durability)
end

View File

@ -0,0 +1,62 @@
local qbVariations = {"qb-inventory", "ps-inventory", "lj-inventory"}
local Inventory = exports["qb-inventory"]
local foundInv = false
for i = 1, #qbVariations do
if GetResourceState(qbVariations[i]) ~= "started" then
if i == #qbVariations then
if not foundInv then
return
end
end
else
foundInv = true
Inventory = exports[qbVariations[i]]
end
end
AddItem = function(inv, item, amount, metadata)
if Inventory:AddItem(inv, item, amount, false, metadata) then
for i = 1, amount do
TriggerClientEvent('inventory:client:ItemBox', inv, QBCore.Shared.Items[item], 'add')
end
return true
end
return false
end
RemoveItem = function(inv, item, amount, metadata, slot)
if Inventory:RemoveItem(inv, item, amount, slot) then
for i = 1, amount do
TriggerClientEvent('inventory:client:ItemBox', inv, QBCore.Shared.Items[item], 'remove')
end
return true
end
return false
end
CanCarryItem = function(inv, item, amount)
return true
end
GetItemCount = function(inv, item)
if #Inventory:GetItemsByName(inv, item) >= 1 then return true end
return false
end
GetSlotWithItem = function(inv, item, metadata, strict)
local Player = GetPlayer(inv)
return Inventory:GetFirstSlotByItem(Player.PlayerData.items, item)
end
SetDurability = function(inv, slot, durability)
return true
end
lib.callback.register("GetItemCount", function(source, item)
local items = Inventory:GetItemsByName(source, item)
for k, v in pairs(items) do
return v.amount
end
return 0
end)

View File

@ -0,0 +1,39 @@
if GetResourceState("qs-inventory") ~= "started" then return end
Inventory = exports["qs-inventory"]
AddItem = function(inv, item, amount, metadata)
return Inventory:AddItem(inv, item, amount, false, metadata)
end
RemoveItem = function(inv, item, amount, metadata, slot)
return Inventory:RemoveItem(inv, item, amount, slot, metadata)
end
CanCarryItem = function(inv, item, amount)
return Inventory:CanCarryItem(inv, item, amount)
end
GetItemCount = function(inv, item)
if Inventory:GetItemTotalAmount(inv, item) >= 1 then return true end
return false
end
GetSlotWithItem = function(inv, item, metadata, strict)
local items = Inventory:GetInventory(inv)
for itemData, slotData in pairs(items) do
if slotData.name == item then
slotData.metadata = slotData.info
return slotData
end
end
return false
end
SetDurability = function(inv, slot, durability)
return true
end
lib.callback.register("GetItemCount", function(source, item)
return Inventory:GetItemTotalAmount(source, item)
end)

View File

@ -0,0 +1,14 @@
{
"no_required_item":"Du har ikke en %s",
"cant_carry":"Du kan ikke bære mere %s",
"uprooting":"Høster %s",
"washing":"Vasker %s",
"item_broke":"%s gik i stykker",
"wash_crops":"Vasker afgrøder",
"no_crops_to_wash":"Du har ingen afgrøder der skal vaskes",
"press_wash_crops":"%s Vask afgrøder",
"open_shop":"Åben shop",
"open_sell":"Åben sælger",
"sell_crops":"Sælg afgrøder",
"farmer_shop":"Landbrugsbutik"
}

View File

@ -0,0 +1,14 @@
{
"no_required_item":"You don't have a %s",
"cant_carry":"You can't carry more %s",
"uprooting":"Uprooting %s",
"washing":"Washing %s",
"item_broke":"%s Broke",
"wash_crops":"Wash Crops",
"no_crops_to_wash":"You don't have any crops that needs a wash",
"press_wash_crops":"%s Wash Crops",
"open_shop":"Open Shop",
"open_sell":"Open Sell",
"sell_crops":"Sell Crops",
"farmer_shop":"Agriculture Shop"
}

View File

@ -0,0 +1,129 @@
RegisterNetEvent("kloud-farm:client:pickProp", function(data)
local zoneData = KloudDev.Locations[data.currentZone]
local canStart, msg = lib.callback.await("kloud-farm:callback:canStart", false, zoneData)
if not canStart then Notify(msg, "error") return end
_G.IsBusy = true
if zoneData.anim.scenario then
TaskStartScenarioInPlace(cache.ped, zoneData.anim.scenario, 0, false)
else
PlayAnim(cache.ped, zoneData.anim.dict, zoneData.anim.clip, -1, zoneData.anim.upperBody)
end
if zoneData.action.type == "progress" then
local progress = Progress(zoneData.action.progressDuration, locale("uprooting", FormatStr(zoneData.item.label)))
if not progress then
ClearPedTasksImmediately(cache.ped)
DeleteProp(data.entity)
_G.IsBusy = false
return
end
elseif zoneData.action.type == "skillCheck" then
if not SkillCheck(zoneData.action.skillCheckDifficulty, zoneData.action.skillCheckInputs) then
ClearPedTasksImmediately(cache.ped)
DeleteProp(data.entity)
_G.IsBusy = false
return
end
end
_G.IsBusy = false
ClearPedTasksImmediately(cache.ped)
DeleteProp(data.entity)
lib.callback("kloud-farm:callback:uprooted", 3000, nil, zoneData)
end)
RegisterNetEvent("kloud-farm:client:pickTree", function(data)
local zoneData = KloudDev.Trees[data.currentZone]
local canStart, msg = lib.callback.await("kloud-farm:callback:canStart", false, zoneData)
if not canStart then Notify(msg, "error") return end
_G.IsBusy = true
if zoneData.anim.scenario then
TaskStartScenarioInPlace(cache.ped, zoneData.anim.scenario, 0, false)
else
PlayAnim(cache.ped, zoneData.anim.dict, zoneData.anim.clip, -1, zoneData.anim.upperBody)
end
if zoneData.action.type == "progress" then
local progress = Progress(zoneData.action.progressDuration, locale("uprooting", FormatStr(zoneData.item.label)))
if not progress then
ClearPedTasksImmediately(cache.ped)
_G.IsBusy = false
return
end
elseif zoneData.action.type == "skillCheck" then
if not SkillCheck(zoneData.action.skillCheckDifficulty, zoneData.action.skillCheckInputs) then
ClearPedTasksImmediately(cache.ped)
_G.IsBusy = false
return
end
end
ClearPedTasksImmediately(cache.ped)
_G.IsBusy = false
table.insert(_T.PickedTrees, {entity = data.entity, cooldown = zoneData.cooldown})
TriggerEvent("kloud-farm:client:startTreesCooldown")
lib.callback("kloud-farm:callback:uprooted", 3000, nil, zoneData)
end)
RegisterNetEvent("kloud-farm:client:startTreesCooldown", function()
if _G.Cooldown then return end
_G.Cooldown = true
while true do
for k, tree in pairs(_T.PickedTrees) do
for key, value in pairs(tree) do
if key == "cooldown" then
_T.PickedTrees[k].cooldown = value - 1
-- print("Cooldown: " .. value)
if value <= 0 then
table.remove(_T.PickedTrees, k)
end
end
end
end
if next(_T.PickedTrees) == nil then
_G.Cooldown = false
return
end
Wait(1000)
end
end)
RegisterNetEvent("kloud-farm:client:wash", function()
HideText()
local optionsTbl = {}
for _, v in pairs(KloudDev.WashLocations.items) do
if GetItemCount(v[1], nil, false) > 0 then
local values = {}
for i = 1, GetItemCount(v[1], nil, false) do
if i <= KloudDev.WashLocations.maxWash then
table.insert(values, i)
end
end
table.insert(optionsTbl, {
label = "x1 ".. FormatStr(v[1]).." : x1 "..FormatStr(v[2]),
icon = KloudDev.ImagePath .. v[2] .. ".png",
values = values,
args = {
itemRequired = v[1],
itemResult = v[2]
}
})
end
end
if next(optionsTbl) == nil then
Notify(locale("no_crops_to_wash"), "error")
return
end
lib.registerMenu({
id = "kloud-farm:wash",
title = locale("wash_crops"),
position = "top-right",
options = optionsTbl,
disableInput = true,
}, function(selected, scrollIndex, args)
WashCrops({itemRequired = args.itemRequired, itemResult = args.itemResult, amount = scrollIndex})
end)
lib.showMenu("kloud-farm:wash")
end)
AddEventHandler("onResourceStop", function(name)
if GetCurrentResourceName() ~= name then return end
ClearProps()
end)

View File

@ -0,0 +1,148 @@
local spawnedProps = 0
GetZCoord = function (x, y, groundHeights)
local groundCheckHeights = groundHeights
for i, height in ipairs(groundCheckHeights) do
local foundGround, z = GetGroundZFor_3dCoord(x, y, height, true)
if foundGround then
return z
end
end
return 76
end
ValidateCoord = function(coord)
local validate = true
if spawnedProps > 0 then
for _, v in pairs(_T.Props) do
if #(coord - GetEntityCoords(v)) < 5 then
validate = false
end
end
end
return validate
end
GetCoords = function (zone)
local loc = KloudDev.Locations[zone]
local groundHeight = {}
local value = loc.coords.z - 15
local radius = math.floor(loc.zoneRadius / 2)
for i = 1, 30 do
value += 1
table.insert(groundHeight, value)
end
while true do
Wait(1)
local propCoordX, propCoordY
math.randomseed(GetGameTimer())
local modX = math.random(radius * -1 , radius)
Wait(100)
math.randomseed(GetGameTimer())
local modY = math.random(-35, 35)
propCoordX = loc.coords.x + modX
propCoordY = loc.coords.y + modY
local coordZ = GetZCoord(propCoordX, propCoordY, groundHeight)
local coord = vector3(propCoordX, propCoordY, coordZ)
if ValidateCoord(coord) then
return coord
end
end
end
SpawnProps = function(zone)
local loc = KloudDev.Locations[zone]
while spawnedProps < loc.max do
Wait(0)
lib.requestModel(loc.prop, 10000)
local propCoords = GetCoords(zone)
local obj = CreateObject(joaat(loc.prop), propCoords.x, propCoords.y, propCoords.z, false, true, false)
while not DoesEntityExist(obj) do Wait(100) end
AddEntityTarget(obj, {
{
event = 'kloud-farm:client:pickProp',
label = loc.target.label,
name = "PickProps",
icon = loc.target.icon,
currentZone = _G.CurrentZone,
canInteract = function()
if not _G.IsBusy and _G.CurrentZone == zone then return true end
return false
end,
distance = 2,
}
})
SetEntityAsMissionEntity(obj, true, true)
PlaceObjectOnGroundProperly(obj)
FreezeEntityPosition(obj, true)
table.insert(_T.Props, obj)
spawnedProps = #_T.Props
end
SetModelAsNoLongerNeeded(joaat(loc.prop))
end
WashCrops = function(data)
local zoneData = KloudDev.WashLocations
local canCarry, msg = lib.callback.await("kloud-farm:callback:canCarry", false, data)
local duration = zoneData.duration * data.amount
if not canCarry then Notify(msg, "error") return end
_G.IsBusy = true
if zoneData.anim.scenario then
TaskStartScenarioInPlace(cache.ped, zoneData.anim.scenario, 0, false)
else
PlayAnim(cache.ped, zoneData.anim.dict, zoneData.anim.clip, -1, zoneData.anim.upperBody)
end
if not Progress(duration, locale("washing", FormatStr(data.itemRequired))) then
ClearPedTasksImmediately(cache.ped)
_G.IsBusy = false
return
end
ClearPedTasksImmediately(cache.ped)
_G.IsBusy = false
lib.callback("kloud-farm:callback:washed", 3000, nil, data)
end
ClearProps = function()
for k, v in pairs(_T.Props) do
if DoesEntityExist(v) then
if not DeleteObject(v) then DeleteObject(v) end
table.remove(_T.Props, k)
spawnedProps = #_T.Props
else
table.remove(_T.Props, k)
spawnedProps = #_T.Props
end
end
end
DeleteProp = function(prop)
for k, v in pairs(_T.Props) do
if prop == v then
if not DoesEntityExist(v) then table.remove(_T.Props, k) end
if not DeleteObject(v) then DeleteObject(v) end
table.remove(_T.Props, k)
spawnedProps = #_T.Props
SpawnProps(_G.CurrentZone)
end
end
end
CanPick = function(entity)
for _, info in pairs(_T.PickedTrees) do
for k, v in pairs(info) do
if v == entity then return false end
end
end
return true
end

View File

@ -0,0 +1,87 @@
RegisterNetEvent("kloud-farm:client:openSell", function()
local optionsTbl = {}
for k, v in pairs(KloudDev.Shops) do
if k == "sell" then
for _, data in pairs(v.prices) do
if GetItemCount(data[1], nil, false) > 0 then
local values = {}
for i = 1, GetItemCount(data[1], nil, false) do
if i <= KloudDev.WashLocations.maxWash then
table.insert(values, i)
end
end
table.insert(optionsTbl, {
label = FormatStr(data[1]) .. " $".. data[2],
icon = KloudDev.ImagePath .. data[1] .. ".png",
values = values,
args = {
item = data[1],
price = data[2]
}
})
else
table.insert(optionsTbl, {
label = FormatStr(data[1]),
icon = KloudDev.ImagePath .. data[1] .. ".png",
close = false
})
end
end
end
end
lib.registerMenu({
id = "kloud-farm:sell",
title = locale("sell_crops"),
position = "top-right",
options = optionsTbl,
disableInput = true,
}, function(selected, scrollIndex, args)
if scrollIndex then
local sold = lib.callback.await("kloud-farm:callback:sellItem", false, {item = args.item, price = args.price, amount = scrollIndex})
if sold then
lib.hideMenu(false)
end
end
end)
lib.showMenu("kloud-farm:sell")
end)
RegisterNetEvent("kloud-farm:client:openShop", function()
local optionsTbl = {}
for k, v in pairs(KloudDev.Shops) do
if k == "shop" then
for _, data in pairs(v.prices) do
local values = {}
for i = 1, 10 do
table.insert(values, i)
end
table.insert(optionsTbl, {
label = "$" .. data[2] .." ".. FormatStr(data[1]),
icon = KloudDev.ImagePath .. data[1] .. ".png",
values = values,
args = {
item = data[1],
price = data[2]
}
})
end
end
end
lib.registerMenu({
id = "kloud-farm:shop",
title = locale("farmer_shop"),
position = "top-right",
options = optionsTbl,
disableInput = true,
}, function(selected, scrollIndex, args)
if scrollIndex then
local sold = lib.callback.await("kloud-farm:callback:buyItem", false, {item = args.item, price = args.price, amount = scrollIndex})
if sold then
lib.hideMenu(false)
end
end
end)
lib.showMenu("kloud-farm:shop")
end)

View File

@ -0,0 +1,77 @@
lib.callback.register("kloud-farm:callback:canStart", function(source, zoneData)
local src = source
local requireItem = zoneData.item.require
if requireItem.enable then
return GetItemCount(src, requireItem.item), locale('no_required_item', requireItem.item)
end
if CanCarryItem(src, zoneData.item.name, 1) then
return true
else
return false, locale('cant_carry', FormatStr(zoneData.item.name))
end
end)
lib.callback.register("kloud-farm:callback:canCarry", function(source, data)
local src = source
if CanCarryItem(src, data.itemResult, data.amount) then
return true
else
return false, locale('cant_carry', FormatStr(data.itemResult))
end
end)
lib.callback.register("kloud-farm:callback:uprooted", function(source, zoneData)
local src = source
local requireItem = zoneData.item.require
local randomAmount = math.random(zoneData.item.min, zoneData.item.max)
AddItem(src, zoneData.item.name, randomAmount, nil)
if requireItem.enable and requireItem.durability.subtract then
local itemData = GetSlotWithItem(src, requireItem.item, nil, false)
local currentDurability = 100
local durabilityChance = math.random(1, 100)
if itemData.metadata.durability then
currentDurability = itemData.metadata.durability
end
if durabilityChance < requireItem.durability.chance then
SetDurability(src, itemData.slot, currentDurability - requireItem.durability.amount)
end
if requireItem.randomBreak then
local randomChance = math.random(1, 100)
if randomChance < requireItem.breakChance then
RemoveItem(src, requireItem.item, 1, false, itemData.slot)
SVNotify(src, locale('item_broke', FormatStr(requireItem.item)), "error")
end
end
end
end)
lib.callback.register("kloud-farm:callback:washed", function(source, data)
local src = source
if RemoveItem(src, data.itemRequired, data.amount) then
AddItem(src, data.itemResult, data.amount, nil)
end
end)
lib.callback.register("kloud-farm:callback:sellItem", function(source, data)
local src = source
if not RemoveItem(src, data.item, data.amount) then return false end
if not AddMoney(src, "cash", data.price * data.amount, "Sold Crop") then return false end
end)
lib.callback.register("kloud-farm:callback:buyItem", function(source, data)
local src = source
if not RemoveMoney(src, "cash", data.price * data.amount, "Buy Farming Item") then return false end
if not AddItem(src, data.item, data.amount) then return false end
end)

View File

@ -0,0 +1,24 @@
_anim = {}
_anim.props = {
clipboard = "p_amb_clipboard_01",
notepad = "prop_notepad_01"
}
_anim.shrug = { dict = "gestures@f@standing@casual", clip = "gesture_shrug_hard" }
_anim.no = { dict = "mp_player_int_upper_nod", clip = "mp_player_int_nod_no" }
_anim.clipboard = { dict = "missfam4", clip = "base" }
_anim.notepad = { dict = "missheistdockssetup1clipboard@base", clip = "base" }
_anim.trolly = { dict = "missfinale_c2ig_11", clip = "pushcar_offcliff_f" }
_anim.give = { dict = "mp_common", clip = "givetake1_a"}
_anim.take = { dict = "mp_common", clip = "givetake1_b"}
_anim.wait = {
{dict = "mp_cp_welcome_tutthink", clip = "b_think"},
{dict = "misscarsteal4@aliens", clip = "rehearsal_base_idle_director"},
{dict = "timetable@tracy@ig_8@base", clip = "base"},
{dict = "missheist_jewelleadinout", clip = "jh_int_outro_loop_a"},
{dict = "rcmjosh1", clip = "idle"},
{dict = "missbigscore2aig_3", clip = "wait_for_van_c"},
{dict = "timetable@amanda@ig_2", clip = "ig_2_base_amanda"}
}

View File

@ -0,0 +1,13 @@
CreateThread(function()
Wait(1000)
if GetResourceState("ox_target") ~= "started" and GetResourceState("qb-target") ~= "started" then
-- print("^1No targeting resource found. Start the targeting resource before this script or you might be using an unsupported one.^0")
end
if GetResourceState("es_extended") ~= "started" and GetResourceState("qb-core") ~= "started" and GetResourceState("qbx-core") ~= "started" then
-- print("^1No framework found.^0")
end
collectgarbage("collect")
end)

View File

@ -0,0 +1,14 @@
KloudDev = {}
KloudDev.Debug = false
KloudDev.ImagePath = "ps-inventory/html/images/"
KloudDev.DrawSprite = true -- ox_target indicator
KloudDev.DrawText = "qb" -- "qb","ox"
KloudDev.Menu = "qb" -- "qb","ox"
KloudDev.Notify = "qb" -- "qb","esx","ox", "ps"
KloudDev.NotifyPos = "top-right" -- For ox_lib // 'top', 'top-right', 'top-left', 'bottom', 'bottom-right', 'bottom-left', 'center-right', 'center-left' // For QB change qb-core/config.lua
KloudDev.Progress = "ox-circle" -- "ox-bar","ox-circle"
KloudDev.ProgressCirclePos = "bottom" -- "middle", "bottom"
KloudDev.DrawTextAlignment = "top" -- "top","right","left"

View File

@ -0,0 +1,414 @@
KloudDev.Locations = {
["potato"] = {
coords = vec4(2852.95, 4627.06, 50.69, 284.01),
zoneRadius = 65,
prop = "prop_plant_fern_02a",
job = false, -- false to disable, "jobname" to enable
action = {
type = "skillCheck", -- "progress" / "skillCheck"
progressDuration = 5000,
skillCheckDifficulty = {"easy", "easy", "easy", "easy"}, -- "easy", "medium", "hard"
skillCheckInputs = {"1", "2", "3", "4"}
},
max = 25,
target = {
label = "Træk op",
icon = "fas fa-trowel"
},
anim = {
scenario = "WORLD_HUMAN_GARDENER_PLANT",
dict = nil,
clip = nil,
upperBody = false
},
item = {
require = {
enable = true,
item = "trowel",
durability = {
subtract = true,
amount = 1,
chance = 75
},
breaking = {
enabled = true,
chance = 15
}
},
name = "dirty_potato",
label = "Beskidt kartoffel",
min = 1,
max = 4
},
blip = {
enabled = true,
label = "Kartoffel-mark",
sprite = 285,
scale = 0.9,
colour = 21,
},
},
["cabbage"] = {
coords = vec4(2541.34, 4812.27, 33.73, 65.37),
zoneRadius = 35,
prop = "prop_veg_crop_03_cab",
job = false, -- false to disable, "jobname" to enable
action = {
type = "progress", -- "progress" / "skillCheck"
progressDuration = 5000,
skillCheckDifficulty = {"easy", "easy", "easy", "easy"}, -- "easy", "medium", "hard"
skillCheckInputs = {"1", "2", "3", "4"}
},
max = 25,
target = {
label = "Træk op",
icon = "fas fa-hands-holding"
},
anim = {
scenario = nil,
dict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
clip = "machinic_loop_mechandplayer",
upperBody = false,
},
item = {
require = {
enable = false,
item = "trowel",
durability = {
subtract = true,
amount = 1,
chance = 75
},
breaking = {
enabled = true,
chance = 15
}
},
name = "dirty_cabbage",
label = "Beskidt kål",
min = 1,
max = 4
},
blip = {
enabled = true,
label = "Kål-mark",
sprite = 285,
scale = 0.9,
colour = 2,
},
},
["tomato"] = {
coords = vec4(2238.95, 5074.01, 47.25, 220.28),
zoneRadius = 45,
prop = "prop_veg_crop_02",
job = false, -- false to disable, "jobname" to enable
action = {
type = "skillCheck", -- "progress" / "skillCheck"
progressDuration = 5000,
skillCheckDifficulty = {"easy", "easy", "easy", "easy"}, -- "easy", "medium", "hard"
skillCheckInputs = {"1", "2", "3", "4"}
},
max = 25,
target = {
label = "Træk op",
icon = "fas fa-hands-holding"
},
anim = {
scenario = nil,
dict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
clip = "machinic_loop_mechandplayer",
upperBody = true,
},
item = {
require = {
enable = false,
item = "trowel",
durability = {
subtract = true,
amount = 1,
chance = 75
},
breaking = {
enabled = true,
chance = 15
}
},
name = "dirty_tomato",
label = "Beskidt tomat",
min = 1,
max = 4
},
blip = {
enabled = true,
label = "Tomat-mark",
sprite = 285,
scale = 0.9,
colour = 6,
},
},
["coffee_beans"] = {
coords = vec4(2308.01, 5131.05, 50.5, 45.11),
zoneRadius = 35,
prop = "prop_veg_crop_04_leaf",
job = false, -- false to disable, "jobname" to enable
action = {
type = "skillCheck", -- "progress" / "skillCheck"
progressDuration = 5000,
skillCheckDifficulty = {"easy", "easy", "easy", "easy"}, -- "easy", "medium", "hard"
skillCheckInputs = {"1", "2", "3", "4"}
},
max = 25,
target = {
label = "Træk op",
icon = "fas fa-hands-holding"
},
anim = {
scenario = nil,
dict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
clip = "machinic_loop_mechandplayer",
upperBody = true,
},
item = {
require = {
enable = false,
item = "trowel",
durability = {
subtract = true,
amount = 1,
chance = 75
},
breaking = {
enabled = true,
chance = 15
}
},
name = "dirty_coffee_beans",
label = "Beskidte kaffebønner",
min = 1,
max = 4
},
blip = {
enabled = true,
label = "Kaffebønne-mark",
sprite = 285,
scale = 0.9,
colour = 44,
},
},
}
KloudDev.Trees = {
["orange"] = {
coords = vec4(2341.86, 5003.98, 42.53, 45.44),
zoneType = "sphere",
zoneRadius = 55,
zonePoints = {
vec3(2455.0, 4670.0, 35.0),
vec3(2367.0, 4761.0, 35.0),
vec3(2311.0, 4780.0, 35.0),
vec3(2299.0, 4743.0, 35.0),
vec3(2361.0, 4712.0, 35.0),
vec3(2428.0, 4646.0, 35.0),
},
cooldown = 60,
prop = "prop_veg_crop_orange",
job = false, -- false to disable, "jobname" to enable
action = {
type = "skillCheck", -- "progress" / "skillCheck"
progressDuration = 5000,
skillCheckDifficulty = {"easy", "easy", "easy", "easy"}, -- "easy", "medium", "hard"
skillCheckInputs = {"1", "2", "3", "4"}
},
target = {
label = "Pluk appelsin",
icon = "fas fa-cannabis"
},
anim = {
scenario = nil,
dict = "missmechanic",
clip = "work_base",
upperBody = true
},
item = {
require = {
enable = false,
item = "trowel",
durability = {
subtract = true,
amount = 1,
chance = 75
},
breaking = {
enabled = true,
chance = 15
}
},
name = "orange",
label = "Appelsin",
min = 1,
max = 4
},
blip = {
enabled = true,
label = "Appelsin-mark",
sprite = 285,
scale = 0.9,
colour = 47,
},
},
["orange2"] = {
coords = vec4(2360.21, 4729.47, 34.53, 260.21),
zoneType = "poly",
zoneRadius = 55,
zonePoints = {
vec3(2455.0, 4670.0, 35.0),
vec3(2367.0, 4761.0, 35.0),
vec3(2311.0, 4780.0, 35.0),
vec3(2299.0, 4743.0, 35.0),
vec3(2361.0, 4712.0, 35.0),
vec3(2428.0, 4646.0, 35.0),
},
cooldown = 60,
prop = "prop_veg_crop_orange",
job = false, -- false to disable, "jobname" to enable
action = {
type = "skillCheck", -- "progress" / "skillCheck"
progressDuration = 5000,
skillCheckDifficulty = {"easy", "easy", "easy", "easy"}, -- "easy", "medium", "hard"
skillCheckInputs = {"1", "2", "3", "4"}
},
target = {
label = "Pluk appelsin",
icon = "fas fa-cannabis"
},
anim = {
scenario = nil,
dict = "missmechanic",
clip = "work_base",
upperBody = true
},
item = {
require = {
enable = false,
item = "trowel",
durability = {
subtract = true,
amount = 1,
chance = 75
},
breaking = {
enabled = true,
chance = 15
}
},
name = "orange",
label = "Appelsin",
min = 1,
max = 4
},
blip = {
enabled = true,
label = "Appelsin-mark",
sprite = 285,
scale = 0.9,
colour = 47,
},
},
}
KloudDev.WashLocations = {
blip = {
enabled = true,
label = "Vask afgrøder",
sprite = 728,
scale = 0.9,
colour = 4,
},
duration = 3000, -- per item count ex. x1 orange = 3secs, x10 orange = 30secs
maxWash = 20,
anim = {
scenario = "WORLD_HUMAN_BUM_WASH", -- nil to disable
dict = nil,
clip = nil,
upperBody = false
},
items = {
{"dirty_potato", "potato"},
{"dirty_cabbage", "cabbage"},
{"dirty_tomato", "tomato"},
{"dirty_coffee_beans", "coffee_beans"},
--{requiredItem, resultItem}
},
coords = {
vec4(2405.77, 4600.39, 30.31, 98.15),
vec4(2397.81, 4596.51, 30.31, 134.76),
vec4(2384.6, 4594.71, 30.38, 107.85),
vec4(2363.49, 4593.61, 30.52, 106.54),
vec4(2372.93, 4595.23, 30.54, 190.0),
}
}
KloudDev.Shops = {
["sell"] = {
blip = {
enabled = true,
label = "Farmer John",
sprite = 59,
scale = 0.9,
colour = 2,
},
coords = {
vector4(2028.18, 4978.26, 40.12, 224.48),
vector4(2243.63, 5154.18, 56.89, 154.39)
},
pedModels = {
"a_m_m_farmer_01",
"cs_russiandrunk",
"cs_old_man1a",
"cs_old_man2",
"cs_nervousron",
},
prices = {
{"potato", 5},
{"tomato", 3},
{"orange", 4},
{"cabbage", 6},
{"coffee_beans", 8},
-- {"itemName", price}
}
},
["shop"] = {
blip = {
enabled = true,
label = "Farmer John",
sprite = 59,
scale = 0.9,
colour = 2,
},
coords = {
vector4(461.93, -696.86, 26.42, 70.94),
},
pedModels = {
"a_m_m_farmer_01",
"cs_russiandrunk",
"cs_old_man1a",
"cs_old_man2",
"cs_nervousron",
},
prices = {
{"shovel", 100},
{"trowel", 50},
{"potato", 75},
{"tomato", 75},
{"orange", 75},
{"cabbage", 75},
{"coffee_beans", 75},
-- {"itemName", price}
}
},
}

View File

@ -0,0 +1,225 @@
lib.locale()
FormatStr = function(str)
local strFormat = str
strFormat = strFormat:gsub("_", " ")
strFormat = string.gsub(" "..strFormat, "%W%l", string.upper):sub(2)
return strFormat
end
DrawText = function (msg)
if KloudDev.DrawText == 'ox' then
local pos = KloudDev.DrawTextAlignment.."-center"
lib.showTextUI(msg, {
position = pos or "right-center"
})
elseif KloudDev.DrawText == 'qb' then
exports['qb-core']:DrawText(msg, KloudDev.DrawTextAlignment)
end
end
HideText = function ()
if KloudDev.DrawText == 'ox' then
lib.hideTextUI()
elseif KloudDev.DrawText == 'qb' then
exports['qb-core']:HideText()
end
end
Progress = function (duration, label, dict, clip)
if KloudDev.Progress == "ox-circle" then
local anim = nil
if dict and clip then
anim = {
dict = dict,
clip = clip
}
end
return lib.progressCircle({
duration = duration,
label = label,
useWhileDead = false,
canCancel = false,
position = KloudDev.ProgressCirclePos or "bottom",
disable = {
move = true,
car = true,
combat = true,
mouse = false
},
anim = anim,
})
elseif KloudDev.Progress == "ox-bar" then
local anim = nil
if dict and clip then
anim = {
dict = dict,
clip = clip
}
end
return lib.progressBar({
duration = duration,
label = label,
useWhileDead = false,
canCancel = false,
disable = {
move = true,
car = true,
combat = true,
mouse = false
},
anim = anim
})
end
end
Notify = function (msg, type, duration)
local dur = duration or 3000
if KloudDev.Notify == "ox" then
if GetResourceState("ox_lib") ~= "started" then print("You need ox_lib running for the notifications to work") return end
if type == "error" then
lib.notify({
description = msg,
icon = 'ban',
duration = dur,
iconColor = '#C53030',
position = KloudDev.NotifyPos or "top-right"
})
elseif type == "success" then
lib.notify({
description = msg,
icon = 'check',
duration = dur,
iconColor = '#30c56a',
position = KloudDev.NotifyPos or "top-right"
})
end
elseif KloudDev.Notify == "qb" then
TriggerEvent('QBCore:Notify', msg, type, dur)
elseif KloudDev.Notify == "esx" then
TriggerEvent('esx:showNotification', msg, type, dur)
elseif KloudDev.Notify == "ps" then
exports['ps-ui']:Notify(msg, type, dur)
end
end
SVNotify = function (source, msg, type, duration)
local dur = duration or 3000
if KloudDev.Notify == "ox" then
local randomID = math.random(1, 500)
if type == "error" then
TriggerClientEvent('ox_lib:notify', source, {
description = msg,
duration = dur,
icon = 'ban',
iconColor = '#C53030',
position = KloudDev.NotifyPos or "top-right"
})
elseif type == "success" then
TriggerClientEvent('ox_lib:notify', source, {
description = msg,
duration = dur,
icon = 'check',
iconColor = '#30c56a',
position = KloudDev.NotifyPos or "top-right"
})
end
elseif KloudDev.Notify == "qb" then
TriggerClientEvent('QBCore:Notify', source, msg, type, dur)
elseif KloudDev.Notify == "esx" then
TriggerClientEvent('esx:showNotification', source, msg, type, dur)
elseif KloudDev.Notify == "ps" then
TriggerClientEvent('ps-ui:Notify', source, msg, type, dur)
end
end
FaceEntity = function (entity1, entity2)
local x, y, z = table.unpack(GetEntityCoords(entity1, true))
local x1, y1, z1 = table.unpack(GetEntityCoords(entity2, true))
local dx = x1 - x
local dy = y1 - y
local heading = GetHeadingFromVector_2d(dx, dy)
SetPedDesiredHeading(entity1, heading)
return tonumber(heading)
end
PlayAnim = function (ped, dict, clip, duration, upperbody)
lib.requestAnimDict(dict)
ClearPedTasks(ped)
TaskPlayAnim(ped, dict, clip, 5.0, 5.0, duration or -1, upperbody and 51 or 0, 0, false, false, false)
end
ShrugAnim = function (ped)
lib.requestAnimDict(_anim.shrug.dict)
ClearPedTasks(ped)
TaskPlayAnim(ped, _anim.shrug.dict, _anim.shrug.clip, 5.0, 5.0, 1000, 51, 0, false, false, false)
Wait(800)
end
NoAnim = function (ped)
lib.requestAnimDict(_anim.no.dict)
ClearPedTasks(ped)
TaskPlayAnim(ped, _anim.no.dict, _anim.no.clip, 5.0, 5.0, 1000, 51, 0, false, false, false)
end
RandomWaitAnim = function (ped, duration)
local randomAnim = math.random(1, #_anim.wait)
lib.requestAnimDict(_anim.wait[randomAnim].dict)
ClearPedTasks(ped)
TaskPlayAnim(ped, _anim.wait[randomAnim].dict, _anim.wait[randomAnim].clip, 5.0, 5.0, duration, 51, 0, false, false, false)
end
DeleteProp = function (prop)
DeleteObject(prop)
end
ClipboardAnim = function (ped, duration)
lib.requestModel(_anim.props.clipboard, 10000)
local ped = ped
local x, y, z = table.unpack(GetEntityCoords(ped))
local prop = CreateObject(joaat(_anim.props.clipboard), x, y, z, true, false, false)
PlayAnim(ped, _anim.clipboard.dict, _anim.clipboard.clip, duration)
AttachEntityToEntity(prop, ped, GetPedBoneIndex(ped, 36029), 0.16, 0.08, 0.1, -130.0, -50.0, 0.0, true, true, false, true, 1, true)
SetModelAsNoLongerNeeded(_anim.props.clipboard)
return prop
end
NotepadAnim = function (ped, duration)
lib.requestModel(_anim.props.notepad, 10000)
local x, y, z = table.unpack(GetEntityCoords(ped))
local prop = CreateObject(joaat(_anim.props.notepad), x, y, z, true, false, false)
PlayAnim(ped, _anim.notepad.dict, _anim.notepad.clip, duration)
AttachEntityToEntity(prop, ped, GetPedBoneIndex(ped, 36029), 0.1, 0.02, 0.05, 10.0, 0.0, 0.0, true, true, false, true, 1, true)
SetModelAsNoLongerNeeded(_anim.props.notepad)
return prop
end
TrollyAnim = function (model, coords, created)
lib.requestAnimDict(_anim.trolly.dict)
ClearPedTasks(cache.ped)
TaskPlayAnim(cache.ped, _anim.trolly.dict, _anim.trolly.clip, 5.0, 5.0, 1.0 , 62, 0, false, false, false)
Wait(200)
if not created then
local trolly = CreateObject(joaat(model), coords.x, coords.y, coords.z, true, false, false)
AttachEntityToEntity(trolly, cache.ped, GetPedBoneIndex(cache.ped, 60309), -0.4, -1.6, -0.85, 0.0, 0.0, 180.0, true, true, false, true, 1, true)
return trolly
end
AttachEntityToEntity(created, cache.ped, GetPedBoneIndex(cache.ped, 60309), -0.4, -1.6, -0.85, 0.0, 0.0, 180.0, true, true, false, true, 1, true)
return created
end
TrollyReAnim = function()
lib.requestAnimDict(_anim.trolly.dict)
TaskPlayAnim(cache.ped, _anim.trolly.dict, _anim.trolly.clip, 5.0, 5.0, 1.0 , 62, 0, false, false, false)
end
SkillCheck = function(difficulty, inputs)
return lib.skillCheck(difficulty, inputs)
end

View File

@ -0,0 +1,32 @@
if GetResourceState("ox_target") ~= "started" then return end
AddTarget = function (coords, radius, options)
exports.ox_target:addSphereZone({
coords = coords,
radius = 2.25,
debug = KloudDev.Debug,
drawSprite = KloudDev.DrawSprite,
options = options
})
end
AddEntityTarget = function (entity, options)
if NetworkGetEntityIsNetworked(entity) then
local netId = NetworkGetNetworkIdFromEntity(entity)
exports.ox_target:addEntity(netId, options)
else
exports.ox_target:addLocalEntity(entity, options)
end
end
RemoveEntityTarget = function(entity, optionNames)
if NetworkGetEntityIsNetworked(entity) then
local netId = NetworkGetNetworkIdFromEntity(entity)
exports.ox_target:removeEntity(netId, optionNames)
else
exports.ox_target:removeLocalEntity(entity, optionNames)
end
end
AddTargetModel = function(model, options)
exports.ox_target:addModel(model, options)
end

View File

@ -0,0 +1,74 @@
if GetResourceState("qb-target") ~= "started" or GetResourceState("ox_target") == "started" then return end
AddTarget = function (coords, radius, options)
local optionsTbl = {}
local distance = 2.0
for _, v in pairs(options) do
table.insert(optionsTbl, {
label = v.label,
name = v.name,
event = v.event or nil,
icon = v.icon,
canInteract = v.canInteract or nil,
action = v.onSelect or nil,
currentZone = v.currentZone
})
distance = v.distance
end
exports['qb-target']:AddCircleZone(options[1].name, coords, radius, {
name = options[1].name,
debugPoly = KloudDev.Debug
}, {
options = optionsTbl,
distance = distance
})
end
AddEntityTarget = function (entity, options)
local optionsTbl = {}
local distance = 2.0
for _, v in pairs(options) do
table.insert(optionsTbl, {
type = "client",
event = v.event or nil,
icon = v.icon,
label = v.label,
action = v.onSelect or nil,
canInteract = v.canInteract or nil,
currentZone = v.currentZone
})
end
if NetworkGetEntityIsNetworked(entity) then
local netId = NetworkGetNetworkIdFromEntity(entity)
exports["qb-target"]:AddTargetEntity(netId, {options = optionsTbl, distance = distance})
else
exports["qb-target"]:AddTargetEntity(entity, {options = optionsTbl, distance = distance})
end
end
AddTargetModel = function(model, options)
local optionsTbl = {}
local distance = 2.0
for _, v in pairs(options) do
distance = v.distance or 2.0
table.insert(optionsTbl, {
type = "client",
event = v.event or nil,
icon = v.icon,
label = v.label,
action = v.onSelect or nil,
canInteract = v.canInteract or nil,
currentZone = v.currentZone
})
end
exports["qb-target"]:AddTargetModel(model, {options = optionsTbl, distance = distance})
end
RemoveEntityTarget = function(entity, optionNames, labels)
if NetworkGetEntityIsNetworked(entity) then
local netId = NetworkGetNetworkIdFromEntity(entity)
exports["qb-target"]:RemoveTargetEntity(netId, labels)
else
exports["qb-target"]:RemoveTargetEntity(entity, labels)
end
end

View File

@ -0,0 +1,51 @@
<div align='center'><img src='https://user-images.githubusercontent.com/111543470/210480469-65f0c4c8-b067-4154-b17d-05d4afd60300.png'/></div>
<div align='center'><h3><a href='https://picklemods.com/'>More Information & Scripts can be found here!</a></h3></div>
## Preview
https://www.youtube.com/watch?v=SHyzr0GcOx8
## What is this?
<p>This is a multi-framework taxi job.</p>
<p>It's a great fit for any type of roleplaying server, whether it's Serious RP or not.</p>
With this resource, you will be able to do the following:
- Create multiple taxi businesses.
- Allow multiple groups to access and manage a business.
- Earn money through NPC missions.
- Spawn Vehicles at the depot.
- Go on/off duty.
- Manage the business.
## Supported Frameworks
- ESX 1.1+ & Legacy
- QBCore
- Other (Code your own bridge)
## What do I need?
Use a supported framework or make it work with yours via the bridge folder.
<a href='https://github.com/overextended/ox_lib/releases/'>Ox Lib</a> (Required).
## Installation
<p>Start ox_lib before pickle_taxijob.</p>
<p>Add your businesses in the config.lua.</p>
<p>Add the groups via the SQL files (use included examples in the "_INSTALL" folder).</p>
<p>Restart the server.</p>
## Need Support?
<a href='https://picklemods.com'>Click here!</a>
## Licensing
<p>Do not at any point redistribute this without my permission and credit.</p>
<p>I've already had to issue reports on people selling my Television Script (which is free).</p>
<p>That is not fair to anyone, especially to the people who get scammed out of their money.</p>
<p>So please, respect the rules and have fun!</p>

View File

@ -0,0 +1,48 @@
if GetResourceState('es_extended') ~= 'started' then return end
ESX = exports.es_extended:getSharedObject()
function ShowNotification(text)
ESX.ShowNotification(text)
end
function ShowHelpNotification(text)
ESX.ShowHelpNotification(text)
end
function ServerCallback(name, cb, ...)
ESX.TriggerServerCallback(name, cb, ...)
end
function GetPlayersInArea(coords, maxDistance)
return ESX.Game.GetPlayersInArea(coords, maxDistance)
end
function CanAccessGroup(data)
if not data then return true end
local pdata = ESX.GetPlayerData()
for k,v in pairs(data) do
if (pdata.job.name == k and pdata.job.grade >= v) then return true end
end
return false
end
function AccessBossMenu(businessID)
local cfg = Config.Businesses[businessID]
if not CanAccessGroup(cfg.bossgroups) then
return ShowNotification(_L("no_access"))
end
TriggerEvent('esx_society:openBossMenu', cfg.info.society, function(data, menu)
menu.close()
end, {
withdraw = false,
deposit = false,
wash = true,
employees = true,
grades = false
})
end
RegisterNetEvent(GetCurrentResourceName()..":showNotification", function(text)
ShowNotification(text)
end)

View File

@ -0,0 +1,75 @@
if GetResourceState('es_extended') ~= 'started' then return end
ESX = exports.es_extended:getSharedObject()
function RegisterCallback(name, cb)
ESX.RegisterServerCallback(name, cb)
end
function RegisterUsableItem(...)
ESX.RegisterUsableItem(...)
end
function ShowNotification(target, text)
TriggerClientEvent(GetCurrentResourceName()..":showNotification", target, text)
end
function Search(source, name)
local xPlayer = ESX.GetPlayerFromId(source)
if (name == "money") then
return xPlayer.getMoney()
elseif (name == "bank") then
return xPlayer.getAccount('bank').money
else
local item = xPlayer.getInventoryItem(name)
if item ~= nil then
return item.count
else
return 0
end
end
end
function AddItem(source, name, amount, metadata)
local xPlayer = ESX.GetPlayerFromId(source)
if (name == "money") then
return xPlayer.addMoney(amount)
elseif (name == "bank") then
return xPlayer.addAccountMoney('bank', amount)
else
return exports.ox_inventory:AddItem(source, name, amount, metadata)
end
end
function RemoveItem(source, name, amount)
local xPlayer = ESX.GetPlayerFromId(source)
if (name == "money") then
return xPlayer.removeMoney(amount)
elseif (name == "bank") then
return xPlayer.removeAccountMoney('bank', amount)
else
return xPlayer.removeInventoryItem(name, amount)
end
end
function CanAccessGroup(source, data)
if not data then return true end
local pdata = ESX.GetPlayerFromId(source)
for k,v in pairs(data) do
if (pdata.job.name == k and pdata.job.grade >= v) then return true end
end
return false
end
function GetIdentifier(source)
local xPlayer = ESX.GetPlayerFromId(source)
return xPlayer.identifier
end
-- REMOVE BELOW IF NOT USING ESX SOCIETY
for i=1, #Config.Businesses do
local cfg = Config.Businesses[i]
local society = cfg.info.society
TriggerEvent('esx_society:registerSociety', society, society, 'society_'..society, 'society_'..society, 'society_'..society, {type = 'public'})
end

View File

@ -0,0 +1,42 @@
if GetResourceState('qb-core') ~= 'started' then return end
QBCore = exports['qb-core']:GetCoreObject()
function ServerCallback(name, cb, ...)
QBCore.Functions.TriggerCallback(name, cb, ...)
end
function ShowNotification(text)
QBCore.Functions.Notify(text)
end
function ShowHelpNotification(text)
AddTextEntry('qbHelpNotification', text)
BeginTextCommandDisplayHelp('qbHelpNotification')
EndTextCommandDisplayHelp(0, false, false, -1)
end
function GetPlayersInArea(coords, maxDistance)
return QBCore.Functions.GetPlayersFromCoords(coords, maxDistance)
end
function CanAccessGroup(data)
if not data then return true end
local pdata = QBCore.Functions.GetPlayerData()
for k,v in pairs(data) do
if (pdata.job.name == k and pdata.job.grade.level >= v) then return true end
end
return false
end
function AccessBossMenu(businessID)
local cfg = Config.Businesses[businessID]
if not CanAccessGroup(cfg.bossgroups) then
return ShowNotification(_L("no_access"))
end
TriggerEvent('qb-bossmenu:client:OpenMenu')
end
RegisterNetEvent(GetCurrentResourceName()..":showNotification", function(text)
ShowNotification(text)
end)

View File

@ -0,0 +1,67 @@
if GetResourceState('qb-core') ~= 'started' then return end
QBCore = exports['qb-core']:GetCoreObject()
function RegisterCallback(name, cb)
QBCore.Functions.CreateCallback(name, cb)
end
function RegisterUsableItem(...)
QBCore.Functions.CreateUseableItem(...)
end
function ShowNotification(target, text)
TriggerClientEvent(GetCurrentResourceName()..":showNotification", target, text)
end
function Search(source, name)
local xPlayer = QBCore.Functions.GetPlayer(source)
if (name == "money") then
return xPlayer.PlayerData.money['cash']
elseif (name == "bank") then
return xPlayer.PlayerData.money['cash'] -- If anyone knows how to get bank balance for QBCore, let me know.
else
local item = xPlayer.Functions.GetItemByName(name)
if item ~= nil then
return item.amount
else
return 0
end
end
end
function AddItem(source, name, amount, metadata)
local xPlayer = QBCore.Functions.GetPlayer(source)
if (name == "money") then
return xPlayer.Functions.AddMoney("cash", amount)
elseif (name == "bank") then
return xPlayer.Functions.AddMoney("cash", amount) -- If anyone knows how to add to bank balance for QBCore, let me know.
else
return xPlayer.Functions.AddItem(name, amount, nil, metadata)
end
end
function RemoveItem(source, name, amount)
local xPlayer = QBCore.Functions.GetPlayer(source)
if (name == "money") then
return xPlayer.Functions.RemoveMoney("cash", amount)
elseif (name == "bank") then
return xPlayer.Functions.RemoveMoney("cash", amount) -- If anyone knows how to remove from bank balance for QBCore, let me know.
else
return xPlayer.Functions.RemoveItem(name, amount)
end
end
function CanAccessGroup(source, data)
if not data then return true end
local pdata = QBCore.Functions.GetPlayer(source).PlayerData
for k,v in pairs(data) do
if (pdata.job.name == k and pdata.job.grade.level >= v) then return true end
end
return false
end
function GetIdentifier(source)
local xPlayer = QBCore.Functions.GetPlayer(source).PlayerData
return xPlayer.citizenid
end

View File

@ -0,0 +1,4 @@
if GetResourceState('es_extended') == 'started' then return end
if GetResourceState('qb-core') == 'started' then return end
print("You are not using a supported framework, it will be required to make edits to the bridge files.")

View File

@ -0,0 +1,4 @@
if GetResourceState('es_extended') == 'started' then return end
if GetResourceState('qb-core') == 'started' then return end
print("You are not using a supported framework, it will be required to make edits to the bridge files.")

View File

@ -0,0 +1,74 @@
Config = {}
Config.Debug = false
Config.Language = "da"
Config.Businesses = {
{
info = {
id = "pickle_taxi",
society = "taxi",
label = "HP Taxa Selskab",
},
blip = {
Label = "HP Taxa Selskab",
Location = vector3(912.0522, -174.0470, 74.2908),
ID = 198,
Display = 4,
Scale = 0.75,
Color = 5
},
groups = {
["taxi"] = 0,
},
bossgroups = {
["taxi"] = 4,
},
vehicles = {
{
label = "Taxi",
model = `taxi`,
groups = {
["taxi"] = 0,
}
},
{
label = "Limosine",
model = `stretch`,
groups = {
["taxi"] = 0,
}
},
},
locations = {
vehicle = vector4(916.0678, -163.4347, 74.6782, 152.6545),
boss = vector3(895.5319, -179.3002, 74.7003),
duty = vector3(900.5847, -171.5111, 74.0756)
}
}
}
Config.Missions = {
loop = false, -- Keep doing missions until /taxijob is used.
reward = {name = "money", min = 10, max = 50, miles = 2.0}, -- multiples reward by miles traveled.
models = {
`s_m_m_cntrybar_01`,
`u_f_y_comjane`,
`a_f_y_hipster_04`,
`s_m_m_highsec_02`,
`a_m_y_hipster_03`,
},
locations = {
vector4(946.3250, -171.7351, 74.5242, 56.1620),
vector4(397.9923, -870.3594, 29.2102, 322.1986),
vector4(59.2745, -1483.8176, 29.2773, 270.6085),
vector4(1246.3237, -1453.9513, 34.9354, 344.2509),
vector4(-289.3166, -1847.9614, 26.2498, 4.3302),
vector4(-45.8459, -1029.7800, 28.6224, 71.5370),
vector4(181.9603, -322.1017, 43.9382, 211.4422),
vector4(-514.8563, -260.6308, 35.5337, 211.8925),
vector4(-1284.6191, 297.2318, 64.9439, 154.2817),
vector4(-1440.0933, -773.8246, 23.4396, 343.2090),
}
}

View File

@ -0,0 +1,62 @@
function CreateVeh(modelHash, ...)
RequestModel(modelHash)
while not HasModelLoaded(modelHash) do Wait(0) end
local veh = CreateVehicle(modelHash, ...)
SetModelAsNoLongerNeeded(modelHash)
return veh
end
function CreateNPC(modelHash, ...)
RequestModel(modelHash)
while not HasModelLoaded(modelHash) do Wait(0) end
local ped = CreatePed(26, modelHash, ...)
SetModelAsNoLongerNeeded(modelHash)
return ped
end
function CreateProp(modelHash, ...)
RequestModel(modelHash)
while not HasModelLoaded(modelHash) do Wait(0) end
local obj = CreateObject(modelHash, ...)
SetModelAsNoLongerNeeded(modelHash)
return obj
end
function PlayAnim(ped, dict, ...)
RequestAnimDict(dict)
while not HasAnimDictLoaded(dict) do Wait(0) end
TaskPlayAnim(ped, dict, ...)
end
function PlayEffect(dict, particleName, entity, off, rot, time, cb)
CreateThread(function()
RequestNamedPtfxAsset(dict)
while not HasNamedPtfxAssetLoaded(dict) do
Wait(0)
end
UseParticleFxAssetNextCall(dict)
Wait(10)
local particleHandle = StartParticleFxLoopedOnEntity(particleName, entity, off.x, off.y, off.z, rot.x, rot.y, rot.z, 1.0)
SetParticleFxLoopedColour(particleHandle, 0, 255, 0 , 0)
Wait(time)
StopParticleFxLooped(particleHandle, false)
cb()
end)
end
function CreateBlip(data)
local x,y,z = table.unpack(data.Location)
local blip = AddBlipForCoord(x, y, z)
SetBlipSprite(blip, data.ID)
SetBlipDisplay(blip, data.Display)
SetBlipScale(blip, data.Scale)
SetBlipColour(blip, data.Color)
if (data.Rotation) then
SetBlipRotation(blip, math.ceil(data.Rotation))
end
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(data.Label)
EndTextCommandSetBlipName(blip)
return blip
end

View File

@ -0,0 +1,10 @@
function v3(coords) return vec3(coords.x, coords.y, coords.z), coords.w end
function GetRandomInt(min, max, exclude)
for i=1, 1000 do
local int = math.random(min, max)
if exclude == nil or exclude ~= int then
return int
end
end
end

View File

@ -0,0 +1,24 @@
fx_version 'cerulean'
game "gta5"
version "v1.0.0"
shared_scripts {
"@ox_lib/init.lua",
"config.lua",
"locales/locale.lua",
"locales/translations/da.lua",
"core/shared.lua"
}
client_scripts {
"bridge/**/client.lua",
"modules/**/client.lua",
"core/client.lua"
}
server_scripts {
"bridge/**/server.lua",
"modules/**/server.lua",
}
lua54 'yes'

View File

@ -0,0 +1,14 @@
Language = {}
function _L(name, ...)
if name then
local str = Language[Config.Language][name]
if str then
return string.format(str, ...)
else
return "ERR_TRANSLATE_"..(name).."_404"
end
else
return "ERR_TRANSLATE_404"
end
end

View File

@ -0,0 +1,26 @@
Language["da"] = {
marker_interact_vehicle = "Tryk ~INPUT_CONTEXT~ for at åbne køretøjsmenuen.",
marker_remove_vehicle = "Tryk ~INPUT_CONTEXT~ for at parkere køretøjet.",
marker_interact_boss = "Tryk ~INPUT_CONTEXT~ for at åbne ledermenuen.",
marker_interact_duty = "Tryk ~INPUT_CONTEXT~ for at gå %s-duty.",
vehicle_menu = "Køretøjsvalg",
vehicle_none = "Du har ingen køretøjer at vælge imellem.",
vehicle_stored = "Dit køretøj er blevet parkeret.",
vehicle_spawned = "Du er spawnet i arbejdskøretøjet.",
no_access = "Du kan ikke gøre dette.",
duty_toggle = "Du er gået %s-duty hos %s.",
duty_forceoff = "Du gik hjem fra arbejde",
not_duty = "Du er ikke på arbejde.",
taxi_occupied = "Der er en person i bilen, kør dem til deres destination før du starter et nyt job.",
taxi_pickup = "Hent personen der er markeret på din GPS.",
taxi_dropoff = "Aflever personen på den lokation der er markeret på din GPS.",
not_driver = "Du kører ikke en taxa.",
mission_fail = "Du har fejlet dit job.",
mission_success = "Du har fuldført ruten, og modtaget %s,-",
cancelled_mission = "Annullerede det nuværende job.",
taxi_pickup_blip = "Hent Kunde",
taxi_dropoff_blip = "Aflever Kunde",
}

View File

@ -0,0 +1,109 @@
STATUS = {
BUSINESS = nil,
DUTY = false
}
function GetStatus()
return STATUS
end
function SetDutyStatus(businessID, bool)
TriggerServerEvent("pickle_taxijob:setDutyStatus", businessID, bool)
end
function OpenVehicleMenu(businessID)
local cfg = Config.Businesses[businessID]
if not CanAccessGroup(cfg.groups) then
return ShowNotification(_L("no_access"))
end
if not STATUS.DUTY then
return ShowNotification(_L("not_duty"))
end
local options = {}
for i=1, #cfg.vehicles do
if CanAccessGroup(cfg.vehicles[i].groups) then
table.insert(options, {label = cfg.vehicles[i].label, value = i})
end
end
if #options < 1 then return ShowNotification(_L("vehicle_none")) end
lib.registerMenu({
id = 'pickle_taxijob_vehicle',
title = _L("vehicle_menu"),
position = 'top-right',
options = options
}, function(selected, scrollIndex, args)
local ped = PlayerPedId()
local vehicleData = cfg.vehicles[options[selected].value]
local coords, heading = v3(cfg.locations.vehicle)
local vehicle = CreateVeh(vehicleData.model, coords.x, coords.y, coords.z, heading, true, true)
TaskWarpPedIntoVehicle(ped, vehicle, -1)
ShowNotification(_L("vehicle_spawned"))
end)
lib.showMenu('pickle_taxijob_vehicle')
end
function InteractLocation(businessID, locationID)
if locationID == "vehicle" then
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle ~= 0 then
TaskLeaveAnyVehicle(PlayerPedId())
Wait(1500)
DeleteEntity(vehicle)
ShowNotification(_L("vehicle_stored"))
else
OpenVehicleMenu(businessID)
end
elseif locationID == "boss" then
AccessBossMenu(businessID)
elseif locationID == "duty" then
SetDutyStatus(businessID, not STATUS.DUTY)
end
end
function DisplayHelp(businessID, locationID)
if locationID == "vehicle" then
if GetVehiclePedIsIn(PlayerPedId()) ~= 0 then
ShowHelpNotification(_L("marker_remove_vehicle"))
else
ShowHelpNotification(_L("marker_interact_vehicle"))
end
elseif locationID == "boss" then
ShowHelpNotification(_L("marker_interact_boss"))
elseif locationID == "duty" then
ShowHelpNotification(_L("marker_interact_duty", STATUS.DUTY and "hjem fra arbejde" or "på arbejde"))
end
end
RegisterNetEvent("pickle_taxijob:onDutyUpdate", function(businessID, bool)
STATUS.BUSINESS = businessID
STATUS.DUTY = bool
end)
CreateThread(function()
for i=1, #Config.Businesses do
if Config.Businesses[i].blip then
CreateBlip(Config.Businesses[i].blip)
end
end
while true do
local wait = 1000
for i=1, #Config.Businesses do
local cfg = Config.Businesses[i]
local ped = PlayerPedId()
local pcoords = GetEntityCoords(ped)
for k,v in pairs(cfg.locations) do
local coords = v3(v)
local dist = #(coords - pcoords)
if (dist < 20) then
wait = 0
DrawMarker(2, coords.x, coords.y, coords.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.25, 0.25, 255, 255, 255, 127, false, true)
if (dist < 1.25 and not DisplayHelp(i, k) and IsControlJustPressed(1, 51)) then
InteractLocation(i, k)
end
end
end
end
Wait(wait)
end
end)

View File

@ -0,0 +1,32 @@
Players = {}
function GetPlayer(source, createIfEmpty)
if Players[source] then
return Players[source]
elseif createIfEmpty then
Players[source] = {}
return Players[source]
end
end
function SetDutyStatus(source, businessID, bool)
local player = GetPlayer(source, true)
Players[source].BUSINESS = businessID
Players[source].DUTY = bool
TriggerClientEvent("pickle_taxijob:onDutyUpdate", source, businessID, bool)
end
RegisterNetEvent("pickle_taxijob:setDutyStatus", function(businessID, bool)
if type(businessID) ~= "boolean" then
local cfg = Config.Businesses[businessID]
if CanAccessGroup(cfg.groups) then
SetDutyStatus(source, businessID, bool)
ShowNotification(source, _L("duty_toggle", bool and "på arbejde" or "hjem fra arbejde", cfg.info.label))
else
ShowNotification(source, _L("no_access"))
end
else
SetDutyStatus(source, nil, false)
ShowNotification(source, _L("duty_forceoff"))
end
end)

View File

@ -0,0 +1,174 @@
local blip
local mission
function Destination(text, coords)
if blip then
RemoveBlip(blip)
end
if not text then
return
end
blip = CreateBlip({
Location = coords,
Label = text,
ID = 1,
Display = 4,
Color = 5,
Scale = 0.75
})
SetBlipRoute(blip, true)
SetBlipRouteColour(blip, 5)
return blip
end
function IsVehicleTaxi(vehicle, list)
local model = GetEntityModel(vehicle)
for i=1, #list do
if model == list[i].model then
return true
end
end
end
function StartMission(lastIndex)
if not STATUS.DUTY then
return ShowNotification(_L("not_duty"))
end
local business = Config.Businesses[STATUS.BUSINESS]
local cfg = Config.Missions
mission = {}
mission.from = GetRandomInt(1, #cfg.locations, lastIndex)
mission.to = GetRandomInt(1, #cfg.locations, mission.from)
mission.model = cfg.models[GetRandomInt(1, #cfg.models)]
mission.ped = nil
mission.taxi = GetVehiclePedIsIn(PlayerPedId())
mission.status = "pickup"
if GetPedInVehicleSeat(mission.taxi, 2) ~= 0 then
return ShowNotification(_L("taxi_occupied"))
end
if GetPedInVehicleSeat(mission.taxi, -1) ~= PlayerPedId() or not IsVehicleTaxi(mission.taxi, business.vehicles) then
return ShowNotification(_L("not_driver"))
end
if (mission and mission.status == "pickup") then
local coords, heading = v3(cfg.locations[mission.from])
local enteringVehicle = false
ShowNotification(_L("taxi_pickup"))
Destination(_L("taxi_pickup_blip"), coords)
while mission and mission.status == "pickup" do
local wait = 1000
local ped = PlayerPedId()
local pedCoords = GetEntityCoords(ped)
local dist = #(coords - pedCoords)
if (not DoesEntityExist(mission.taxi) or GetEntityHealth(mission.taxi) == 0) then
mission.status = "fail"
end
if (dist < 60.0) then
if not mission.ped then
enteringVehicle = false
mission.ped = CreateNPC(mission.model, coords.x, coords.y, coords.z, heading, true, true)
else
if IsEntityDead(mission.ped) then
mission.status = "fail"
end
if (dist < 10.0 and not enteringVehicle) then
enteringVehicle = true
TaskEnterVehicle(mission.ped, mission.taxi, -1, 2, 2.0, 1, 0)
elseif GetVehiclePedIsIn(mission.ped) == mission.taxi then
mission.status = "dropoff"
end
end
elseif mission.ped then
DeleteEntity(mission.ped)
mission.ped = nil
end
Wait(wait)
end
end
if (mission and mission.status == "dropoff") then
local coords, heading = v3(cfg.locations[mission.to])
local exitingVehicle = false
ShowNotification(_L("taxi_dropoff"))
Destination(_L("taxi_dropoff_blip"), coords)
while mission and mission.status == "dropoff" do
local wait = 1000
local ped = PlayerPedId()
local pedCoords = GetEntityCoords(ped)
local dist = #(coords - pedCoords)
if (not DoesEntityExist(mission.taxi) or GetEntityHealth(mission.taxi) == 0) then
mission.status = "fail"
end
if (not exitingVehicle and GetVehiclePedIsIn(mission.ped) ~= mission.taxi) or (not DoesEntityExist(mission.ped) or IsEntityDead(mission.ped)) then
mission.status = "fail"
end
if (dist < 5.0 and not exitingVehicle) then
exitingVehicle = true
TaskLeaveAnyVehicle(mission.ped, 1, 1)
elseif exitingVehicle and GetVehiclePedIsIn(mission.ped) ~= mission.taxi then
mission.status = "success"
end
Wait(wait)
end
end
Destination()
if (mission and mission.status == "success") then
for i=-1, 4 do
SetVehicleDoorShut(mission.taxi, i, false)
end
ServerCallback("pickle_taxijob:npcMissionComplete", function(result)
if result then
local ped = mission.ped
TaskWanderStandard(ped, 1, 1)
SetTimeout(5000, function()
DeleteEntity(ped)
end)
else
ShowNotification(_L("mission_fail"))
end
if cfg.loop then
StartMission(mission.to)
else
mission = nil
end
end, mission.from, mission.to)
elseif (mission) then
for i=-1, 4 do
SetVehicleDoorShut(mission.taxi, i, false)
end
ShowNotification(_L("mission_fail"))
if cfg.loop then
StartMission(mission.to)
else
mission = nil
end
end
end
function StopMission()
local _mission = mission
mission = nil
if _mission.ped then
DeleteEntity(_mission.ped)
end
Destination()
ShowNotification(_L("cancelled_mission"))
end
RegisterCommand("taxijob", function()
if mission then
StopMission()
else
StartMission()
end
end)

View File

@ -0,0 +1,19 @@
RegisterCallback("pickle_taxijob:npcMissionComplete", function(source, cb, from, to)
local player = GetPlayer(source, true)
local cfg = Config.Missions
local coords = {
from = v3(cfg.locations[from]),
to = v3(cfg.locations[to]),
}
local dist = #(coords.from - coords.to)
if (player.DUTY) then
local amount = math.random(cfg.reward.min, cfg.reward.max)
local multi = cfg.reward.miles * (dist / 1000)
amount = math.ceil(amount * multi)
AddItem(source, cfg.reward.name, amount)
ShowNotification(source, _L("mission_success", amount))
cb(true)
else
cb(false)
end
end)

View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -0,0 +1,35 @@
# qb-ambulancejob
EMS Job and Death/Wound Logic for QB-Core Framework :ambulance:
## Dependencies
- [qb-core](https://github.com/qbcore-framework/qb-core) (Required)
- [qb-phone](https://github.com/qbcore-framework/qb-phone) (Required)
- [qb-target](https://github.com/BerkieBb/qb-target) (Optional)
- [PolyZone](https://github.com/mkafrin/PolyZone) (Required)
## Showcase
- [walk trough](https://www.youtube.com/watch?v=LWKerWlh3g4)
## Features
- [More Config Option](https://youtu.be/9Qn4qRrGi7A)
- Ped Integratios
- [Ranjit's emsbag](https://github.com/Ranjit-Develops/Ranjit-EMS-bag) integration
# License
QBCore Framework
Copyright (C) 2021 Joshua Eger
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>

View File

@ -0,0 +1,223 @@
local deadAnimDict = "dead"
local deadAnim = "dead_a"
local hold = 5
deathTime = 0
-- Functions
local function loadAnimDict(dict)
while (not HasAnimDictLoaded(dict)) do
RequestAnimDict(dict)
Wait(5)
end
end
function OnDeath()
if not isDead then
isDead = true
TriggerServerEvent("hospital:server:SetDeathStatus", true)
TriggerServerEvent("InteractSound_SV:PlayOnSource", "demo", 0.1)
local player = PlayerPedId()
while GetEntitySpeed(player) > 0.5 or IsPedRagdoll(player) do
Wait(10)
end
if isDead then
local pos = GetEntityCoords(player)
local heading = GetEntityHeading(player)
local ped = PlayerPedId()
if IsPedInAnyVehicle(ped) then
local veh = GetVehiclePedIsIn(ped)
local vehseats = GetVehicleModelNumberOfSeats(GetHashKey(GetEntityModel(veh)))
for i = -1, vehseats do
local occupant = GetPedInVehicleSeat(veh, i)
if occupant == ped then
NetworkResurrectLocalPlayer(pos.x, pos.y, pos.z + 0.5, heading, true, false)
SetPedIntoVehicle(ped, veh, i)
end
end
else
NetworkResurrectLocalPlayer(pos.x, pos.y, pos.z + 0.5, heading, true, false)
end
SetEntityInvincible(player, true)
SetEntityHealth(player, GetEntityMaxHealth(player))
if IsPedInAnyVehicle(player, false) then
loadAnimDict("veh@low@front_ps@idle_duck")
TaskPlayAnim(player, "veh@low@front_ps@idle_duck", "sit", 1.0, 1.0, -1, 1, 0, 0, 0, 0)
else
loadAnimDict(deadAnimDict)
TaskPlayAnim(player, deadAnimDict, deadAnim, 1.0, 1.0, -1, 1, 0, 0, 0, 0)
end
TriggerServerEvent('hospital:server:ambulanceAlert', Lang:t('info.civ_died'))
end
end
end
function DeathTimer()
hold = 5
while isDead do
Wait(1000)
deathTime = deathTime - 1
if deathTime <= 0 then
if IsControlPressed(0, 38) and hold <= 0 and not isInHospitalBed then
TriggerEvent("hospital:client:RespawnAtHospital")
hold = 5
end
if IsControlPressed(0, 38) then
if hold - 1 >= 0 then
hold = hold - 1
else
hold = 0
end
end
if IsControlReleased(0, 38) then
hold = 5
end
end
end
end
local function DrawTxt(x, y, width, height, scale, text, r, g, b, a, _)
SetTextFont(4)
SetTextProportional(0)
SetTextScale(scale, scale)
SetTextColour(r, g, b, a)
SetTextDropShadow(0, 0, 0, 0,255)
SetTextEdge(2, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
AddTextComponentString(text)
DrawText(x - width/2, y - height/2 + 0.005)
end
-- Damage Handler
AddEventHandler('gameEventTriggered', function(event, data)
if event == "CEventNetworkEntityDamage" then
local victim, attacker, victimDied, weapon = data[1], data[2], data[4], data[7]
if not IsEntityAPed(victim) then return end
if victimDied and NetworkGetPlayerIndexFromPed(victim) == PlayerId() and IsEntityDead(PlayerPedId()) then
if not InLaststand then
SetLaststand(true)
elseif InLaststand and not isDead then
SetLaststand(false)
local playerid = NetworkGetPlayerIndexFromPed(victim)
local playerName = GetPlayerName(playerid) .. " " .. "("..GetPlayerServerId(playerid)..")" or Lang:t('info.self_death')
local killerId = NetworkGetPlayerIndexFromPed(attacker)
local killerName = GetPlayerName(killerId) .. " " .. "("..GetPlayerServerId(killerId)..")" or Lang:t('info.self_death')
local weaponLabel = QBCore.Shared.Weapons[weapon].label or 'Ukendt'
local weaponName = QBCore.Shared.Weapons[weapon].name or 'Ukendt'
TriggerServerEvent("qb-log:server:CreateLog", "death", Lang:t('logs.death_log_title', {playername = playerName, playerid = GetPlayerServerId(playerid)}), "red", Lang:t('logs.death_log_message', {killername = killerName, playername = playerName, weaponlabel = weaponLabel, weaponname = weaponName}))
deathTime = Config.DeathTime
OnDeath()
DeathTimer()
end
end
end
end)
-- Threads
emsNotified = false
CreateThread(function()
while true do
local sleep = 1000
if isDead or InLaststand then
sleep = 5
local ped = PlayerPedId()
DisableAllControlActions(0)
EnableControlAction(0, 1, true)
EnableControlAction(0, 2, true)
EnableControlAction(0, 245, true)
EnableControlAction(0, 38, true)
EnableControlAction(0, 0, true)
EnableControlAction(0, 322, true)
EnableControlAction(0, 288, true)
EnableControlAction(0, 213, true)
EnableControlAction(0, 249, true)
EnableControlAction(0, 46, true)
EnableControlAction(0, 47, true)
if isDead then
if not isInHospitalBed then
if deathTime > 0 then
DrawTxt(0.93, 1.44, 1.0,1.0,0.6, Lang:t('info.respawn_txt', {deathtime = math.ceil(deathTime)}), 255, 255, 255, 255)
else
DrawTxt(0.865, 1.44, 1.0, 1.0, 0.6, Lang:t('info.respawn_revive', {holdtime = hold, cost = Config.BillCost}), 255, 255, 255, 255)
end
end
if IsPedInAnyVehicle(ped, false) then
loadAnimDict("veh@low@front_ps@idle_duck")
if not IsEntityPlayingAnim(ped, "veh@low@front_ps@idle_duck", "sit", 3) then
TaskPlayAnim(ped, "veh@low@front_ps@idle_duck", "sit", 1.0, 1.0, -1, 1, 0, 0, 0, 0)
end
else
if isInHospitalBed then
if not IsEntityPlayingAnim(ped, inBedDict, inBedAnim, 3) then
loadAnimDict(inBedDict)
TaskPlayAnim(ped, inBedDict, inBedAnim, 1.0, 1.0, -1, 1, 0, 0, 0, 0)
end
else
if not IsEntityPlayingAnim(ped, deadAnimDict, deadAnim, 3) then
loadAnimDict(deadAnimDict)
TaskPlayAnim(ped, deadAnimDict, deadAnim, 1.0, 1.0, -1, 1, 0, 0, 0, 0)
end
end
end
SetCurrentPedWeapon(ped, `WEAPON_UNARMED`, true)
elseif InLaststand then
sleep = 5
if LaststandTime > Config.MinimumRevive then
DrawTxt(0.94, 1.44, 1.0, 1.0, 0.6, Lang:t('info.bleed_out', {time = math.ceil(LaststandTime)}), 255, 255, 255, 255)
else
DrawTxt(0.845, 1.44, 1.0, 1.0, 0.6, Lang:t('info.bleed_out_help', {time = math.ceil(LaststandTime)}), 255, 255, 255, 255)
if not emsNotified then
DrawTxt(0.91, 1.40, 1.0, 1.0, 0.6, Lang:t('info.request_help'), 255, 255, 255, 255)
else
DrawTxt(0.90, 1.40, 1.0, 1.0, 0.6, Lang:t('info.help_requested'), 255, 255, 255, 255)
end
if IsControlJustPressed(0, 47) and not emsNotified then
TriggerServerEvent('hospital:server:ambulanceAlert', Lang:t('info.civ_down'))
emsNotified = true
end
end
if not isEscorted then
if IsPedInAnyVehicle(ped, false) then
loadAnimDict("veh@low@front_ps@idle_duck")
if not IsEntityPlayingAnim(ped, "veh@low@front_ps@idle_duck", "sit", 3) then
TaskPlayAnim(ped, "veh@low@front_ps@idle_duck", "sit", 1.0, 1.0, -1, 1, 0, 0, 0, 0)
end
else
loadAnimDict(lastStandDict)
if not IsEntityPlayingAnim(ped, lastStandDict, lastStandAnim, 3) then
TaskPlayAnim(ped, lastStandDict, lastStandAnim, 1.0, 1.0, -1, 1, 0, 0, 0, 0)
end
end
else
if IsPedInAnyVehicle(ped, false) then
loadAnimDict("veh@low@front_ps@idle_duck")
if IsEntityPlayingAnim(ped, "veh@low@front_ps@idle_duck", "sit", 3) then
StopAnimTask(ped, "veh@low@front_ps@idle_duck", "sit", 3)
end
else
loadAnimDict(lastStandDict)
if IsEntityPlayingAnim(ped, lastStandDict, lastStandAnim, 3) then
StopAnimTask(ped, lastStandDict, lastStandAnim, 3)
end
end
end
end
end
Wait(sleep)
end
end)

View File

@ -0,0 +1,74 @@
local QBCore = exports['qb-core']:GetCoreObject()
local emsbag1 = nil
local function dropemsbag()
DetachEntity(emsbag1)
PlaceObjectOnGroundProperly(emsbag1)
end
local function spawnemsbag()
local hasBag = true
CreateThread(function()
while hasBag do
Wait(0)
if IsControlJustReleased(0, 38) then -- If E is pressed it drop the bag
hasBag = false
dropemsbag()
Wait(1000)
end
end
end)
end
local ObjectList = {}
RegisterNetEvent('Ranjit-EmsBag:Client:SpawnAmbulanceBag', function()
local hash = GetHashKey('prop_cs_shopping_bag')
local ped = PlayerPedId()
local x, y, z = table.unpack(GetOffsetFromEntityInWorldCoords(ped, 0.0, 3.0, 0.5))
QBCore.Functions.LoadModel(hash)
emsbag1 = CreateObjectNoOffset(hash, x, y, z, true, false)
SetModelAsNoLongerNeeded(hash)
AttachEntityToEntity(emsbag1, ped, GetPedBoneIndex(ped, 57005), 0.42, 0, -0.05, 0.10, 270.0, 60.0, true, true, false,
true, 1, true)
spawnemsbag()
TriggerServerEvent("Ranjit-EmsBag:Server:RemoveItem","emsbag",1)
end)
RegisterNetEvent('Ranjit-EmsBag:Client:spawnLight', function()
TriggerServerEvent("Ranjit-EmsBag:Server:SpawnAmbulanceBag", "emsbag")
end)
RegisterNetEvent('Ranjit-EmsBag:Client:GuardarAmbulanceBag')
AddEventHandler("Ranjit-EmsBag:Client:GuardarAmbulanceBag", function()
local x, y, z = table.unpack(GetEntityCoords(PlayerPedId(), true))
local playerPedPos = GetEntityCoords(PlayerPedId(), true)
local AmbulanceBag = GetClosestObjectOfType(playerPedPos, 10.0, GetHashKey("prop_cs_shopping_bag"), false, false, false)
local playerPed = PlayerPedId()
TaskStartScenarioInPlace(playerPed, "CODE_HUMAN_MEDIC_TEND_TO_DEAD")
progressBar("Tager EMS taske...")
Wait(2500)
Notify("EMS taske taget.")
SetEntityAsMissionEntity(AmbulanceBag, 1, 1)
DeleteObject(AmbulanceBag)
TriggerServerEvent("Ranjit-EmsBag:Server:AddItem","emsbag",1)
end)
local citizenid = nil
AddEventHandler("Ranjit-EmsBag:Client:StorageAmbulanceBag", function()
local charinfo = QBCore.Functions.GetPlayerData().charinfo
citizenid = QBCore.Functions.GetPlayerData().citizenid
TriggerEvent("inventory:client:SetCurrentStash", "Ambulance Taske",citizenid)
TriggerServerEvent("inventory:server:OpenInventory", "stash", "Ambulance Taske",citizenid, {
maxweight = Config.Stash.MaxWeighStash,
slots = Config.Stash.MaxSlotsStash,
})
end)
local AmbulanceBags = {
`prop_cs_shopping_bag`,
}
exports['qb-target']:AddTargetModel(AmbulanceBags, {
options = {{event = "Ranjit-EmsBag:Client:MenuAmbulanceBag",icon = "fa-solid fa-suitcase-medical",label = "Ems taske" , job = Config.Bag.Job },
{event = "Ranjit-EmsBag:Client:GuardarAmbulanceBag",icon = "fa-solid fa-suitcase-medical",label = "Tag EMS taske" , job = Config.Bag.Job },},distance = 2.0 })

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,181 @@
Laststand = Laststand or {}
Laststand.ReviveInterval = 360
Laststand.MinimumRevive = 300
InLaststand = false
LaststandTime = 0
lastStandDict = "combat@damage@rb_writhe"
lastStandAnim = "rb_writhe_loop"
isEscorted = false
local isEscorting = false
-- Functions
local function GetClosestPlayer()
local closestPlayers = QBCore.Functions.GetPlayersFromCoords()
local closestDistance = -1
local closestPlayer = -1
local coords = GetEntityCoords(PlayerPedId())
for i=1, #closestPlayers, 1 do
if closestPlayers[i] ~= PlayerId() then
local pos = GetEntityCoords(GetPlayerPed(closestPlayers[i]))
local distance = #(pos - coords)
if closestDistance == -1 or closestDistance > distance then
closestPlayer = closestPlayers[i]
closestDistance = distance
end
end
end
return closestPlayer, closestDistance
end
local function LoadAnimation(dict)
while not HasAnimDictLoaded(dict) do
RequestAnimDict(dict)
Wait(100)
end
end
function SetLaststand(bool, spawn)
local ped = PlayerPedId()
if bool then
Wait(1000)
local pos = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
while GetEntitySpeed(ped) > 0.5 or IsPedRagdoll(ped) do
Wait(10)
end
TriggerServerEvent("InteractSound_SV:PlayOnSource", "heart", 0.2)
LaststandTime = Laststand.ReviveInterval
local ped = PlayerPedId()
if IsPedInAnyVehicle(ped) then
local veh = GetVehiclePedIsIn(ped)
local vehseats = GetVehicleModelNumberOfSeats(GetHashKey(GetEntityModel(veh)))
for i = -1, vehseats do
local occupant = GetPedInVehicleSeat(veh, i)
if occupant == ped then
NetworkResurrectLocalPlayer(pos.x, pos.y, pos.z + 0.5, heading, true, false)
SetPedIntoVehicle(ped, veh, i)
end
end
else
NetworkResurrectLocalPlayer(pos.x, pos.y, pos.z + 0.5, heading, true, false)
end
SetEntityHealth(ped, 150)
if IsPedInAnyVehicle(ped, false) then
LoadAnimation("veh@low@front_ps@idle_duck")
TaskPlayAnim(ped, "veh@low@front_ps@idle_duck", "sit", 1.0, 8.0, -1, 1, -1, false, false, false)
else
LoadAnimation(lastStandDict)
TaskPlayAnim(ped, lastStandDict, lastStandAnim, 1.0, 8.0, -1, 1, -1, false, false, false)
end
InLaststand = true
TriggerServerEvent('hospital:server:ambulanceAlert', Lang:t('info.civ_down'))
CreateThread(function()
while InLaststand do
ped = PlayerPedId()
player = PlayerId()
if LaststandTime - 1 > Laststand.MinimumRevive then
LaststandTime = LaststandTime - 1
Config.DeathTime = LaststandTime
elseif LaststandTime - 1 <= Laststand.MinimumRevive and LaststandTime - 1 ~= 0 then
LaststandTime = LaststandTime - 1
Config.DeathTime = LaststandTime
elseif LaststandTime - 1 <= 0 then
QBCore.Functions.Notify(Lang:t('error.bled_out'), "error")
SetLaststand(false)
local killer_2, killerWeapon = NetworkGetEntityKillerOfPlayer(player)
local killer = GetPedSourceOfDeath(ped)
if killer_2 ~= 0 and killer_2 ~= -1 then
killer = killer_2
end
local killerId = NetworkGetPlayerIndexFromPed(killer)
local killerName = killerId ~= -1 and GetPlayerName(killerId) .. " " .. "("..GetPlayerServerId(killerId)..")" or Lang:t('info.self_death')
local weaponLabel = Lang:t('info.wep_unknown')
local weaponName = Lang:t('info.wep_unknown')
local weaponItem = QBCore.Shared.Weapons[killerWeapon]
if weaponItem then
weaponLabel = weaponItem.label
weaponName = weaponItem.name
end
TriggerServerEvent("qb-log:server:CreateLog", "death", Lang:t('logs.death_log_title', {playername = GetPlayerName(-1), playerid = GetPlayerServerId(player)}), "red", Lang:t('logs.death_log_message', {killername = killerName, playername = GetPlayerName(player), weaponlabel = weaponLabel, weaponname = weaponName}))
deathTime = 0
OnDeath()
DeathTimer()
end
Wait(1000)
end
end)
else
TaskPlayAnim(ped, lastStandDict, "exit", 1.0, 8.0, -1, 1, -1, false, false, false)
InLaststand = false
LaststandTime = 0
end
TriggerServerEvent("hospital:server:SetLaststandStatus", bool)
end
-- Events
RegisterNetEvent('hospital:client:SetEscortingState', function(bool)
isEscorting = bool
end)
RegisterNetEvent('hospital:client:isEscorted', function(bool)
isEscorted = bool
end)
RegisterNetEvent('hospital:client:UseFirstAid', function()
if not isEscorting then
local player, distance = GetClosestPlayer()
if player ~= -1 and distance < 1.5 then
local playerId = GetPlayerServerId(player)
TriggerServerEvent('hospital:server:UseFirstAid', playerId)
end
else
QBCore.Functions.Notify(Lang:t('error.impossible'), 'error')
end
end)
RegisterNetEvent('hospital:client:CanHelp', function(helperId)
if InLaststand then
if LaststandTime <= 300 then
TriggerServerEvent('hospital:server:CanHelp', helperId, true)
else
TriggerServerEvent('hospital:server:CanHelp', helperId, false)
end
else
TriggerServerEvent('hospital:server:CanHelp', helperId, false)
end
end)
RegisterNetEvent('hospital:client:HelpPerson', function(targetId)
local ped = PlayerPedId()
isHealingPerson = true
QBCore.Functions.Progressbar("hospital_revive", Lang:t('progress.revive'), math.random(30000, 60000), false, true, {
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = true,
}, {
animDict = healAnimDict,
anim = healAnim,
flags = 1,
}, {}, {}, function() -- Done
isHealingPerson = false
ClearPedTasks(ped)
QBCore.Functions.Notify(Lang:t('success.revived'), 'success')
TriggerServerEvent("hospital:server:RevivePlayer", targetId)
end, function() -- Cancel
isHealingPerson = false
ClearPedTasks(ped)
QBCore.Functions.Notify(Lang:t('error.canceled'), "error")
end)
end)

Some files were not shown because too many files have changed in this diff Show More