Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qb-menu #2

Merged
merged 3 commits into from
Feb 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 131 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,134 @@ QBCore.Functions.DeleteObject = function(object)
SetEntityAsMissionEntity(object, false, true)
DeleteObject(object)
end
```
# Add to qb-target

```
Config.TargetModels = {
["cokeplant"] = {
models = {
"mw_coke_plant",
},
options = {
{
type = "client",
event = "qb-drugtrafficking:client:coke",
icon = "fas fa-leaf",
label = "Pickup Coke Leafs",
},
},
distance = 4.0
},
["heroinplant"] = {
models = {
"mw_heroin_plant",
},
options = {
{
type = "client",
event = "qb-drugtrafficking:client:heorin",
icon = "fas fa-seedling",
label = "Pickup Poppy Plants",
},
},
distance = 4.0
},
["weedplant"] = {
models = {
"mw_weed_plant",
},
options = {
{
type = "client",
event = "qb-drugtrafficking:client:weed",
icon = "fas fa-envira",
label = "Pickup Weed Leafs",
},
},
distance = 4.0
},
["hydrobarrel"] = {
models = {
"mw_hydro_barrel",
},
options = {
{
type = "client",
event = "qb-drugtrafficking:client:hydro",
icon = "fas fa-biohazard",
label = "Pickup Hydro Barrel",
},
},
distance = 4.0
},
["sodiumbarrel"] = {
models = {
"mw_sodium_barrel",
},
options = {
{
type = "client",
event = "qb-drugtrafficking:client:sodium",
icon = "fas fa-dna",
label = "Pickup Sodium Barrel",
},
},
distance = 4.0
},
["sulfuricbarrel"] = {
models = {
"mw_sulfuric_barrel",
},
options = {
{
type = "client",
event = "qb-drugtrafficking:client:sulfuric",
icon = "fas fa-shield-virus",
label = "Pickup Sulfuric Barrel",
},
},
distance = 4.0
},
["chemicalbarrel"] = {
models = {
"mw_chemical_barrel",
},
options = {
{
type = "client",
event = "qb-drugtrafficking:chemicals",
icon = "fas fa-radiation",
label = "Pickup Chem Barrels",
},
},
distance = 4.0
},
}

Config.BoxZones = {
["chemmenu"] = {
name = "chemmenu",
coords = vector3(3535.66, 3661.69, 28.12),
length = 1.65,
width = 2.4,
heading = 350,
debugPoly = false,
minZ = 27.52,
maxZ = 29.12,
options = {
{
type = "client",
event = "qb-drugtrafficking:chemicalmenu",
icon = "fas fa-vials",
label = "Learn a New Chemical Compound",
--job = "scientist", -- Remove this line if you do not want a job check.
},
},
distance = 2.5
},
}

