Fix stash dist exploit checker

This commit is contained in:
Jim Shield
2025-09-13 02:50:31 +01:00
parent 420e035e2b
commit 807cfe1a2a
2 changed files with 18 additions and 12 deletions

View File

@@ -1,6 +1,8 @@
------------------------------------------------------------- -------------------------------------------------------------
-- Exploit Auth System -- Exploit Auth System
------------------------------------------------------------- -------------------------------------------------------------
forceDisableExplotProtection = false -- dangerous, this allows exploits
AuthEvent = nil AuthEvent = nil
currentToken = nil currentToken = nil
if isServer() then if isServer() then
@@ -81,6 +83,8 @@ if isServer() then
-- Multiuse function to check if the generated client token is valid -- Multiuse function to check if the generated client token is valid
function checkToken(src, token, genType, name) function checkToken(src, token, genType, name)
if forceDisableExplotProtection == true then return true end
if token == nil then if token == nil then
debugPrint("^1Auth^7: ^1No token recieved^7") debugPrint("^1Auth^7: ^1No token recieved^7")
if genType == "stash" then if genType == "stash" then
@@ -119,6 +123,7 @@ else
end end
function distExploitCheck(table, src) function distExploitCheck(table, src)
if forceDisableExplotProtection == true then return true end
if not table then if not table then
print("^1Error^7: ^1This wasn^7'^1t reigstered correctly or this is an exploit attempt^1") print("^1Error^7: ^1This wasn^7'^1t reigstered correctly or this is an exploit attempt^1")
@@ -130,7 +135,7 @@ function distExploitCheck(table, src)
local allow = false local allow = false
for i = 1, #table do for i = 1, #table do
if #(table[i] - srcCoords) <= 10 then if #(table[i].xyz - srcCoords) <= 10 then
return true return true
else else
allow = false allow = false

View File

@@ -1670,7 +1670,6 @@ end
--- ```lua --- ```lua
--- useToolDegrade({ item = "drill", maxUse = 10 }) --- useToolDegrade({ item = "drill", maxUse = 10 })
--- ``` --- ```
function useToolDegrade(data) -- WIP function useToolDegrade(data) -- WIP
local metadata, slot = getItemMetadata(data.item) local metadata, slot = getItemMetadata(data.item)
metadata = metadata or {} metadata = metadata or {}
@@ -1752,7 +1751,7 @@ end)
--- ```lua --- ```lua
--- getRandomReward("gold_ring") --- getRandomReward("gold_ring")
--- ``` --- ```
function getRandomReward(itemName) function getRandomReward(itemName, src)
if Config.Rewards.RewardPool then if Config.Rewards.RewardPool then
local reward = false local reward = false
if type(Config.Rewards.RewardItem) == "string" then if type(Config.Rewards.RewardItem) == "string" then
@@ -1765,7 +1764,6 @@ function getRandomReward(itemName)
end end
end end
if reward then if reward then
removeItem(itemName, 1)
local totalRarity = 0 local totalRarity = 0
for i = 1, #Config.Rewards.RewardPool do for i = 1, #Config.Rewards.RewardPool do
totalRarity += Config.Rewards.RewardPool[i].rarity totalRarity += Config.Rewards.RewardPool[i].rarity
@@ -1778,7 +1776,7 @@ function getRandomReward(itemName)
currentRarity += Config.Rewards.RewardPool[i].rarity currentRarity += Config.Rewards.RewardPool[i].rarity
if randomNum <= currentRarity then if randomNum <= currentRarity then
debugPrint("^6Bridge^7: ^3getRandomReward^7: ^2Selected toy ^7'^6"..Config.Rewards.RewardPool[i].item.."^7'") debugPrint("^6Bridge^7: ^3getRandomReward^7: ^2Selected toy ^7'^6"..Config.Rewards.RewardPool[i].item.."^7'")
addItem(Config.Rewards.RewardPool[i].item, 1) addItem(Config.Rewards.RewardPool[i].item, 1, nil, src)
return return
end end
end end
@@ -2106,7 +2104,10 @@ end
function openStash(data) function openStash(data)
if (data.job or data.gang) and not jobCheck(data.job or data.gang) then return end if (data.job or data.gang) and not jobCheck(data.job or data.gang) then return end
local exploitCheck = triggerCallback(getScript()..":getRegisteredStashLocations", data.stash) local p = promise.new()
p:resolve(triggerCallback(getScript()..":getRegisteredStashLocations", data.stash))
local exploitCheck = Citizen.Await(p)
if not exploitCheck then if not exploitCheck then
print("^3Warning^7: ^2This isn't a registered stash^1, refusing call^7") print("^3Warning^7: ^2This isn't a registered stash^1, refusing call^7")
return return
@@ -2350,6 +2351,12 @@ end
--- ) --- )
--- ``` --- ```
function registerStash(name, label, slots, weight, owner, coords) function registerStash(name, label, slots, weight, owner, coords)
if coords then
stashExploitCheck[name] = stashExploitCheck[name] or {}
stashExploitCheck[name][#stashExploitCheck[name]+1] = coords
else
print("^3Warning^7: ^1Stash ^4"..name.." ^1doesn^7'^1t have coords^7, ^1this is exploitable^7, ^1add coords to ^3regiterStash^7()")
end
for i = 1, #InvFunc do for i = 1, #InvFunc do
local inv = InvFunc[i] local inv = InvFunc[i]
if isStarted(inv.invName) then if isStarted(inv.invName) then
@@ -2357,12 +2364,6 @@ function registerStash(name, label, slots, weight, owner, coords)
return return
end end
end end
if coords then
stashExploitCheck[name] = stashExploitCheck[name] or {}
stashExploitCheck[name][#stashExploitCheck[name]+1] = coords
else
print("^3Warning^7: ^1Stash ^4"..name.." ^1doesn^7'^1t have coords^7, ^1this is exploitable^7, ^1add coords to ^3regiterStash^7()")
end
end end
if isServer() then if isServer() then