Put distance exploit checks in place

This is a continuation from an earlier commit

- If something is attempted to be opened without correctly registered coordinates, (most likely being called outside the script), refuse it
- If the player isn't close enough to the registered coords, refuse it

Basically, built-in distance based exploit protection for shops/stashes/sellShops
This commit is contained in:
Jim Shield
2025-09-08 18:08:17 +01:00
parent 833bc675ce
commit 02ca13bcbd
2 changed files with 40 additions and 40 deletions

View File

@@ -121,7 +121,7 @@ end
function distExploitCheck(table, src)
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")
return false
end
@@ -138,7 +138,7 @@ function distExploitCheck(table, src)
end
if not allow then
debugPrint(src and ("^1Src ^3"..src.." ").."^1Tried to open a registered shop/stash from over the distance limit^7")
print(src and ("^1Src ^3"..src.." ").."^1Tried to open a registered shop/stash from over the distance limit^7")
return false
end

View File

@@ -2106,14 +2106,14 @@ end
function openStash(data)
if (data.job or data.gang) and not jobCheck(data.job or data.gang) then return end
--local exploitCheck = triggerCallback(getScript()..":getRegisteredStashLocations", data.stash)
--if not exploitCheck then
-- print("^3Warning^7: ^2This isn't a registered stash^1, refusing call^7")
-- return
--end
--if not distExploitCheck(exploitCheck) then
-- return
--end
local exploitCheck = triggerCallback(getScript()..":getRegisteredStashLocations", data.stash)
if not exploitCheck then
print("^3Warning^7: ^2This isn't a registered stash^1, refusing call^7")
return
end
if not distExploitCheck(exploitCheck) then
return
end
for i = 1, #InvFunc do
local inv = InvFunc[i]
@@ -2140,13 +2140,13 @@ end
RegisterNetEvent(getScript()..":server:openServerStash", function(data)
local src = source
--if not stashExploitCheck[data.stashName] then
-- print("^3Warning^7: ^1Source^7: ^3"..src.." ^1Tried to open a shop^7: ^2This isn't a registered stash^1, refusing call^7")
-- return
--end
--if not distExploitCheck(stashExploitCheck[data.stashName]) then
-- return
--end
if not stashExploitCheck[data.stashName] then
print("^3Warning^7: ^1Source^7: ^3"..src.." ^1Tried to open a shop^7: ^2This isn't a registered stash^1, refusing call^7")
return
end
if not distExploitCheck(stashExploitCheck[data.stashName], src) then
return
end
if isStarted(TgiannInv) then
exports[TgiannInv]:OpenInventory(source, 'stash', data.stashName, data)
@@ -2442,14 +2442,14 @@ end
function sellMenu(data)
local origData = data
--local exploitCheck = triggerCallback(getScript()..":getRegisteredSellShopLocation", data.name)
--if not exploitCheck then
-- print("^3Warning^7: ^2This isn't a registered store^1, refusing call^7")
-- return
--end
--if not distExploitCheck(exploitCheck) then
-- return
--end
local exploitCheck = triggerCallback(getScript()..":getRegisteredSellShopLocation", data.name)
if not exploitCheck then
print("^3Warning^7: ^2This isn't a registered store^1, refusing call^7")
return
end
if not distExploitCheck(exploitCheck) then
return
end
local Menu = {}
if data.sellTable.Items then
@@ -2628,14 +2628,14 @@ function openShop(data)
if (data.job or data.gang) and not jobCheck(data.job or data.gang) then return end
-- If shop has registered coords, limit players from being too far away from it when opening
--local exploitCheck = triggerCallback(getScript()..":getRegisteredShopLocation", data.shop)
--if not exploitCheck then
-- print("^3Warning^7: ^2This isn't a registered store^1, refusing call^7")
-- return
--end
--if not distExploitCheck(exploitCheck) then
-- return
--end
local exploitCheck = triggerCallback(getScript()..":getRegisteredShopLocation", data.shop)
if not exploitCheck then
print("^3Warning^7: ^2This isn't a registered store^1, refusing call^7")
return
end
if not distExploitCheck(exploitCheck) then
return
end
if Config.General.JimShops then
TriggerServerEvent("jim-shops:ShopOpen", "shop", data.items.label, data.items)
@@ -2658,13 +2658,13 @@ RegisterNetEvent(getScript()..':server:openServerShop', function(shopName)
local src = source
-- If shop has registered coords, limit players from being too far away from it when opening
--if not shopExploitCheck[data.shop] then
-- print("^3Warning^7: ^1Source^7: ^3"..src.." ^1Tried to open a shop^7: ^2This isn't a registered store^1, refusing call^7")
-- return
--end
--if not distExploitCheck(shopExploitCheck[data.shop]) then
-- return
--end
if not shopExploitCheck[shopName] then
print("^3Warning^7: ^1Source^7: ^3"..src.." ^1Tried to open a shop^7: ^2This isn't a registered store^1, refusing call^7")
return
end
if not distExploitCheck(shopExploitCheck[shopName], src) then
return
end
for i = 1, #InvFunc do
local inv = InvFunc[i]