From 02ca13bcbd7bc2046cfe7bde50f3b21e577c7025 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Mon, 8 Sep 2025 18:08:17 +0100 Subject: [PATCH] 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 --- shared/_authToken.lua | 4 +-- shared/itemcontrol.lua | 76 +++++++++++++++++++++--------------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/shared/_authToken.lua b/shared/_authToken.lua index 3104d2e..d114746 100644 --- a/shared/_authToken.lua +++ b/shared/_authToken.lua @@ -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 diff --git a/shared/itemcontrol.lua b/shared/itemcontrol.lua index 15e9dd1..c56cd55 100644 --- a/shared/itemcontrol.lua +++ b/shared/itemcontrol.lua @@ -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]