```

# Helpful Triggers:
Expand All @@ -58,7 +186,9 @@ end
* "qb-drugtrafficking:lsa" - Process LSA


# Dependecies
# Dependencies
* qb-target - https://github.com/BerkieBb/qb-target
* qb-menu - https://github.com/qbcore-framework/qb-menu

# Original Repo
https://github.com/DoPeMan17/esx_drugs
91 changes: 39 additions & 52 deletions client/chemicals.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
local QBCore = exports['qb-core']:GetCoreObject()

local menuOpen = false
local wasOpen = false
local SpawnedChemicals = 0
local Chemicals = {}

Expand All @@ -27,7 +24,7 @@ AddEventHandler('onResourceStop', function(resource)
end
end)

Citizen.CreateThread(function()
--[[Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerPed = PlayerPedId()
Expand All @@ -46,60 +43,70 @@ Citizen.CreateThread(function()
end
end
end
end)]]--

-- Chemical Menu Trigger & Menu Button Triggers --

RegisterNetEvent('qb-drugtrafficking:chemicalmenu', function()
createChemicalMenu()
exports['qb-menu']:openMenu(chemMenu)
end)

RegisterNetEvent('qb-drugtrafficking:chemicalmenu', function(data)
TriggerEvent('qb-drugtrafficking:sendMenu', {
function createChemicalMenu()
chemMenu = {
{
id = 0,
header = "Chemical Menu",
txt = "",
isHeader = true,
header = 'Chemical Menu'
},
{
id = 1,
header = "Hydrochloric Acid",
txt = "x1 Chemicals",
params = {
event = "qb-drugtrafficking:hydrochloric_acid"
params = {
isServer = false,
event = "qb-drugtrafficking:hydrochloric_acid",
}
},
{
id = 2,
header = "Sodium Hydroxide",
txt = "x1 Chemicals",
params = {
event = "qb-drugtrafficking:sodium_hydroxide"
params = {
isServer = false,
event = "qb-drugtrafficking:sodium_hydroxide",
}
},
{
id = 3,
{
header = "Sulfuric Acid",
txt = "x1 Chemicals",
params = {
event = "qb-drugtrafficking:sulfuric_acid"
params = {
isServer = false,
event = "qb-drugtrafficking:sulfuric_acid",
}
},
{
id = 4,
header = "LSA",
{
header = "LSA",
txt = "x1 Chemicals",
params = {
event = "qb-drugtrafficking:lsa"
params = {
isServer = false,
event = "qb-drugtrafficking:lsa",
}
},
{
id = 5,
header = "Close (ESC)",
txt = "",
header = "Close Menu",
txt = "Close Menu",
params = {
isServer = false,
event = exports['qb-menu']:closeMenu(),
}
},
})
end)
}
exports['qb-menu']:openMenu(chemMenu)
end

--------------------------------------------------------------------

RegisterNetEvent("qb-drugtrafficking:hydrochloric_acid")
AddEventHandler("qb-drugtrafficking:hydrochloric_acid", function()
ped = PlayerPedId();
MenuTitle = "Chemicals"
ClearMenu()
QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
if result then
process_hydrochloric_acid()
Expand All @@ -112,8 +119,6 @@ end)
RegisterNetEvent("qb-drugtrafficking:lsa")
AddEventHandler("qb-drugtrafficking:lsa", function()
ped = PlayerPedId();
MenuTitle = "Chemicals"
ClearMenu()
QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
if result then
process_lsa()
Expand Down Expand Up @@ -159,8 +164,6 @@ end
RegisterNetEvent("qb-drugtrafficking:sulfuric_acid")
AddEventHandler("qb-drugtrafficking:sulfuric_acid", function()
ped = PlayerPedId();
MenuTitle = "Chemicals"
ClearMenu()
QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
if result then
process_sulfuric_acid()
Expand All @@ -173,8 +176,6 @@ end)
RegisterNetEvent("qb-drugtrafficking:sodium_hydroxide")
AddEventHandler("qb-drugtrafficking:sodium_hydroxide", function()
ped = PlayerPedId();
MenuTitle = "Chemicals"
ClearMenu()
QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
if result then
process_sodium_hydroxide()
Expand Down Expand Up @@ -283,15 +284,9 @@ function process_hydrochloric_acid()
isProcessing = false
end

function closeMenuFull()
Menu.hidden = true
currentGarage = nil
ClearMenu()
end

RegisterNetEvent("qb-drugtrafficking:chemicals")
AddEventHandler("qb-drugtrafficking:chemicals", function()
--while true do
Citizen.Wait(0)
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
Expand All @@ -304,12 +299,6 @@ AddEventHandler("qb-drugtrafficking:chemicals", function()
end

if nearbyObject and IsPedOnFoot(playerPed) then

--[[ if not isPickingUp then
QBCore.Functions.Draw2DText(0.5, 0.88, 'Press [~g~ E ~w~] to pickup chemicals', 0.5)
end ]]

--if IsControlJustReleased(0, 38) and not isPickingUp then
isPickingUp = true
TaskStartScenarioInPlace(playerPed, 'world_human_gardener_plant', 0, false)

Expand All @@ -332,11 +321,9 @@ AddEventHandler("qb-drugtrafficking:chemicals", function()
end)

isPickingUp = false
--end
else
Citizen.Wait(500)
end
--end
end)

function SpawnChemicals()
Expand Down Expand Up @@ -412,4 +399,4 @@ function GetCoordZChemicals(x, y)
end

return 5.9
end
end