Skip to content

Commit

Permalink
Merge pull request #8 from 3RROR-HUB/update-1
Browse files Browse the repository at this point in the history
Update 1
  • Loading branch information
MonkeyWhisper authored Mar 3, 2023
2 parents c197d41 + 04e51dd commit 0eff681
Show file tree
Hide file tree
Showing 10 changed files with 260 additions and 93 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ For all support questions, ask in our [Discord](https://www.discord.gg/projectsl
![image](https://user-images.githubusercontent.com/82112471/221007957-34e1641e-1cc0-469a-8bf1-33315ef1bdf0.png)
![image](https://user-images.githubusercontent.com/82112471/221006801-4639fe6e-3a07-4d27-b0e1-90e1134829fd.png)
![image](https://user-images.githubusercontent.com/82112471/221007532-bd50ae14-5927-4d7e-90fb-b2c1c9b0c467.png)
![image](https://user-images.githubusercontent.com/82112471/221007532-bd50ae14-5927-4d7e-90fb-b2c1c9b0c467.png)
![image](https://user-images.githubusercontent.com/107671912/222414486-e789257e-f9f4-4152-a8d0-738be9d13fa7.png)

# Processing Location

/tp 1041.77, -3199.31, -38.16

# Dependencies

Expand All @@ -23,12 +29,16 @@ For all support questions, ask in our [Discord](https://www.discord.gg/projectsl

## Add to your qb-core > shared > items.lua
```lua
--- ps-weedplanting
['weedplant_seedm'] = {['name'] = 'weedplant_seedm', ['label'] = 'Male Weed Seed', ['weight'] = 0, ['type'] = 'item', ['image'] = 'weedplant_seed.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = false, ['combinable'] = nil, ['description'] = 'Male Weed Seed'},
['weedplant_seedf'] = {['name'] = 'weedplant_seedf', ['label'] = 'Female Weed Seed', ['weight'] = 0, ['type'] = 'item', ['image'] = 'weedplant_seed.png', ['unique'] = false, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Female Weed Seed'},
['weedplant_branch'] = {['name'] = 'weedplant_branch', ['label'] = 'Weed Branch', ['weight'] = 10000, ['type'] = 'item', ['image'] = 'weedplant_branch.png', ['unique'] = true, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Weed plant'},
['weedplant_weed'] = {['name'] = 'weedplant_weed', ['label'] = 'Dried Weed', ['weight'] = 100, ['type'] = 'item', ['image'] = 'weedplant_weed.png', ['unique'] = true, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Weed ready for packaging'},
['weedplant_branch'] = {['name'] = 'weedplant_branch', ['label'] = 'Weed Branch', ['weight'] = 10000, ['type'] = 'item', ['image'] = 'weedplant_branch.png', ['unique'] = true, ['useable'] = false, ['shouldClose'] = false, ['combinable'] = nil, ['description'] = 'Weed plant'},
['weedplant_weed'] = {['name'] = 'weedplant_weed', ['label'] = 'Dried Weed', ['weight'] = 100, ['type'] = 'item', ['image'] = 'weedplant_weed.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = false, ['combinable'] = nil, ['description'] = 'Weed ready for packaging'},
['weedplant_packedweed'] = {['name'] = 'weedplant_packedweed', ['label'] = 'Packed Weed', ['weight'] = 100, ['type'] = 'item', ['image'] = 'weedplant_weed.png', ['unique'] = true, ['useable'] = false, ['shouldClose'] = false, ['combinable'] = nil, ['description'] = 'Weed ready for sale'},
['weedplant_package'] = {['name'] = 'weedplant_package', ['label'] = 'Suspicious Package', ['weight'] = 10000, ['type'] = 'item', ['image'] = 'weedplant_package.png', ['unique'] = true, ['useable'] = false, ['shouldClose'] = false, ['combinable'] = nil, ['description'] = 'Suspicious Package'},
['plant_tub'] = {['name'] = 'plant_tub', ['label'] = 'Plant Tub', ['weight'] = 1000, ['type'] = 'item', ['image'] = 'plant_tub.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = false, ['combinable'] = nil, ['description'] = 'Pot for planting plants'},
['empty_watering_can'] = {['name'] = 'empty_watering_can', ['label'] = 'Empty Watering Can', ['weight'] = 500, ['type'] = 'item', ['image'] = 'watering_can.png', ['unique'] = true, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Empty watering can'},
['full_watering_can'] = {['name'] = 'full_watering_can', ['label'] = 'Full Watering Can', ['weight'] = 1000, ['type'] = 'item', ['image'] = 'watering_can.png', ['unique'] = true, ['useable'] = false, ['shouldClose'] = false, ['combinable'] = nil, ['description'] = 'Watering can filled with water for watering plants'},
```
# Credits
* [Lionh34rt](https://github.com/Lionh34rt) | Check out more scripts from Lionh34rt [here.](https://lionh34rt.tebex.io/category/1954119)
50 changes: 46 additions & 4 deletions client/cl_planting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ RegisterNetEvent('ps-weedplanting:client:CheckPlant', function(data)
}
})
elseif result.growth == 100 then -- Harvest
if PlayerJob.type == 'leo' and PlayerJob.onduty then
if PlayerJob.type == Shared.CopJob and PlayerJob.onduty then
exports['qb-menu']:openMenu({
{
header = _U('plant_header'),
Expand Down Expand Up @@ -190,7 +190,7 @@ RegisterNetEvent('ps-weedplanting:client:CheckPlant', function(data)
})
end
elseif result.gender == 'female' then -- Option to add male seed
if PlayerJob.type == 'leo' and PlayerJob.onduty then
if PlayerJob.type == Shared.CopJob and PlayerJob.onduty then
exports['qb-menu']:openMenu({
{
header = _U('plant_header'),
Expand Down Expand Up @@ -262,7 +262,7 @@ RegisterNetEvent('ps-weedplanting:client:CheckPlant', function(data)
})
end
else -- No option to add male seed
if PlayerJob.type == 'leo' and PlayerJob.onduty then
if PlayerJob.type == Shared.CopJob and PlayerJob.onduty then
exports['qb-menu']:openMenu({
{
header = _U('plant_header'),
Expand Down Expand Up @@ -427,7 +427,7 @@ RegisterNetEvent('ps-weedplanting:client:FireGoBrrrrrrr', function(coords)
end)

RegisterNetEvent('ps-weedplanting:client:GiveWater', function(entity)
if QBCore.Functions.HasItem(Shared.WaterItem, 1) then
if QBCore.Functions.HasItem(Shared.FullCanItem, 1) then
local netId = NetworkGetNetworkIdFromEntity(entity)
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
Expand Down Expand Up @@ -466,6 +466,48 @@ RegisterNetEvent('ps-weedplanting:client:GiveWater', function(entity)
end
end)

RegisterNetEvent('ps-weedplanting:client:OpenFillWaterMenu', function()
exports['qb-menu']:openMenu({
{
header = _U('empty_watering_can_header'),
txt = _U('esc_to_close'),
icon = 'fas fa-chevron-left',
params = {
event = 'qb-menu:closeMenu'
}
},
{
header = _U('fill_can_header'),
txt = _U('fill_can_text'),
icon = 'fa-solid fa-oil-can',
params = {
event = 'ps-weedplanting:client:FillWater',
}
}
})
end)

RegisterNetEvent('ps-weedplanting:client:FillWater', function()

local hasItem = QBCore.Functions.HasItem(Shared.WaterItem)

if not hasItem then
QBCore.Functions.Notify(_U('missing_filling_water'), 'error', 2500)
return
end

QBCore.Functions.Progressbar('filling_water', _U('filling_water'), 2000, false, true, {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
}, {}, {}, {}, function()
TriggerServerEvent('ps-weedplanting:server:GetFullWateringCan')
end, function() -- Cancel
QBCore.Functions.Notify(_U('canceled'), 'error', 2500)
end)
end)

RegisterNetEvent('ps-weedplanting:client:GiveFertilizer', function(entity)
if QBCore.Functions.HasItem(Shared.FertilizerItem, 1) then
local netId = NetworkGetNetworkIdFromEntity(entity)
Expand Down
82 changes: 75 additions & 7 deletions client/cl_processing.lua
Original file line number Diff line number Diff line change
@@ -1,27 +1,95 @@
--- Events
local props = {}

RegisterNetEvent('ps-weedplanting:client:UseBranch', function()
QBCore.Functions.Progressbar('weedbranch', _U('processing_branch'), 5000, false, true, {
function SpawnWeedProcessProps()
for k, v in pairs(Shared.ProcessingProps) do
props[#props+1] = CreateObject(v.model,vector3(v.coords.x,v.coords.y,v.coords.z-1.00))
SetEntityHeading(props[#props],v.coords.w)
FreezeEntityPosition(props, true)
end
end

CreateThread(function ()

SpawnWeedProcessProps()

exports['qb-target']:AddBoxZone('weedprocess', vector3(1045.4, -3197.62, -38.16), 2.3, 1.0, {
name = 'weedprocess',
heading = 0,
minZ = -41.16,
maxZ = -37.50,
debugPoly = Shared.Debug,
}, {
options = {
{
type = 'client',
event = 'ps-weedplanting:client:ProcessBranch',
icon = 'fa-solid fa-cannabis',
label = _U('process_branch'),
},
{ -- Create Package
type = 'client',
event = 'ps-weedplanting:client:PackDryWeed',
icon = 'fa-solid fa-box',
label = _U('pack_dry_weed'),
}

},
distance = 1.5
})
end)

RegisterNetEvent('ps-weedplanting:client:ProcessBranch', function()

local hasItem = QBCore.Functions.HasItem(Shared.BranchItem, 1)

if not hasItem then
QBCore.Functions.Notify(_U('dont_have_branch'), 'error', 2500)
return
end

local ped = PlayerPedId()
local table = vector4(1045.4, -3197.62, -38.16, 0.0)

TaskTurnPedToFaceCoord(ped, table, 1000)
Wait(1300)

QBCore.Functions.Progressbar('weedbranch', _U('processing_branch'), 12000, false, true, {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
}, {}, {}, {}, function() -- Done
}, { animDict = "mini@repair", anim = "fixing_a_ped", flags = 8, }, {}, {}, function()
TriggerServerEvent('ps-weedplanting:server:ProcessBranch')
end, function() -- Cancel
QBCore.Functions.Notify(_U('canceled'), 'error', 2500)
ClearPedTasks(ped)
end)
end)

RegisterNetEvent('ps-weedplanting:client:UseDryWeed', function()
QBCore.Functions.Progressbar('dryweed', _U('packaging_weed'), 5000, false, true, {
RegisterNetEvent('ps-weedplanting:client:PackDryWeed', function()

local hasItem = QBCore.Functions.HasItem(Shared.WeedItem)

if not hasItem then
QBCore.Functions.Notify(_U('dont_have_enough_dryweed'), 'error', 2500)
return
end

local ped = PlayerPedId()
local table = vector4(1045.4, -3197.62, -38.16, 0.0)

TaskTurnPedToFaceCoord(ped, table, 1000)
Wait(1300)

QBCore.Functions.Progressbar('dryweed', _U('packaging_weed'), 12000, false, true, {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
}, {}, {}, {}, function() -- Done
}, { animDict = "mini@repair", anim = "fixing_a_ped", flags = 8, }, {}, {}, function()
TriggerServerEvent('ps-weedplanting:server:PackageWeed')
end, function() -- Cancel
QBCore.Functions.Notify(_U('canceled'), 'error', 2500)
ClearPedTasks(ped)
end)
end)
116 changes: 59 additions & 57 deletions client/cl_weedrun.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ local createNewDropOff = function()
createDropOffBlip(randomLoc)
dropOffArea = CircleZone:Create(randomLoc.xyz, 85.0, {
name = 'dropOffArea',
debugPoly = true
debugPoly = Shared.Debug
})

dropOffArea:onPlayerInOut(function(isPointInside, point)
Expand Down Expand Up @@ -186,7 +186,7 @@ RegisterNetEvent('ps-weedplanting:client:StartPackage', function(data)

packageZone = CircleZone:Create(Shared.WeedRunStart.xyz, 10.0, {
name = 'weedrunning_start',
debugPoly = false
debugPoly = Shared.Debug
})

packageZone:onPlayerInOut(function(isPointInside, point)
Expand Down Expand Up @@ -241,16 +241,16 @@ RegisterNetEvent('ps-weedplanting:client:DeliverWeed', function()
return
end

local ped = PlayerPedId()
local ped = PlayerPedId()
if not IsPedOnFoot(ped) then return end
if #(GetEntityCoords(ped) - GetEntityCoords(deliveryPed)) < 5.0 then
madeDeal = true
exports['qb-target']:RemoveTargetEntity(deliveryPed)

-- Alert Cops
if math.random(100) <= Shared.CallCopsChance then
if GetResourceState('ps-dispatch') == 'started' then
exports['ps-dispatch']:DrugSale() -- Project-SLoth ps-dispatch
if GetResourceState(Shared.Dispatch) == 'started' then
exports[Shared.Dispatch]:DrugSale() -- Project-SLoth ps-dispatch
end
end

Expand Down Expand Up @@ -299,59 +299,61 @@ RegisterNetEvent('ps-weedplanting:client:DeliverWeed', function()
end
end)

--- Threads

CreateThread(function()
exports['qb-target']:SpawnPed({
model = Shared.PedModel,
coords = Shared.WeedRunStart,
minusOne = true,
freeze = true,
invincible = true,
blockevents = true,
animDict = 'anim@mp_celebration@idles@female',
anim = 'celebration_idle_f_a',
flag = 0,
target = {
options = {
{ -- Create Package
type = 'client',
event = 'ps-weedplanting:client:StartPackage',
icon = 'fas fa-circle-chevron-right',
label = _U('package_goods'),
canInteract = function()
return not waitingForPackage
end
},
{ -- Receive Package
type = 'server',
event = 'ps-weedplanting:server:CollectPackageGoods',
icon = 'fas fa-circle-chevron-right',
label = _U('grab_packaged_goods'),
canInteract = function()
return waitingForPackage
end
},
{ -- Clock In for deliveries
type = 'client',
event = 'ps-weedplanting:client:ClockIn',
icon = 'fas fa-stopwatch',
label = _U('start_delivering'),
canInteract = function()
return not delivering
end
},
{ -- Clock out for deliveries
type = 'client',
event = 'ps-weedplanting:client:ClockOut',
icon = 'fas fa-stopwatch',
label = _U('stop_delivering'),
canInteract = function()
return delivering
end
}
local ped = nil

RequestModel(Shared.PedModel) while not HasModelLoaded(Shared.PedModel) do Wait(0) end
ped = CreatePed(0, Shared.PedModel, vector4(Shared.WeedRunStart.x, Shared.WeedRunStart.y, Shared.WeedRunStart.z - 1, Shared.WeedRunStart.w ), false, false)
SetEntityInvincible(ped, true)
SetBlockingOfNonTemporaryEvents(ped, true)
FreezeEntityPosition(ped, true)
TaskStartScenarioInPlace(ped,"WORLD_HUMAN_DRUG_DEALER", -1, true)

exports['qb-target']:AddBoxZone('weed-run-zone', vector3(Shared.WeedRunStart.x, Shared.WeedRunStart.y, Shared.WeedRunStart.z), 0.8, 0.8, {
name = 'weed-run-zone',
heading = Shared.WeedRunStart.w,
minZ = Shared.WeedRunStart.z - 1,
maxZ = Shared.WeedRunStart.z + 1,
debugPoly = Shared.Debug,
}, {
options = {
{ -- Create Package
type = 'client',
event = 'ps-weedplanting:client:StartPackage',
icon = 'fas fa-circle-chevron-right',
label = _U('package_goods'),
canInteract = function()
return not waitingForPackage
end
},
{ -- Receive Package
type = 'server',
event = 'ps-weedplanting:server:CollectPackageGoods',
icon = 'fas fa-circle-chevron-right',
label = _U('grab_packaged_goods'),
canInteract = function()
return waitingForPackage
end
},
distance = 1.5
}
{ -- Clock In for deliveries
type = 'client',
event = 'ps-weedplanting:client:ClockIn',
icon = 'fas fa-stopwatch',
label = _U('start_delivering'),
canInteract = function()
return not delivering
end
},
{ -- Clock out for deliveries
type = 'client',
event = 'ps-weedplanting:client:ClockOut',
icon = 'fas fa-stopwatch',
label = _U('stop_delivering'),
canInteract = function()
return delivering
end
}
},
distance = 1.5
})
end)
Binary file added images/plant_tub.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/watering_can.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0eff681

Please sign in to comment.