-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #808 from bitpredator/dev
refactor: reconstruction of the drug system
- Loading branch information
Showing
35 changed files
with
573 additions
and
1,963 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+16.5 KB
server-data/resources/[bpt_addons]/bpt_crafting/html/img/cannabis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
BIN
+62.9 KB
server-data/resources/[bpt_addons]/bpt_crafting/html/img/diamond_tip.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
BIN
+33.2 KB
server-data/resources/[bpt_addons]/bpt_crafting/html/img/marijuana.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<h1 align='center'>bpt_drugs</a></h1> | ||
<p align='center'><a href='https://discord.gg/ksGfNvDEfq'>Discord</a> | ||
|
||
Copyright (C) 2024 bitpredator | ||
|
||
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. | ||
|
||
ATTENTION: | ||
You are not authorized to change the name of the resource and the resources within it. | ||
|
||
If you want to contribute you can open a pull request. | ||
|
||
You are not authorized to sell this software (this is free project). | ||
|
||
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 http://www.gnu.org/licenses/. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES | ||
('cannabis', 'Cannabis', 3, 0, 1), | ||
('marijuana', 'Marijuana', 2, 0, 1) | ||
; |
136 changes: 136 additions & 0 deletions
136
server-data/resources/[bpt_addons]/bpt_drugs/client/main.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
local menuOpen = false | ||
local inZoneDrugShop = false | ||
local inRangeMarkerDrugShop = false | ||
local cfgMarker = Config.Marker | ||
|
||
--slow loop | ||
CreateThread(function() | ||
while true do | ||
local playerPed = PlayerPedId() | ||
local coords = GetEntityCoords(playerPed) | ||
local distDrugShop = #(coords - Config.CircleZones.DrugDealer.coords) | ||
|
||
inRangeMarkerDrugShop = false | ||
if distDrugShop <= Config.Marker.Distance then | ||
inRangeMarkerDrugShop = true | ||
end | ||
|
||
if distDrugShop < 1 then | ||
inZoneDrugShop = true | ||
else | ||
inZoneDrugShop = false | ||
if menuOpen then | ||
menuOpen = false | ||
end | ||
end | ||
|
||
Wait(500) | ||
end | ||
end) | ||
|
||
--drawk marker | ||
CreateThread(function() | ||
while true do | ||
local Sleep = 1500 | ||
if inRangeMarkerDrugShop then | ||
Sleep = 0 | ||
local coordsMarker = Config.CircleZones.DrugDealer.coords | ||
local color = cfgMarker.Color | ||
DrawMarker(cfgMarker.Type, coordsMarker.x, coordsMarker.y, coordsMarker.z - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, cfgMarker.Size, color.r, color.g, color.b, color.a, false, true, 2, false, nil, nil, false) | ||
end | ||
Wait(Sleep) | ||
end | ||
end) | ||
|
||
--main loop | ||
CreateThread(function() | ||
while true do | ||
local Sleep = 1500 | ||
if inZoneDrugShop and not menuOpen then | ||
Sleep = 0 | ||
ESX.ShowHelpNotification(TranslateCap("dealer_prompt"), true) | ||
if IsControlJustPressed(0, 38) then | ||
OpenDrugShop() | ||
end | ||
end | ||
Wait(Sleep) | ||
end | ||
end) | ||
|
||
function OpenDrugShop() | ||
local elements = { | ||
{ unselectable = true, icon = "fas fa-cannabis", title = TranslateCap("dealer_title") }, | ||
} | ||
menuOpen = true | ||
|
||
for _, v in pairs(ESX.GetPlayerData().inventory) do | ||
local price = Config.DrugDealerItems[v.name] | ||
|
||
if price and v.count > 0 then | ||
elements[#elements + 1] = { | ||
icon = "fas fa-shopping-basket", | ||
title = ('%s - <span style="color:green;">%s</span>'):format(v.label, TranslateCap("dealer_item", ESX.Math.GroupDigits(price))), | ||
name = v.name, | ||
price = price, | ||
} | ||
end | ||
end | ||
|
||
ESX.OpenContext("right", elements, function(menu, element) | ||
local elements2 = { | ||
{ unselectable = true, icon = "fas fa-shopping-basket", title = element.title }, | ||
{ icon = "fas fa-shopping-basket", title = "Amount", input = true, inputType = "number", inputPlaceholder = "Amount you want to sell", inputValue = 0, inputMin = Config.SellMenu.Min, inputMax = Config.SellMenu.Max }, | ||
{ icon = "fas fa-check-double", title = "Confirm", val = "confirm" }, | ||
} | ||
|
||
ESX.OpenContext("right", elements2, function(menu2, element2) | ||
ESX.CloseContext() | ||
local count = tonumber(menu2.eles[2].inputValue) | ||
|
||
if count < 1 then | ||
return | ||
end | ||
|
||
TriggerServerEvent("bpt_drugs:sellDrug", tostring(element.name), count) | ||
end, function() | ||
menuOpen = false | ||
end) | ||
end, function(menu) | ||
menuOpen = false | ||
end) | ||
end | ||
|
||
AddEventHandler("onResourceStop", function(resource) | ||
if resource == GetCurrentResourceName() then | ||
if menuOpen then | ||
ESX.CloseContext() | ||
end | ||
end | ||
end) | ||
|
||
function CreateBlipCircle(coords, text, radius, color, sprite) | ||
local blip = AddBlipForRadius(coords, radius) | ||
|
||
SetBlipHighDetail(blip, true) | ||
SetBlipColour(blip, 1) | ||
SetBlipAlpha(blip, 128) | ||
|
||
-- create a blip in the middle | ||
blip = AddBlipForCoord(coords) | ||
|
||
SetBlipHighDetail(blip, true) | ||
SetBlipSprite(blip, sprite) | ||
SetBlipScale(blip, 1.0) | ||
SetBlipColour(blip, color) | ||
SetBlipAsShortRange(blip, true) | ||
|
||
BeginTextCommandSetBlipName("STRING") | ||
AddTextComponentSubstringPlayerName(text) | ||
EndTextCommandSetBlipName(blip) | ||
end | ||
|
||
CreateThread(function() | ||
for _, zone in pairs(Config.CircleZones) do | ||
CreateBlipCircle(zone.coords, zone.name, zone.radius, zone.color, zone.sprite) | ||
end | ||
end) |
Oops, something went wrong.