Skip to content

Commit

Permalink
Fixed Exploit and Possible Bypass
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Aug 25, 2023
1 parent d878f39 commit 3a2b42e
Showing 1 changed file with 66 additions and 37 deletions.
103 changes: 66 additions & 37 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@ local playersProcessingCannabis = {}
local outofbound = true
local alive = true

local function ValidatePickupCannabis(src)
local ECoords = Config.CircleZones.WeedField.coords
local PCoords = GetEntityCoords(GetPlayerPed(src))
local Dist = #(PCoords-ECoords)
if Dist <= 90 then return true end
end

local function ValidateProcessCannabis(src)
local ECoords = Config.CircleZones.WeedProcessing.coords
local PCoords = GetEntityCoords(GetPlayerPed(src))
local Dist = #(PCoords-ECoords)
if Dist <= 90 then return true end
end

local function BanPlayer(src,reason)
-- Add Event Here --
DropPlayer(src,reason)
end

RegisterServerEvent('esx_drugs:sellDrug')
AddEventHandler('esx_drugs:sellDrug', function(itemName, amount)
local xPlayer = ESX.GetPlayerFromId(source)
Expand All @@ -13,6 +32,10 @@ AddEventHandler('esx_drugs:sellDrug', function(itemName, amount)
return
end

if amount < 0 then
print(('esx_drugs: %s attempted to sell an minus amount!'):format(xPlayer.identifier))
end

if xItem.count < amount then
xPlayer.showNotification(TranslateCap('dealer_notenough'))
return
Expand Down Expand Up @@ -52,13 +75,17 @@ end)

RegisterServerEvent('esx_drugs:pickedUpCannabis')
AddEventHandler('esx_drugs:pickedUpCannabis', function()
local xPlayer = ESX.GetPlayerFromId(source)
local src = source
local xPlayer = ESX.GetPlayerFromId(src)
local cime = math.random(5,10)

if xPlayer.canCarryItem('cannabis', cime) then
xPlayer.addInventoryItem('cannabis', cime)
if ValidatePickupCannabis(src) then
if xPlayer.canCarryItem('cannabis', cime) then
xPlayer.addInventoryItem('cannabis', cime)
else
xPlayer.showNotification(TranslateCap('weed_inventoryfull'))
end
else
xPlayer.showNotification(TranslateCap('weed_inventoryfull'))
BanPlayer(src,'Event Trigger')
end
end)

Expand All @@ -80,43 +107,45 @@ end)

RegisterServerEvent('esx_drugs:processCannabis')
AddEventHandler('esx_drugs:processCannabis', function()
if not playersProcessingCannabis[source] then
if not playersProcessingCannabis[source] then
local source = source
local xPlayer = ESX.GetPlayerFromId(source)
local xCannabis = xPlayer.getInventoryItem('cannabis')
local can = true
outofbound = false
if xCannabis.count >= 3 then
while outofbound == false and can do
if playersProcessingCannabis[source] == nil then
playersProcessingCannabis[source] = ESX.SetTimeout(Config.Delays.WeedProcessing , function()
if xCannabis.count >= 3 then
if xPlayer.canSwapItem('cannabis', 3, 'marijuana', 1) then
xPlayer.removeInventoryItem('cannabis', 3)
xPlayer.addInventoryItem('marijuana', 1)
xPlayer.showNotification(TranslateCap('weed_processed'))
else
if ValidateProcessCannabis(src) then
local xPlayer = ESX.GetPlayerFromId(source)
local xCannabis = xPlayer.getInventoryItem('cannabis')
local can = true
outofbound = false
if xCannabis.count >= 3 then
while outofbound == false and can do
if playersProcessingCannabis[source] == nil then
playersProcessingCannabis[source] = ESX.SetTimeout(Config.Delays.WeedProcessing , function()
if xCannabis.count >= 3 then
if xPlayer.canSwapItem('cannabis', 3, 'marijuana', 1) then
xPlayer.removeInventoryItem('cannabis', 3)
xPlayer.addInventoryItem('marijuana', 1)
xPlayer.showNotification(TranslateCap('weed_processed'))
else
can = false
xPlayer.showNotification(TranslateCap('weed_processingfull'))
TriggerEvent('esx_drugs:cancelProcessing')
end
else
can = false
xPlayer.showNotification(TranslateCap('weed_processingfull'))
xPlayer.showNotification(TranslateCap('weed_processingenough'))
TriggerEvent('esx_drugs:cancelProcessing')
end
else
can = false
xPlayer.showNotification(TranslateCap('weed_processingenough'))
TriggerEvent('esx_drugs:cancelProcessing')
end

playersProcessingCannabis[source] = nil
end)
else
Wait(Config.Delays.WeedProcessing)
end
end
playersProcessingCannabis[source] = nil
end)
else
Wait(Config.Delays.WeedProcessing)
end
end
else
xPlayer.showNotification(TranslateCap('weed_processingenough'))
TriggerEvent('esx_drugs:cancelProcessing')
end
else
xPlayer.showNotification(TranslateCap('weed_processingenough'))
TriggerEvent('esx_drugs:cancelProcessing')
end

BanPlayer(source,'Event Trigger')
end
else
print(('esx_drugs: %s attempted to exploit weed processing!'):format(GetPlayerIdentifiers(source)[1]))
end
Expand Down

0 comments on commit 3a2b42e

Please sign in to comment.