├── .gitignore ├── LICENSE ├── README.md ├── SecureServe ├── bans.json ├── config.lua ├── fxmanifest.lua ├── secureserve.key └── src │ ├── client │ ├── blacklists │ │ ├── blacklisted_commands.lua │ │ ├── blacklisted_sprites.lua │ │ └── blacklisted_weapons.lua │ ├── core │ │ ├── blue_screen.lua │ │ ├── cache.lua │ │ ├── client_logger.lua │ │ ├── config_loader.lua │ │ └── entity_monitor.lua │ ├── init.lua │ ├── main.lua │ └── protections │ │ ├── anti_afk_injection.lua │ │ ├── anti_ai.lua │ │ ├── anti_aim_assist.lua │ │ ├── anti_bigger_hitbox.lua │ │ ├── anti_entity_security.lua │ │ ├── anti_explosion_bullet.lua │ │ ├── anti_freecam.lua │ │ ├── anti_give_weapon.lua │ │ ├── anti_god_mode.lua │ │ ├── anti_infinite_stamina.lua │ │ ├── anti_invisible.lua │ │ ├── anti_load_resource_file.lua │ │ ├── anti_magic_bullet.lua │ │ ├── anti_no_ragdoll.lua │ │ ├── anti_no_recoil.lua │ │ ├── anti_no_reload.lua │ │ ├── anti_noclip.lua │ │ ├── anti_ocr.lua │ │ ├── anti_player_blips.lua │ │ ├── anti_resource_stop.lua │ │ ├── anti_spectate.lua │ │ ├── anti_speed_hack.lua │ │ ├── anti_state_bag_overflow.lua │ │ ├── anti_super_jump.lua │ │ ├── anti_teleport.lua │ │ ├── anti_visions.lua │ │ ├── anti_weapon_damage_modifier.lua │ │ ├── anti_weapon_pickup.lua │ │ ├── index.html │ │ └── protection_manager.lua │ ├── main.lua │ ├── module │ ├── module.js │ └── module.lua │ ├── server │ ├── core │ │ ├── admin_whitelist.lua │ │ ├── auto_config.lua │ │ ├── ban_manager.lua │ │ ├── config_manager.lua │ │ ├── debug_module.lua │ │ ├── discord_logger.lua │ │ ├── install.js │ │ ├── logger.lua │ │ └── player_manager.lua │ ├── main.lua │ └── protections │ │ ├── anti_create_entity.lua │ │ ├── anti_entity_spam.lua │ │ ├── anti_execution.lua │ │ ├── anti_explosions.lua │ │ ├── anti_explosive_damage.lua │ │ ├── anti_particle_effects.lua │ │ ├── anti_resource_injection.lua │ │ ├── anti_server_cfg_options.lua │ │ ├── anti_weapon_damage_modifier.lua │ │ ├── heartbeat.lua │ │ └── resource_manager.lua │ └── shared │ ├── init.lua │ └── lib │ ├── callbacks.lua │ ├── encryption.lua │ ├── require.lua │ └── utils.lua └── keep-alive ├── client.lua └── fxmanifest.lua /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Lua sources 2 | luac.out 3 | 4 | # luarocks build files 5 | *.src.rock 6 | *.zip 7 | *.tar.gz 8 | 9 | # Object files 10 | *.o 11 | *.os 12 | *.ko 13 | *.obj 14 | *.elf 15 | 16 | # Precompiled Headers 17 | *.gch 18 | *.pch 19 | 20 | # Libraries 21 | *.lib 22 | *.a 23 | *.la 24 | *.lo 25 | *.def 26 | *.exp 27 | 28 | # Shared objects (inc. Windows DLLs) 29 | *.dll 30 | *.so 31 | *.so.* 32 | *.dylib 33 | 34 | # Executables 35 | *.exe 36 | *.out 37 | *.app 38 | *.i*86 39 | *.x86_64 40 | *.hex 41 | 42 | .vscode/ 43 | SecureServe-AC.rar 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## New Update | Soon 2 | # SecureServe - Free & Open Source Fivem Anti-Cheat 3 | 4 | - **Discord:** [Join Our Server](https://discord.gg/z6qGGtbcr4) for live support and updates. 5 | - **Docs:** [SecureServe Documentation](https://peleg.gitbook.io/secureserve/) 6 | - **Support the anticheat for future updates:** [KOFI](https://ko-fi.com/peleg) 7 | - **Please use the release beta or v versions only unless u want to the test latest version (might be bugged)!** 8 | 9 | SecureServe is a state-of-the-art anti-cheat solution designed specifically for FiveM servers. Combining advanced detection techniques with comprehensive server protection, it ensures a fair and secure gaming environment. This open-source script is completely free to use, modify, and extend. 10 | 11 | --- 12 | 13 | ## 🚀 **Getting Started** 14 | 15 | ### Step-by-Step Installation 16 | 1. **Encountering Ban Messages:** During the initial setup, you may see the following ban reason: 17 | > *"A player has been banned for Trigger Event with an executor (name of the event)"* 18 | 2. **How to Fix It:** 19 | - Open the configuration file. 20 | - Identify the event name causing the issue. 21 | - Add the event name to the **whitelisted events list** in the config. 22 | 3. **Still Have Issues?** 23 | - Read our docs: [SecureServe Documentation](https://peleg.gitbook.io/secureserve/) 24 | - Join our [Discord](https://discord.gg/z6qGGtbcr4) and open a ticket for personalized support. 25 | 26 | --- 27 | 28 | ## 🛡️ **Core Features** 29 | 30 | ### Advanced Entity Detections 31 | - **Unauthorized Entity Blocking:** Prevents cheats from spawning illegitimate entities. 32 | - **Trigger Event Monitoring:** Automatically detects and prevents unauthorized triggers. 33 | - **Suspicious Resource Scanning:** Identifies and flags unauthorized resources. 34 | - **Internal Executor Protection:** Detects hidden executor exploits. 35 | - **Audio Manipulation Defense:** Stops unauthorized sound exploits. 36 | - **Entity Control Safeguard:** Secures entities from control hijacking. 37 | - **Enhanced Player Safety:** Ensures players are shielded from typical exploits. 38 | 39 | ### Intelligent Client-Side Protections 40 | - **Menu and Cheat Detection:** Flags unauthorized cheat menus. 41 | - **Noclip & Freecam Defense:** Prevents players from abusing these features. 42 | - **Godmode Prevention:** Detects invincibility cheats. 43 | - **Weapon Exploit Detection:** Identifies rapid-fire and recoil cheats. 44 | - **AI Modification Alerts:** Flags altered AI files used for exploits. 45 | 46 | ### Comprehensive Server-Side Monitoring 47 | - **Weapon and Particle Oversight:** Tracks unauthorized items and particle effects. 48 | - **Explosion Management:** Detects and blocks unauthorized explosions. 49 | - **Resource Security:** Stops unauthorized attempts to halt server resources. 50 | 51 | --- 52 | 53 | ## 📥 **Installation Guide** 54 | 55 | 1. **Set Up Logging Webhooks:** Enable webhook logs for monitoring actions. 56 | 2. **Adjust Whitelisted Events:** Update the config file with events causing false positives. 57 | 3. **Explosion Threshold Tuning:** Set minimum and maximum values for explosion detections tailored to your server. 58 | 59 | **Sample Ban Export Command:** 60 | ```lua 61 | exports['SecureServe']:banPlayer(source, 'Detected Cheat Activity') 62 | ``` 63 | 64 | --- 65 | 66 | ## 🌐 **Upcoming Enhancements** 67 | - **Anti Internal Module:** Returning soon with optimized performance. 68 | - **Standalone Admin Panel:** Features added for ESX, QBCore, and standalone frameworks. 69 | 70 | --- 71 | 72 | ## 🤝 **Contributing to SecureServe** 73 | We value contributions! If you encounter issues, have suggestions, or want to contribute code, submit a pull request or report issues on our GitHub. 74 | 75 | --- 76 | 77 | ## 🎥 **Screenshots & Video Previews** 78 | 79 | # **Admin Panel (Ingame Panel)** 80 |  81 |  82 |  83 |  84 |  85 |  86 | 87 | # **Detections** 88 |  89 |  90 |  91 |  92 |  93 |  94 |  95 | 96 | ### Video Previews 97 | - **[Watch Preview 1](https://www.youtube.com/watch?v=xgFFfGNQehk)** 98 | - **[Watch Preview 2](https://youtu.be/BfSHgVtE3eE)** 99 | 100 | --- 101 | 102 | ## 🏷️ **License** 103 | SecureServe is licensed under the [GNU Affero General Public License v3.0](https://www.gnu.org/licenses/agpl-3.0.en.html). You are free to use, modify, and share it under the terms of this license. 104 | 105 | --- 106 | 107 | ## 📞 **Contact & Support** 108 | - **Join Us on Discord:** [Get Help Here](https://discord.gg/z6qGGtbcr4) 109 | 110 | --- 111 | 112 | ## 📚 **Documentation** 113 | Access our detailed documentation for installation, configuration, and troubleshooting guides: 114 | - **GitBook:** [SecureServe Documentation](https://peleg.gitbook.io/secureserve/) 115 | 116 | **Experience unmatched security with SecureServe, the professional-grade anti-cheat solution for FiveM servers.** 117 | -------------------------------------------------------------------------------- /SecureServe/bans.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /SecureServe/fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version "cerulean" 2 | game "gta5" 3 | 4 | author "SecureServe.net" 5 | version "1.2.1" 6 | 7 | files { 8 | "bans.json", 9 | "src/client/protections/index.html", 10 | "secureserve.key" 11 | } 12 | 13 | ui_page "src/client/protections/index.html" 14 | 15 | shared_scripts { 16 | "src/module/module.lua", 17 | "src/module/module.js", 18 | "src/shared/lib/require.lua", 19 | "src/shared/lib/encryption.lua", 20 | "src/shared/lib/utils.lua", 21 | "src/shared/lib/callbacks.lua", 22 | "src/shared/init.lua", 23 | } 24 | 25 | client_scripts { 26 | "src/client/init.lua", 27 | "src/client/core/config_loader.lua", 28 | "src/client/core/cache.lua", 29 | "src/client/core/entity_monitor.lua", 30 | "src/client/core/client_logger.lua", 31 | "src/client/core/blue_screen.lua", 32 | "src/client/protections/protection_manager.lua", 33 | "src/client/protections/anti_load_resource_file.lua", 34 | "src/client/protections/anti_invisible.lua", 35 | "src/client/protections/anti_no_reload.lua", 36 | "src/client/protections/anti_explosion_bullet.lua", 37 | "src/client/protections/anti_entity_security.lua", 38 | "src/client/protections/anti_magic_bullet.lua", 39 | "src/client/protections/anti_aim_assist.lua", 40 | "src/client/protections/anti_noclip.lua", 41 | "src/client/protections/anti_resource_stop.lua", 42 | "src/client/protections/anti_god_mode.lua", 43 | "src/client/protections/anti_spectate.lua", 44 | "src/client/protections/anti_give_weapon.lua", 45 | "src/client/protections/anti_freecam.lua", 46 | "src/client/protections/anti_teleport.lua", 47 | "src/client/protections/anti_weapon_damage_modifier.lua", 48 | "src/client/protections/anti_ocr.lua", 49 | "src/client/protections/anti_player_blips.lua", 50 | "src/client/protections/anti_speed_hack.lua", 51 | "src/client/protections/anti_state_bag_overflow.lua", 52 | "src/client/protections/anti_afk_injection.lua", 53 | "src/client/protections/anti_ai.lua", 54 | "src/client/protections/anti_bigger_hitbox.lua", 55 | "src/client/protections/anti_no_recoil.lua", 56 | "src/client/protections/anti_visions.lua", 57 | "src/client/protections/anti_weapon_pickup.lua", 58 | "src/client/main.lua" 59 | } 60 | server_scripts { 61 | "config.lua", 62 | "src/server/main.lua", 63 | "src/server/core/config_manager.lua", 64 | "src/server/core/ban_manager.lua", 65 | "src/server/core/player_manager.lua", 66 | "src/server/core/logger.lua", 67 | "src/server/core/debug_module.lua", 68 | "src/server/core/auto_config.lua", 69 | "src/server/core/discord_logger.lua", 70 | "src/server/core/admin_whitelist.lua", 71 | "src/server/protections/resource_manager.lua", 72 | "src/server/protections/anti_execution.lua", 73 | "src/server/protections/anti_entity_spam.lua", 74 | "src/server/protections/anti_resource_injection.lua", 75 | "src/server/protections/anti_weapon_damage_modifier.lua", 76 | "src/server/protections/anti_explosions.lua", 77 | "src/server/protections/anti_particle_effects.lua", 78 | "src/server/protections/heartbeat.lua", 79 | "src/server/core/install.js" 80 | } 81 | 82 | dependencies { 83 | "/server:5181", 84 | "screenshot-basic", 85 | "keep-alive" 86 | } 87 | 88 | lua54 "yes" 89 | 90 | exports { 91 | "get_event_whitelist", 92 | "add_event_handler", 93 | "register_net_event" 94 | } 95 | 96 | server_exports { 97 | "banPlayer", 98 | "get_logger", 99 | "get_debug_module", 100 | "get_auto_config", 101 | "whitelist_event", 102 | "validate_event", 103 | "module_punish", 104 | "SecureLog" 105 | } -------------------------------------------------------------------------------- /SecureServe/secureserve.key: -------------------------------------------------------------------------------- 1 | dont-touch-this-will-auto-update-next-restart -------------------------------------------------------------------------------- /SecureServe/src/client/blacklists/blacklisted_commands.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | 3 | ---@class BlacklistedCommandsModule 4 | local BlacklistedCommands = {} 5 | 6 | ---@description Initialize Blacklisted Commands check 7 | function BlacklistedCommands.initialize() 8 | Citizen.CreateThread(function() 9 | while true do 10 | local registered_commands = GetRegisteredCommands() 11 | for _, k in pairs(SecureServe.Protection.BlacklistedCommands) do 12 | for _, v in pairs(registered_commands) do 13 | if k.command == v.name then 14 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Blacklisted Command (" .. k.command .. ")", k.webhook, k.time) 15 | end 16 | end 17 | end 18 | 19 | Citizen.Wait(7600) 20 | end 21 | end) 22 | end 23 | 24 | ProtectionManager.register_protection("blacklisted_commands", BlacklistedCommands.initialize) 25 | 26 | return BlacklistedCommands -------------------------------------------------------------------------------- /SecureServe/src/client/blacklists/blacklisted_sprites.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | 3 | ---@class BlacklistedSpritesModule 4 | local BlacklistedSprites = {} 5 | 6 | ---@description Initialize Blacklisted Sprites check 7 | function BlacklistedSprites.initialize() 8 | Citizen.CreateThread(function() 9 | while true do 10 | for k, v in pairs(SecureServe.Protection.BlacklistedSprites) do 11 | if HasStreamedTextureDictLoaded(v.sprite) then 12 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Blacklisted Sprite (" .. v.name .. ")", v.webhook, v.time) 13 | end 14 | end 15 | 16 | Citizen.Wait(5700) 17 | end 18 | end) 19 | end 20 | 21 | ProtectionManager.register_protection("blacklisted_sprites", BlacklistedSprites.initialize) 22 | 23 | return BlacklistedSprites -------------------------------------------------------------------------------- /SecureServe/src/client/blacklists/blacklisted_weapons.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local Cache = require("client/core/cache") 3 | 4 | ---@class BlacklistedWeaponsModule 5 | local BlacklistedWeapons = {} 6 | 7 | ---@description Initialize Blacklisted Weapons check 8 | function BlacklistedWeapons.initialize() 9 | Citizen.CreateThread(function() 10 | while true do 11 | Citizen.Wait(4000) 12 | 13 | local player = Cache.Get("ped") 14 | local weapon = Cache.Get("selectedWeapon") 15 | 16 | for k, v in pairs(SecureServe.Protection.BlacklistedWeapons) do 17 | if weapon == GetHashKey(v.name) then 18 | RemoveWeaponFromPed(player, weapon) 19 | end 20 | end 21 | end 22 | end) 23 | end 24 | 25 | ProtectionManager.register_protection("blacklisted_weapons", BlacklistedWeapons.initialize) 26 | 27 | return BlacklistedWeapons -------------------------------------------------------------------------------- /SecureServe/src/client/core/blue_screen.lua: -------------------------------------------------------------------------------- 1 | ---@class BlueScreenModule 2 | local BlueScreen = {} 3 | local bluescreenActive = false 4 | 5 | ---@description Initialize the blue screen module 6 | function BlueScreen.initialize() 7 | local bluescreenActive = false 8 | 9 | RegisterNetEvent("SecureServe:ShowWindowsBluescreen", function() 10 | if bluescreenActive then return end 11 | bluescreenActive = true 12 | 13 | local soundId = GetSoundId() 14 | PlaySoundFrontend(soundId, "Bed", "WastedSounds", true) 15 | 16 | local stopCodes = { 17 | "SYSTEM_SERVICE_EXCEPTION", 18 | "CRITICAL_PROCESS_DIED", 19 | "PAGE_FAULT_IN_NONPAGED_AREA", 20 | "MEMORY_MANAGEMENT", 21 | "UNEXPECTED_KERNEL_MODE_TRAP", 22 | "DPC_WATCHDOG_VIOLATION", 23 | "IRQL_NOT_LESS_OR_EQUAL", 24 | "KERNEL_SECURITY_CHECK_FAILURE", 25 | "SYSTEM_THREAD_EXCEPTION_NOT_HANDLED", 26 | "UNEXPECTED_STORE_EXCEPTION", 27 | "DRIVER_POWER_STATE_FAILURE", 28 | "KMODE_EXCEPTION_NOT_HANDLED" 29 | } 30 | 31 | local cheatingErrorCodes = { 32 | "SECURE_SERV_ANTICHEAT_VIOLATION", 33 | "MEMORY_INTEGRITY_FAILURE", 34 | "CHEAT_ENGINE_DETECTED", 35 | "MEMORY_INJECTION_DETECTED", 36 | "INVALID_GAME_MODIFICATION", 37 | "PROCESS_TAMPERING_DETECTED" 38 | } 39 | 40 | local stopCode = math.random() > 0.4 41 | and cheatingErrorCodes[math.random(1, #cheatingErrorCodes)] 42 | or stopCodes[math.random(1, #stopCodes)] 43 | 44 | local randomErr = string.format("0x%08X", math.random(0, 4294967295)) 45 | 46 | local percent = 0 47 | local lastUpdate = GetGameTimer() 48 | 49 | Citizen.CreateThread(function() 50 | SetNuiFocus(true, true) 51 | 52 | while bluescreenActive do 53 | DisableAllControlActions(0) 54 | 55 | DrawRect(0.5, 0.5, 1.0, 1.0, 0, 120, 212, 255) 56 | 57 | SetTextFont(4) 58 | SetTextScale(1.8, 1.8) 59 | SetTextColour(255, 255, 255, 255) 60 | SetTextCentre(true) 61 | SetTextDropShadow(0, 0, 0, 0, 255) 62 | SetTextEdge(0, 0, 0, 0, 0) 63 | BeginTextCommandDisplayText("STRING") 64 | AddTextComponentSubstringPlayerName(":(") 65 | EndTextCommandDisplayText(0.5, 0.22) 66 | 67 | SetTextFont(4) 68 | SetTextScale(0.65, 0.65) 69 | SetTextColour(255, 255, 255, 255) 70 | SetTextCentre(true) 71 | SetTextDropShadow(0, 0, 0, 0, 255) 72 | BeginTextCommandDisplayText("STRING") 73 | AddTextComponentSubstringPlayerName("Your PC ran into a problem and needs to restart.") 74 | EndTextCommandDisplayText(0.5, 0.33) 75 | 76 | SetTextFont(4) 77 | SetTextScale(0.43, 0.43) 78 | SetTextColour(255, 255, 255, 190) 79 | SetTextCentre(true) 80 | BeginTextCommandDisplayText("STRING") 81 | AddTextComponentSubstringPlayerName( 82 | "We're just collecting some error info, and then we'll restart for you.") 83 | EndTextCommandDisplayText(0.5, 0.39) 84 | 85 | local currentTime = GetGameTimer() 86 | if currentTime - lastUpdate > 30 then 87 | if percent < 30 then 88 | percent = percent + math.random(2, 3) 89 | elseif percent < 70 then 90 | percent = percent + math.random(3, 5) 91 | elseif percent < 90 then 92 | percent = percent + math.random(1, 3) 93 | elseif percent < 100 then 94 | percent = percent + 1 95 | end 96 | percent = math.min(percent, 100) 97 | lastUpdate = currentTime 98 | end 99 | 100 | SetTextFont(4) 101 | SetTextScale(0.43, 0.43) 102 | SetTextColour(255, 255, 255, 190) 103 | SetTextCentre(true) 104 | BeginTextCommandDisplayText("STRING") 105 | AddTextComponentSubstringPlayerName(percent .. "% complete") 106 | EndTextCommandDisplayText(0.5, 0.44) 107 | 108 | SetTextFont(4) 109 | SetTextScale(0.37, 0.37) 110 | SetTextColour(255, 255, 255, 190) 111 | SetTextCentre(false) 112 | BeginTextCommandDisplayText("STRING") 113 | AddTextComponentSubstringPlayerName( 114 | "If you'd like to know more, you can search online later for this error:") 115 | EndTextCommandDisplayText(0.33, 0.7) 116 | 117 | SetTextFont(4) 118 | SetTextScale(0.37, 0.37) 119 | SetTextColour(255, 255, 255, 190) 120 | SetTextCentre(false) 121 | BeginTextCommandDisplayText("STRING") 122 | AddTextComponentSubstringPlayerName(stopCode) 123 | EndTextCommandDisplayText(0.33, 0.74) 124 | 125 | SetTextFont(4) 126 | SetTextScale(0.37, 0.37) 127 | SetTextColour(255, 255, 255, 190) 128 | SetTextCentre(false) 129 | BeginTextCommandDisplayText("STRING") 130 | AddTextComponentSubstringPlayerName(randomErr) 131 | EndTextCommandDisplayText(0.33, 0.78) 132 | 133 | Citizen.Wait(0) 134 | end 135 | 136 | SetNuiFocus(false, false) 137 | end) 138 | 139 | Citizen.SetTimeout(3000, function() 140 | bluescreenActive = false 141 | if soundId then 142 | StopSound(soundId) 143 | ReleaseSoundId(soundId) 144 | end 145 | end) 146 | end) 147 | 148 | AddEventHandler('onResourceStop', function(resourceName) 149 | if GetCurrentResourceName() ~= resourceName then return end 150 | bluescreenActive = false 151 | SetNuiFocus(false, false) 152 | end) 153 | end 154 | 155 | return BlueScreen 156 | -------------------------------------------------------------------------------- /SecureServe/src/client/core/cache.lua: -------------------------------------------------------------------------------- 1 | ---@class Cache 2 | local Cache = {} 3 | local config_loader = require("client/core/config_loader") 4 | 5 | Cache.Values = { 6 | ped = nil, 7 | vehicle = nil, 8 | isInVehicle = false, 9 | isSwimming = false, 10 | isSwimmingUnderWater = false, 11 | isFalling = false, 12 | isInvisible = false, 13 | health = 0, 14 | armor = 0, 15 | coords = vector3(0,0,0), 16 | lastUpdate = 0, 17 | selectedWeapon = nil, 18 | damageTaken = false, 19 | isAdmin = false, 20 | permissions = {}, 21 | permissionsLastUpdate = 0 22 | } 23 | 24 | Cache.UpdateIntervals = { 25 | coords = 1000, 26 | selectedWeapon = 2500, 27 | ped = 5000, 28 | permissions = 30000, -- Check permissions every 30 seconds 29 | default = 3000 30 | } 31 | 32 | Cache.LastUpdated = {} 33 | Cache.LastValues = {} 34 | 35 | local updateThreads = {} 36 | 37 | ---@description Initialize the cache 38 | function Cache.initialize() 39 | for _, threadId in pairs(updateThreads) do 40 | if threadId then 41 | TerminateThread(threadId) 42 | end 43 | end 44 | updateThreads = {} 45 | 46 | Cache.UpdateAll() 47 | Cache.StartUpdateThreads() 48 | 49 | -- Request permission check on initialization 50 | Cache.RequestPermissionCheck() 51 | end 52 | 53 | function Cache.UpdateAll() 54 | local currentTime = GetGameTimer() 55 | Cache.Values.lastUpdate = currentTime 56 | 57 | local ped = PlayerPedId() 58 | Cache.Values.ped = ped 59 | 60 | for k, v in pairs(Cache.Values) do 61 | Cache.LastValues[k] = v 62 | Cache.LastUpdated[k] = currentTime 63 | end 64 | 65 | Cache.Values.health = GetEntityHealth(ped) 66 | Cache.Values.armor = GetPedArmour(ped) 67 | Cache.Values.coords = GetEntityCoords(ped) 68 | Cache.Values.selectedWeapon = GetSelectedPedWeapon(ped) 69 | Cache.Values.isInVehicle = IsPedInAnyVehicle(ped, false) 70 | if Cache.Values.isInVehicle then 71 | Cache.Values.vehicle = GetVehiclePedIsIn(ped, false) 72 | else 73 | Cache.Values.vehicle = nil 74 | end 75 | 76 | Cache.Values.isSwimming = IsPedSwimming(ped) 77 | Cache.Values.isSwimmingUnderWater = IsPedSwimmingUnderWater(ped) 78 | Cache.Values.isFalling = IsPedFalling(ped) 79 | Cache.Values.isInvisible = IsEntityVisible(ped) == 0 80 | Cache.Values.isAdmin = config_loader.is_whitelisted(GetPlayerServerId(PlayerId())) 81 | end 82 | 83 | function Cache.Get(key, subKey) 84 | local currentTime = GetGameTimer() 85 | local updateInterval = Cache.UpdateIntervals[key] or Cache.UpdateIntervals.default 86 | 87 | -- Handle special case for permission check 88 | if key == "hasPermission" and subKey then 89 | Cache.CheckPermission(subKey) 90 | return Cache.Values.permissions[subKey] or false 91 | end 92 | 93 | if not Cache.LastUpdated[key] or (currentTime - Cache.LastUpdated[key]) > updateInterval then 94 | Cache.ForceUpdate(key) 95 | end 96 | 97 | return Cache.Values[key] 98 | end 99 | 100 | function Cache.ForceUpdate(key) 101 | local currentTime = GetGameTimer() 102 | local ped = Cache.Values.ped 103 | 104 | if currentTime - (Cache.LastUpdated["ped"] or 0) > Cache.UpdateIntervals.ped then 105 | ped = PlayerPedId() 106 | Cache.Values.ped = ped 107 | Cache.LastUpdated["ped"] = currentTime 108 | end 109 | 110 | if key == "ped" then 111 | elseif key == "vehicle" then 112 | if Cache.Values.isInVehicle then 113 | Cache.Values.vehicle = GetVehiclePedIsIn(ped, false) 114 | else 115 | Cache.Values.vehicle = nil 116 | end 117 | elseif key == "isInVehicle" then 118 | Cache.Values.isInVehicle = IsPedInAnyVehicle(ped, false) 119 | elseif key == "isSwimming" then 120 | Cache.Values.isSwimming = IsPedSwimming(ped) 121 | elseif key == "isSwimmingUnderWater" then 122 | Cache.Values.isSwimmingUnderWater = IsPedSwimmingUnderWater(ped) 123 | elseif key == "isFalling" then 124 | Cache.Values.isFalling = IsPedFalling(ped) 125 | elseif key == "isInvisible" then 126 | Cache.Values.isInvisible = IsEntityVisible(ped) == 0 127 | elseif key == "health" then 128 | Cache.Values.health = GetEntityHealth(ped) 129 | elseif key == "armor" then 130 | Cache.Values.armor = GetPedArmour(ped) 131 | elseif key == "coords" then 132 | Cache.Values.coords = GetEntityCoords(ped) 133 | elseif key == "selectedWeapon" then 134 | Cache.Values.selectedWeapon = GetSelectedPedWeapon(ped) 135 | elseif key == "isAdmin" then 136 | Cache.Values.isAdmin = config_loader.is_whitelisted(GetPlayerServerId(PlayerId())) 137 | elseif key == "permissions" then 138 | Cache.RequestPermissionCheck() 139 | end 140 | 141 | Cache.LastUpdated[key] = currentTime 142 | 143 | Cache.LastValues[key] = Cache.Values[key] 144 | end 145 | 146 | function Cache.StartUpdateThreads() 147 | local updateGroups = { 148 | fast = { 149 | interval = 1000, 150 | keys = {"coords", "selectedWeapon"} 151 | }, 152 | medium = { 153 | interval = 2500, 154 | keys = {"isInVehicle", "vehicle", "health", "armor", "isFalling"} 155 | }, 156 | slow = { 157 | interval = 5000, 158 | keys = {"isSwimming", "isSwimmingUnderWater", "isInvisible", "isAdmin"} 159 | }, 160 | permission = { 161 | interval = 30000, -- Every 30 seconds 162 | keys = {"permissions"} 163 | } 164 | } 165 | 166 | for groupName, groupData in pairs(updateGroups) do 167 | updateThreads[groupName] = Citizen.CreateThread(function() 168 | while true do 169 | Citizen.Wait(groupData.interval) 170 | 171 | if groupName == "slow" then 172 | local ped = PlayerPedId() 173 | Cache.Values.ped = ped 174 | Cache.LastUpdated["ped"] = GetGameTimer() 175 | end 176 | 177 | for _, key in ipairs(groupData.keys) do 178 | Cache.ForceUpdate(key) 179 | end 180 | end 181 | end) 182 | end 183 | end 184 | 185 | ---@description Request permission check from server 186 | function Cache.RequestPermissionCheck() 187 | TriggerServerEvent("SecureServe:RequestPermissions") 188 | Cache.Values.permissionsLastUpdate = GetGameTimer() 189 | Cache.LastUpdated["permissions"] = GetGameTimer() 190 | end 191 | 192 | ---@description Check if player has specific permission 193 | ---@param permission string The permission to check 194 | function Cache.CheckPermission(permission) 195 | local currentTime = GetGameTimer() 196 | -- If permissions haven't been checked recently, request an update 197 | if currentTime - Cache.Values.permissionsLastUpdate > Cache.UpdateIntervals.permissions then 198 | Cache.RequestPermissionCheck() 199 | end 200 | end 201 | 202 | -- Event handler for receiving permissions from server 203 | RegisterNetEvent("SecureServe:ReceivePermissions", function(permissions) 204 | Cache.Values.permissions = permissions or {} 205 | Cache.Values.permissionsLastUpdate = GetGameTimer() 206 | Cache.LastUpdated["permissions"] = GetGameTimer() 207 | end) 208 | 209 | AddEventHandler("gameEventTriggered", function(name, args) 210 | if name == "CEventNetworkEntityDamage" then 211 | local victim = args[1] 212 | if victim == Cache.Values.ped then 213 | Cache.Values.damageTaken = true 214 | Cache.ForceUpdate("health") 215 | Cache.ForceUpdate("armor") 216 | end 217 | end 218 | end) 219 | 220 | AddEventHandler('onResourceStop', function(resourceName) 221 | if GetCurrentResourceName() ~= resourceName then return end 222 | 223 | for _, threadId in pairs(updateThreads) do 224 | if threadId then 225 | TerminateThread(threadId) 226 | end 227 | end 228 | 229 | updateThreads = {} 230 | Cache.Values = {} 231 | Cache.LastUpdated = {} 232 | Cache.LastValues = {} 233 | end) 234 | 235 | return Cache -------------------------------------------------------------------------------- /SecureServe/src/client/core/client_logger.lua: -------------------------------------------------------------------------------- 1 | ---@class ClientLoggerModule 2 | local ClientLogger = { 3 | levels = { 4 | DEBUG = 0, 5 | INFO = 1, 6 | WARN = 2, 7 | ERROR = 3, 8 | FATAL = 4 9 | }, 10 | colors = { 11 | DEBUG = "^5", 12 | INFO = "^2", 13 | WARN = "^3", 14 | ERROR = "^1", 15 | FATAL = "^1", 16 | RESET = "^7" 17 | }, 18 | level = 1, 19 | max_history = 4, 20 | history = {}, 21 | debug_enabled = false, 22 | cleanup_thread = nil, 23 | last_cleanup = 0 24 | } 25 | 26 | ---@description Initialize the client logger 27 | ---@param config table Configuration options 28 | function ClientLogger.initialize(config) 29 | if ClientLogger.cleanup_thread then 30 | TerminateThread(ClientLogger.cleanup_thread) 31 | ClientLogger.cleanup_thread = nil 32 | end 33 | 34 | ClientLogger.history = {} 35 | ClientLogger.last_cleanup = GetGameTimer() 36 | 37 | if config then 38 | ClientLogger.level = config.LogLevel or ClientLogger.level 39 | ClientLogger.max_history = config.MaxLogHistory or ClientLogger.max_history 40 | ClientLogger.debug_enabled = config.Debug or false 41 | end 42 | 43 | ClientLogger.info("Client logger initialized with debug mode: " .. tostring(ClientLogger.debug_enabled)) 44 | 45 | RegisterNetEvent("SecureServe:UpdateDebugMode") 46 | AddEventHandler("SecureServe:UpdateDebugMode", function(enabled) 47 | ClientLogger.debug_enabled = enabled 48 | ClientLogger.info("Debug mode " .. (enabled and "enabled" or "disabled")) 49 | end) 50 | 51 | ClientLogger.cleanup_thread = Citizen.CreateThread(function() 52 | while true do 53 | Citizen.Wait(60000) 54 | 55 | local current_time = GetGameTimer() 56 | if (current_time - ClientLogger.last_cleanup) < 60000 then 57 | goto continue 58 | end 59 | 60 | if #ClientLogger.history > (ClientLogger.max_history * 1.5) then 61 | local target_size = ClientLogger.max_history 62 | local history_copy = {} 63 | 64 | for i = #ClientLogger.history - target_size + 1, #ClientLogger.history do 65 | if ClientLogger.history[i] then 66 | table.insert(history_copy, ClientLogger.history[i]) 67 | end 68 | end 69 | 70 | ClientLogger.history = history_copy 71 | ClientLogger.last_cleanup = current_time 72 | 73 | collectgarbage("step", 50) 74 | end 75 | 76 | ::continue:: 77 | end 78 | end) 79 | end 80 | 81 | ---@description Format a log message 82 | ---@param level string The log level 83 | ---@param message string The message to log 84 | ---@param ... any Additional values to include in the log 85 | ---@return string formatted_message The formatted log message 86 | function ClientLogger.format(level, message, ...) 87 | local color = ClientLogger.colors[level] or ClientLogger.colors.INFO 88 | local reset = ClientLogger.colors.RESET 89 | 90 | local final_message = string.format("[%s%s%s] %s", 91 | color, 92 | level, 93 | reset, 94 | message 95 | ) 96 | 97 | local args = {...} 98 | if #args > 0 then 99 | for i, v in ipairs(args) do 100 | if type(v) == "table" then 101 | final_message = final_message .. " " .. ClientLogger.simple_table_format(v) 102 | else 103 | final_message = final_message .. " " .. tostring(v) 104 | end 105 | end 106 | end 107 | 108 | return final_message 109 | end 110 | 111 | function ClientLogger.simple_table_format(t) 112 | if type(t) ~= "table" then return tostring(t) end 113 | 114 | local count = 0 115 | local max_entries = 5 116 | local result = "{" 117 | 118 | for k, v in pairs(t) do 119 | count = count + 1 120 | if count > max_entries then 121 | result = result .. ",...}" 122 | return result 123 | end 124 | 125 | local val 126 | if type(v) == "table" then 127 | val = "{...}" 128 | elseif type(v) == "string" and #v > 20 then 129 | val = string.sub(v, 1, 20) .. "..." 130 | else 131 | val = tostring(v) 132 | end 133 | 134 | result = result .. tostring(k) .. "=" .. val 135 | 136 | if count < max_entries then 137 | result = result .. "," 138 | end 139 | end 140 | 141 | return result .. "}" 142 | end 143 | 144 | ---@description Add a log entry to the history 145 | ---@param level string The log level 146 | ---@param message string The message to log 147 | function ClientLogger.add_to_history(level, message) 148 | if level == "DEBUG" and not ClientLogger.debug_enabled then 149 | return 150 | end 151 | 152 | if #message > 200 then 153 | message = string.sub(message, 1, 200) .. "..." 154 | end 155 | 156 | table.insert(ClientLogger.history, { 157 | level = level, 158 | message = message, 159 | time = GetGameTimer() 160 | }) 161 | 162 | if #ClientLogger.history > (ClientLogger.max_history * 1.5) then 163 | local current_time = GetGameTimer() 164 | 165 | if (current_time - ClientLogger.last_cleanup) < 30000 then 166 | return 167 | end 168 | 169 | local target_size = ClientLogger.max_history 170 | local history_copy = {} 171 | 172 | for i = #ClientLogger.history - target_size + 1, #ClientLogger.history do 173 | if ClientLogger.history[i] then 174 | table.insert(history_copy, ClientLogger.history[i]) 175 | end 176 | end 177 | 178 | ClientLogger.history = history_copy 179 | ClientLogger.last_cleanup = current_time 180 | end 181 | end 182 | 183 | ---@description Send a log to the server for potential Discord logging 184 | ---@param level string The log level 185 | ---@param message string The message to log 186 | function ClientLogger.send_to_server(level, message) 187 | if level == "ERROR" or level == "FATAL" then 188 | if #message > 500 then 189 | message = string.sub(message, 1, 500) .. "..." 190 | end 191 | TriggerServerEvent("SecureServe:ClientLog", level, message) 192 | end 193 | end 194 | 195 | ---@description Log a debug message 196 | ---@param message string The message to log 197 | ---@param ... any Additional values to include in the log 198 | function ClientLogger.debug(message, ...) 199 | if ClientLogger.levels.DEBUG < ClientLogger.level then 200 | return 201 | end 202 | 203 | if not ClientLogger.debug_enabled then 204 | return 205 | end 206 | 207 | local formatted = ClientLogger.format("DEBUG", message, ...) 208 | ClientLogger.add_to_history("DEBUG", formatted) 209 | 210 | print(formatted) 211 | end 212 | 213 | ---@description Log an info message 214 | ---@param message string The message to log 215 | ---@param ... any Additional values to include in the log 216 | function ClientLogger.info(message, ...) 217 | if ClientLogger.levels.INFO < ClientLogger.level then 218 | return 219 | end 220 | 221 | local formatted = ClientLogger.format("INFO", message, ...) 222 | ClientLogger.add_to_history("INFO", formatted) 223 | 224 | if ClientLogger.debug_enabled then 225 | print(formatted) 226 | end 227 | end 228 | 229 | ---@description Log a warning message 230 | ---@param message string The message to log 231 | ---@param ... any Additional values to include in the log 232 | function ClientLogger.warn(message, ...) 233 | if ClientLogger.levels.WARN < ClientLogger.level then 234 | return 235 | end 236 | 237 | local formatted = ClientLogger.format("WARN", message, ...) 238 | ClientLogger.add_to_history("WARN", formatted) 239 | 240 | if ClientLogger.debug_enabled then 241 | print(formatted) 242 | end 243 | 244 | if #message < 100 then 245 | TriggerServerEvent("SecureServe:ForwardLog", "WARN", message) 246 | end 247 | end 248 | 249 | ---@description Log an error message 250 | ---@param message string The message to log 251 | ---@param ... any Additional values to include in the log 252 | function ClientLogger.error(message, ...) 253 | if ClientLogger.levels.ERROR < ClientLogger.level then 254 | return 255 | end 256 | 257 | local formatted = ClientLogger.format("ERROR", message, ...) 258 | ClientLogger.add_to_history("ERROR", formatted) 259 | 260 | print(formatted) 261 | 262 | TriggerServerEvent("SecureServe:ForwardLog", "ERROR", message) 263 | end 264 | 265 | ---@description Log a fatal error message 266 | ---@param message string The message to log 267 | ---@param ... any Additional values to include in the log 268 | function ClientLogger.fatal(message, ...) 269 | if ClientLogger.levels.FATAL < ClientLogger.level then 270 | return 271 | end 272 | 273 | local formatted = ClientLogger.format("FATAL", message, ...) 274 | ClientLogger.add_to_history("FATAL", formatted) 275 | 276 | print(formatted) 277 | 278 | TriggerServerEvent("SecureServe:ForwardLog", "FATAL", message) 279 | end 280 | 281 | ---@description Get the log history 282 | ---@param count number The number of entries to retrieve (default: all) 283 | ---@param level string Optional filter by log level 284 | ---@return table log_entries The log entries 285 | function ClientLogger.get_history(count, level) 286 | local result = {} 287 | local actual_count = math.min(count or #ClientLogger.history, #ClientLogger.history) 288 | local start_index = #ClientLogger.history - actual_count + 1 289 | start_index = math.max(1, start_index) 290 | 291 | for i = start_index, #ClientLogger.history do 292 | local entry = ClientLogger.history[i] 293 | if not level or entry.level == level then 294 | table.insert(result, entry) 295 | end 296 | end 297 | 298 | return result 299 | end 300 | 301 | ---@description Set the debug mode 302 | ---@param enabled boolean The debug mode 303 | function ClientLogger.set_debug_mode(enabled) 304 | ClientLogger.debug_enabled = enabled 305 | end 306 | 307 | function ClientLogger.cleanup() 308 | if ClientLogger.cleanup_thread then 309 | TerminateThread(ClientLogger.cleanup_thread) 310 | ClientLogger.cleanup_thread = nil 311 | end 312 | 313 | ClientLogger.history = {} 314 | collectgarbage("step", 50) 315 | end 316 | 317 | AddEventHandler('onResourceStop', function(resourceName) 318 | if GetCurrentResourceName() ~= resourceName then return end 319 | ClientLogger.cleanup() 320 | end) 321 | 322 | return ClientLogger -------------------------------------------------------------------------------- /SecureServe/src/client/core/config_loader.lua: -------------------------------------------------------------------------------- 1 | ---@class ConfigLoaderModule 2 | local ConfigLoader = {} 3 | 4 | local Utils = require("shared/lib/utils") 5 | local ClientLogger = require("client/core/client_logger") 6 | local protection_count = {} 7 | 8 | -- Initialize global variables 9 | _G.SecureServeConfig = nil 10 | _G.SecureServeLoaded = false 11 | _G.SecureServeProtectionSettings = {} 12 | _G.SecureServeInitCalled = false 13 | _G.SecureServeAdminList = {} 14 | _G.SecureServeLastAdminUpdate = 0 15 | 16 | ---@description Initialize the client-side config loader 17 | function ConfigLoader.initialize() 18 | if _G.SecureServeInitCalled then return end 19 | _G.SecureServeInitCalled = true 20 | 21 | ClientLogger.info("^5[LOADING] ^3Client Config^7") 22 | 23 | TriggerServerEvent("requestConfig") 24 | 25 | RegisterNetEvent("receiveConfig", function(serverConfig) 26 | _G.SecureServeConfig = serverConfig 27 | _G.SecureServe = serverConfig 28 | ConfigLoader.process_config(serverConfig) 29 | _G.SecureServeLoaded = true 30 | ClientLogger.info("^5[SUCCESS] ^3Client Config^7 received from server") 31 | end) 32 | 33 | local attempts = 0 34 | local maxAttempts = 10 35 | 36 | while not _G.SecureServeLoaded and attempts < maxAttempts do 37 | Wait(1000) 38 | attempts = attempts + 1 39 | if not _G.SecureServeLoaded then 40 | TriggerServerEvent("requestConfig") 41 | end 42 | end 43 | end 44 | 45 | ---@description Get config value with optional default 46 | ---@param key string The config key to get 47 | ---@param default any Optional default value if key doesn't exist 48 | ---@return any The config value or default 49 | function ConfigLoader.get(key, default) 50 | if not _G.SecureServeLoaded or not _G.SecureServeConfig then 51 | return default 52 | end 53 | 54 | local parts = {} 55 | for part in key:gmatch("[^%.]+") do 56 | table.insert(parts, part) 57 | end 58 | 59 | local value = _G.SecureServeConfig 60 | for _, part in ipairs(parts) do 61 | if type(value) ~= "table" then 62 | return default 63 | end 64 | value = value[part] 65 | if value == nil then 66 | return default 67 | end 68 | end 69 | 70 | return value 71 | end 72 | 73 | ---@description Check if config has been loaded 74 | ---@return boolean is_loaded Whether config has been loaded 75 | function ConfigLoader.is_loaded() 76 | return _G.SecureServeLoaded 77 | end 78 | 79 | ---@description Get the entire config table 80 | ---@return table config The config table 81 | function ConfigLoader.get_config() 82 | return _G.SecureServeConfig 83 | end 84 | 85 | ---@description Get the SecureServe configuration 86 | ---@return table secureserve The SecureServe configuration 87 | function ConfigLoader.get_secureserve() 88 | return _G.SecureServe 89 | end 90 | 91 | ---@description Ensure settings are initialized 92 | local function ensure_initialized() 93 | if not _G.SecureServeInitCalled then 94 | ConfigLoader.initialize() 95 | Wait(1000) 96 | end 97 | end 98 | 99 | ---@description Get protection setting directly from SecureServe.Protection.Simple 100 | ---@param name string The name of the protection 101 | ---@param property string The property to get 102 | ---@return any value The protection setting value 103 | local function get_from_simple_protection(name, property) 104 | if not _G.SecureServe or not _G.SecureServe.Protection or not _G.SecureServe.Protection.Simple then 105 | return nil 106 | end 107 | 108 | for _, v in pairs(_G.SecureServe.Protection.Simple) do 109 | if v.protection == name then 110 | if property == "time" and type(v.time) ~= "number" and _G.SecureServe.BanTimes then 111 | return _G.SecureServe.BanTimes[v.time] 112 | elseif property == "webhook" and v.webhook == "" and _G.SecureServe.Webhooks then 113 | return _G.SecureServe.Webhooks.Simple 114 | else 115 | return v[property] 116 | end 117 | end 118 | end 119 | 120 | return nil 121 | end 122 | 123 | ---@description Get a protection setting by name and property 124 | ---@param name string The name of the protection 125 | ---@param property string The property to get 126 | ---@return any value The protection setting value 127 | function ConfigLoader.get_protection_setting(name, property) 128 | 129 | 130 | if not name or not property then 131 | return nil 132 | end 133 | 134 | if _G.SecureServeProtectionSettings[name] and _G.SecureServeProtectionSettings[name][property] ~= nil then 135 | return _G.SecureServeProtectionSettings[name][property] 136 | end 137 | 138 | if _G.SecureServeLoaded and _G.SecureServe and _G.SecureServe.Protection and _G.SecureServe.Protection.Simple then 139 | for _, v in pairs(_G.SecureServe.Protection.Simple) do 140 | if v.protection == name then 141 | local time = v.time 142 | if type(time) ~= "number" and _G.SecureServe.BanTimes then 143 | time = _G.SecureServe.BanTimes[v.time] 144 | end 145 | 146 | local webhook = v.webhook 147 | if webhook == "" and _G.SecureServe.Webhooks then 148 | webhook = _G.SecureServe.Webhooks.Simple 149 | end 150 | 151 | local settings = { 152 | time = time, 153 | limit = v.limit or 999, 154 | webhook = webhook, 155 | enabled = v.enabled, 156 | default = v.default, 157 | defaultr = v.defaultr, 158 | tolerance = v.tolerance, 159 | defaults = v.defaults, 160 | dispatch = v.dispatch 161 | } 162 | 163 | _G.SecureServeProtectionSettings[name] = settings 164 | 165 | return settings[property] 166 | end 167 | end 168 | end 169 | 170 | return get_from_simple_protection(name, property) 171 | end 172 | 173 | ---@param config table The received config from server 174 | function ConfigLoader.process_config(config) 175 | if not config then return end 176 | 177 | _G.SecureServe = config 178 | local SecureServe = _G.SecureServe 179 | 180 | _G.SecureServeProtectionSettings = _G.SecureServeProtectionSettings or {} 181 | 182 | for k, v in pairs(SecureServe.Protection.Simple) do 183 | if v.webhook == "" then 184 | SecureServe.Protection.Simple[k].webhook = SecureServe.Webhooks.Simple 185 | end 186 | if type(v.time) ~= "number" then 187 | SecureServe.Protection.Simple[k].time = SecureServe.BanTimes[v.time] 188 | end 189 | 190 | local name = SecureServe.Protection.Simple[k].protection 191 | local dispatch = SecureServe.Protection.Simple[k].dispatch 192 | local default = SecureServe.Protection.Simple[k].default 193 | local defaultr = SecureServe.Protection.Simple[k].defaultr 194 | local tolerance = SecureServe.Protection.Simple[k].tolerance 195 | local defaults = SecureServe.Protection.Simple[k].defaults 196 | local time = SecureServe.Protection.Simple[k].time 197 | if type(time) ~= "number" then 198 | time = SecureServe.BanTimes[v.time] 199 | end 200 | local limit = SecureServe.Protection.Simple[k].limit or 999 201 | local webhook = SecureServe.Protection.Simple[k].webhook 202 | if webhook == "" then 203 | webhook = SecureServe.Webhooks.Simple 204 | end 205 | local enabled = SecureServe.Protection.Simple[k].enabled 206 | 207 | ConfigLoader.assign_protection_settings(name, { 208 | ["time"] = time, 209 | ["limit"] = limit, 210 | ["webhook"] = webhook, 211 | ["enabled"] = enabled, 212 | ["default"] = default, 213 | ["defaultr"] = defaultr, 214 | ["tolerance"] = tolerance, 215 | ["defaults"] = defaults, 216 | ["dispatch"] = dispatch 217 | }) 218 | 219 | if not protection_count["SecureServe.Protection.Simple"] then protection_count["SecureServe.Protection.Simple"] = 0 end 220 | protection_count["SecureServe.Protection.Simple"] = protection_count["SecureServe.Protection.Simple"] + 1 221 | end 222 | 223 | ConfigLoader.process_blacklist_category("BlacklistedCommands") 224 | ConfigLoader.process_blacklist_category("BlacklistedSprites") 225 | ConfigLoader.process_blacklist_category("BlacklistedAnimDicts") 226 | ConfigLoader.process_blacklist_category("BlacklistedExplosions") 227 | ConfigLoader.process_blacklist_category("BlacklistedWeapons") 228 | ConfigLoader.process_blacklist_category("BlacklistedVehicles") 229 | ConfigLoader.process_blacklist_category("BlacklistedObjects") 230 | end 231 | 232 | ---@param category string The blacklist category to process 233 | function ConfigLoader.process_blacklist_category(category) 234 | local SecureServe = _G.SecureServe 235 | 236 | for k, v in pairs(SecureServe.Protection[category]) do 237 | if v.webhook == "" then 238 | SecureServe.Protection[category][k].webhook = SecureServe.Webhooks[category] 239 | end 240 | if type(v.time) ~= "number" then 241 | SecureServe.Protection[category][k].time = SecureServe.BanTimes[v.time] 242 | end 243 | 244 | if not protection_count["SecureServe.Protection." .. category] then 245 | protection_count["SecureServe.Protection." .. category] = 0 246 | end 247 | protection_count["SecureServe.Protection." .. category] = protection_count["SecureServe.Protection." .. category] + 1 248 | end 249 | end 250 | 251 | ---@param name string The name of the protection 252 | ---@param settings table The settings to assign 253 | function ConfigLoader.assign_protection_settings(name, settings) 254 | _G.SecureServeProtectionSettings[name] = settings 255 | end 256 | 257 | ---@param player number The player ID to check 258 | ---@return boolean is_whitelisted Whether the player is whitelisted 259 | function ConfigLoader.is_whitelisted(player_id) 260 | local player_id = player_id or GetPlayerServerId(PlayerId()) 261 | 262 | local currentTime = GetGameTimer() 263 | if currentTime - _G.SecureServeLastAdminUpdate > 60000 then 264 | TriggerServerEvent("SecureServe:RequestAdminList") 265 | _G.SecureServeLastAdminUpdate = currentTime 266 | end 267 | 268 | if _G.SecureServeAdminList[tostring(player_id)] then 269 | return true 270 | end 271 | 272 | return false 273 | end 274 | 275 | RegisterNetEvent("SecureServe:ReceiveAdminList", function(adminList) 276 | _G.SecureServeAdminList = adminList 277 | _G.SecureServeLastAdminUpdate = GetGameTimer() 278 | end) 279 | 280 | Citizen.CreateThread(function() 281 | Citizen.Wait(2000) 282 | TriggerServerEvent("SecureServe:RequestAdminList") 283 | _G.SecureServeLastAdminUpdate = GetGameTimer() 284 | end) 285 | 286 | ---@param player number The player ID to check 287 | ---@return boolean is_menu_admin Whether the player is a menu admin 288 | function ConfigLoader.is_menu_admin(player) 289 | local promise = promise.new() 290 | 291 | TriggerServerEvent('SecureServe:RequestMenuAdminStatus', player) 292 | 293 | RegisterNetEvent('SecureServe:ReturnMenuAdminStatus', function(result) 294 | promise:resolve(result) 295 | end) 296 | 297 | return Citizen.Await(promise) 298 | end 299 | 300 | ---@description Check if a model is blacklisted 301 | ---@param model_hash string|number The model hash to check 302 | ---@return boolean is_blacklisted Whether the model is blacklisted 303 | function ConfigLoader.is_model_blacklisted(model_hash) 304 | 305 | if not _G.SecureServeLoaded or not _G.SecureServeConfig then 306 | return false 307 | end 308 | 309 | model_hash = tostring(model_hash) 310 | 311 | if _G.SecureServeConfig.Protection and _G.SecureServeConfig.Protection.BlacklistedObjects then 312 | for _, blacklisted in pairs(_G.SecureServeConfig.Protection.BlacklistedObjects) do 313 | if tostring(blacklisted.hash) == model_hash then 314 | return true 315 | end 316 | end 317 | end 318 | 319 | if _G.SecureServeConfig.Protection and _G.SecureServeConfig.Protection.BlacklistedVehicles then 320 | for _, blacklisted in pairs(_G.SecureServeConfig.Protection.BlacklistedVehicles) do 321 | if tostring(blacklisted.hash) == model_hash then 322 | return true 323 | end 324 | end 325 | end 326 | 327 | if _G.SecureServeConfig.Protection and _G.SecureServeConfig.Protection.BlacklistedPeds then 328 | for _, blacklisted in pairs(_G.SecureServeConfig.Protection.BlacklistedPeds) do 329 | if tostring(blacklisted.hash) == model_hash then 330 | return true 331 | end 332 | end 333 | end 334 | 335 | return false 336 | end 337 | 338 | return ConfigLoader 339 | -------------------------------------------------------------------------------- /SecureServe/src/client/core/entity_monitor.lua: -------------------------------------------------------------------------------- 1 | ---@class EntityMonitorModule 2 | local EntityMonitor = { 3 | tracked_entities = {}, 4 | suspicious_entities = {} 5 | } 6 | 7 | local Utils = require("shared/lib/utils") 8 | 9 | ---@description Initialize entity monitoring 10 | function EntityMonitor.initialize() 11 | return 12 | end 13 | 14 | ---@description Get the name of an entity type 15 | ---@param entity_type number The entity type number 16 | ---@return string The entity type name 17 | function EntityMonitor.get_entity_type_name(entity_type) 18 | if entity_type == 1 then 19 | return "Ped" 20 | elseif entity_type == 2 then 21 | return "Vehicle" 22 | elseif entity_type == 3 then 23 | return "Object" 24 | else 25 | return "Unknown" 26 | end 27 | end 28 | 29 | return EntityMonitor -------------------------------------------------------------------------------- /SecureServe/src/client/init.lua: -------------------------------------------------------------------------------- 1 | local Require = require("shared/lib/require") 2 | 3 | ---@class ClientInit 4 | local ClientInit = {} 5 | 6 | ---@description Initialize all client components 7 | function ClientInit.initialize() 8 | local logger = require("client/core/client_logger") 9 | local ConfigLoader = require("client/core/config_loader") 10 | 11 | logger.initialize({ 12 | Debug = false 13 | }) 14 | 15 | logger.info("==============================================") 16 | logger.info("SecureServe Client v1.2.1 initializing...") 17 | 18 | ConfigLoader.initialize() 19 | logger.info("Config Loader initialized") 20 | 21 | local secureServe = ConfigLoader.get_secureserve() 22 | 23 | local Cache = require("client/core/cache") 24 | Cache.initialize() 25 | logger.info("Cache initialized") 26 | 27 | Citizen.CreateThread(function() 28 | Wait(2000) 29 | TriggerServerEvent("SecureServe:CheckWhitelist") 30 | end) 31 | 32 | logger.info("Loading Protection Manager...") 33 | local ProtectionManager = require("client/protections/protection_manager") 34 | ProtectionManager.initialize() 35 | logger.info("Protection Manager initialized") 36 | 37 | logger.info("Loading Entity Monitor...") 38 | local EntityMonitor = require("client/core/entity_monitor") 39 | EntityMonitor.initialize() 40 | logger.info("Entity Monitor initialized") 41 | 42 | logger.info("Loading Blue Screen...") 43 | local blue_screen = require("client/core/blue_screen") 44 | blue_screen.initialize() 45 | logger.info("Blue Screen initialized") 46 | 47 | RegisterNetEvent("SecureServe:UpdateDebugMode", function(enabled) 48 | local logger = require("client/core/client_logger") 49 | logger.set_debug_mode(enabled) 50 | end) 51 | 52 | if SecureServeErrorHandler then 53 | logger.info("Global Error Handler initialized") 54 | end 55 | 56 | logger.info("Client-side components initialized") 57 | logger.info("==============================================") 58 | end 59 | 60 | CreateThread(function() 61 | Wait(1000) 62 | ClientInit.initialize() 63 | end) 64 | 65 | return ClientInit -------------------------------------------------------------------------------- /SecureServe/src/client/main.lua: -------------------------------------------------------------------------------- 1 | RegisterNetEvent("SecureServe:ForceSocialClubUpdate", function() 2 | ForceSocialClubUpdate() 3 | end) 4 | 5 | RegisterNetEvent("SecureServe:ForceUpdate", function() 6 | ForceSocialClubUpdate() 7 | NetworkIsPlayerActive(PlayerId()) 8 | NetworkIsPlayerConnected(PlayerId()) 9 | end) 10 | 11 | RegisterNetEvent("SecureServe:ShowPermaBanCard", function(cardData) 12 | ForceSocialClubUpdate() 13 | end) 14 | 15 | 16 | RegisterNetEvent("checkalive", function () 17 | TriggerServerEvent("addalive") 18 | end) 19 | 20 | RegisterNetEvent("SecureServe:Client:getEncryptionKey", function(key) 21 | end) 22 | -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_afk_injection.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiAfkInjectionModule 6 | local AntiAfkInjection = {} 7 | 8 | ---@description Initialize Anti AFK Injection protection 9 | function AntiAfkInjection.initialize() 10 | if not ConfigLoader.get_protection_setting("Anti AFK Injection", "enabled") then return end 11 | 12 | Citizen.CreateThread(function() 13 | while true do 14 | local pid = Cache.Get("ped") 15 | if (GetIsTaskActive(pid, 100)) 16 | or (GetIsTaskActive(pid, 101)) 17 | or (GetIsTaskActive(pid, 151)) 18 | or (GetIsTaskActive(pid, 221)) 19 | or (GetIsTaskActive(pid, 222)) then 20 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Anti AFK Injection", webhook, time) 21 | end 22 | Citizen.Wait(5000) 23 | end 24 | end) 25 | end 26 | 27 | ProtectionManager.register_protection("afk_injection", AntiAfkInjection.initialize) 28 | 29 | return AntiAfkInjection -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_ai.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | 4 | ---@class AntiAIModule 5 | local AntiAI = {} 6 | 7 | ---@description Initialize Anti AI protection 8 | function AntiAI.initialize() 9 | if not ConfigLoader.get_protection_setting("Anti AI", "enabled") then return end 10 | local default = ConfigLoader.get_protection_setting("Anti AI", "default") 11 | Citizen.CreateThread(function() 12 | while true do 13 | Citizen.Wait(15000) 14 | local weapons = { 15 | GetHashKey("COMPONENT_COMBATPISTOL_CLIP_01"), 16 | GetHashKey("COMPONENT_COMBATPISTOL_CLIP_02"), 17 | GetHashKey("COMPONENT_APPISTOL_CLIP_01"), 18 | GetHashKey("COMPONENT_APPISTOL_CLIP_02"), 19 | GetHashKey("COMPONENT_MICROSMG_CLIP_01"), 20 | GetHashKey("COMPONENT_MICROSMG_CLIP_02"), 21 | GetHashKey("COMPONENT_SMG_CLIP_01"), 22 | GetHashKey("COMPONENT_SMG_CLIP_02"), 23 | GetHashKey("COMPONENT_ASSAULTRIFLE_CLIP_01"), 24 | GetHashKey("COMPONENT_ASSAULTRIFLE_CLIP_02"), 25 | GetHashKey("COMPONENT_CARBINERIFLE_CLIP_01"), 26 | GetHashKey("COMPONENT_CARBINERIFLE_CLIP_02"), 27 | GetHashKey("COMPONENT_ADVANCEDRIFLE_CLIP_01"), 28 | GetHashKey("COMPONENT_ADVANCEDRIFLE_CLIP_02"), 29 | GetHashKey("COMPONENT_MG_CLIP_01"), 30 | GetHashKey("COMPONENT_MG_CLIP_02"), 31 | GetHashKey("COMPONENT_COMBATMG_CLIP_01"), 32 | GetHashKey("COMPONENT_COMBATMG_CLIP_02"), 33 | GetHashKey("COMPONENT_PUMPSHOTGUN_CLIP_01"), 34 | GetHashKey("COMPONENT_SAWNOFFSHOTGUN_CLIP_01"), 35 | GetHashKey("COMPONENT_ASSAULTSHOTGUN_CLIP_01"), 36 | GetHashKey("COMPONENT_ASSAULTSHOTGUN_CLIP_02"), 37 | GetHashKey("COMPONENT_PISTOL50_CLIP_01"), 38 | GetHashKey("COMPONENT_PISTOL50_CLIP_02"), 39 | GetHashKey("COMPONENT_ASSAULTSMG_CLIP_01"), 40 | GetHashKey("COMPONENT_ASSAULTSMG_CLIP_02"), 41 | GetHashKey("COMPONENT_AT_RAILCOVER_01"), 42 | GetHashKey("COMPONENT_AT_AR_AFGRIP"), 43 | GetHashKey("COMPONENT_AT_PI_FLSH"), 44 | GetHashKey("COMPONENT_AT_AR_FLSH"), 45 | GetHashKey("COMPONENT_AT_SCOPE_MACRO"), 46 | GetHashKey("COMPONENT_AT_SCOPE_SMALL"), 47 | GetHashKey("COMPONENT_AT_SCOPE_MEDIUM"), 48 | GetHashKey("COMPONENT_AT_SCOPE_LARGE"), 49 | GetHashKey("COMPONENT_AT_SCOPE_MAX"), 50 | GetHashKey("COMPONENT_AT_PI_SUPP"), 51 | } 52 | 53 | for i = 1, #weapons do 54 | local dmg_mod = GetWeaponComponentDamageModifier(weapons[i]) 55 | local accuracy_mod = GetWeaponComponentAccuracyModifier(weapons[i]) 56 | local range_mod = GetWeaponComponentRangeModifier(weapons[i]) 57 | 58 | if dmg_mod > default or accuracy_mod > default or range_mod > default then 59 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Anti AIS", webhook, time) 60 | end 61 | end 62 | end 63 | end) 64 | end 65 | 66 | ProtectionManager.register_protection("ai", AntiAI.initialize) 67 | 68 | return AntiAI -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_aim_assist.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiAimAssistModule 6 | local AntiAimAssist = {} 7 | 8 | ---@description Initialize Anti Aim Assist protection 9 | function AntiAimAssist.initialize() 10 | if not ConfigLoader.get_protection_setting("Anti Aim Assist", "enabled") then return end 11 | 12 | Citizen.CreateThread(function() 13 | while true do 14 | Citizen.Wait(10000) 15 | local aim_state = GetLocalPlayerAimState() 16 | if Cache.Get("hasPermission", "aimassist") or Cache.Get("hasPermission", "all") or Cache.Get("isAdmin") then 17 | goto continue 18 | end 19 | 20 | if aim_state ~= 3 then 21 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Anti Aim Assist " .. aim_state, webhook, time) 22 | end 23 | ::continue:: 24 | end 25 | end) 26 | end 27 | 28 | ProtectionManager.register_protection("aim_assist", AntiAimAssist.initialize) 29 | 30 | return AntiAimAssist -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_bigger_hitbox.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiBiggerHitboxModule 6 | local AntiBiggerHitbox = {} 7 | 8 | ---@description Initialize Anti Bigger Hitbox protection 9 | function AntiBiggerHitbox.initialize() 10 | if not ConfigLoader.get_protection_setting("Anti Bigger Hitbox", "enabled") then return end 11 | 12 | Citizen.CreateThread(function() 13 | while true do 14 | local id = Cache.Get("ped") 15 | local ped = GetEntityModel(id) 16 | 17 | if (ped == GetHashKey('mp_m_freemode_01') or ped == GetHashKey('mp_f_freemode_01')) then 18 | local min, max = GetModelDimensions(ped) 19 | if (min.x > -0.58) 20 | or (min.x < -0.62) 21 | or (min.y < -0.252) 22 | or (min.y < -0.29) 23 | or (max.z > 0.98) then 24 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Anti Bigger Hit Box", webhook, time) 25 | end 26 | end 27 | 28 | Citizen.Wait(15000) 29 | end 30 | end) 31 | end 32 | 33 | ProtectionManager.register_protection("bigger_hitbox", AntiBiggerHitbox.initialize) 34 | 35 | return AntiBiggerHitbox -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_entity_security.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Utils = require("shared/lib/utils") 4 | local Cache = require("client/core/cache") 5 | 6 | ---@class AntiEntitySecurityModule 7 | local AntiEntitySecurity = { 8 | active_handlers = {}, 9 | entity_cache = {}, 10 | cleanup_interval = 120000, 11 | last_cache_cleanup = 0, 12 | entity_check_count = 0 13 | } 14 | 15 | ---@description Initialize Entity Security protection 16 | function AntiEntitySecurity.initialize() 17 | AntiEntitySecurity.cleanup() 18 | 19 | local whitelisted_resources = {} 20 | local last_check_times = {} 21 | local CHECK_COOLDOWN = 1000 22 | 23 | local secureServe = ConfigLoader.get_secureserve() 24 | if not secureServe or not secureServe.Module or not secureServe.Module.Entity then 25 | return 26 | end 27 | 28 | local blacklisted_vehicles = {} 29 | local blacklisted_peds = {} 30 | local blacklisted_objects = {} 31 | 32 | for _, entry in ipairs(secureServe.Module.Entity.SecurityWhitelist) do 33 | whitelisted_resources[entry.resource] = entry.whitelist 34 | end 35 | 36 | local function checkEntityResource(entity, entityType, modelHash) 37 | AntiEntitySecurity.entity_check_count = AntiEntitySecurity.entity_check_count + 1 38 | if AntiEntitySecurity.entity_check_count % 3 ~= 0 then 39 | return 40 | end 41 | 42 | if not entity or not DoesEntityExist(entity) then return end 43 | 44 | local entityId = tostring(entity) 45 | if AntiEntitySecurity.entity_cache[entityId] then 46 | return 47 | end 48 | 49 | AntiEntitySecurity.entity_cache[entityId] = { 50 | time = GetGameTimer(), 51 | type = entityType 52 | } 53 | 54 | local entityScript = GetEntityScript(entity) 55 | if not entityScript then entityScript = "unknown" end 56 | 57 | if whitelisted_resources[entityScript] then 58 | return 59 | end 60 | 61 | if DoesEntityExist(entity) then 62 | SetEntityAsMissionEntity(entity, true, true) 63 | if IsEntityAVehicle(entity) then 64 | DeleteVehicle(entity) 65 | else 66 | DeleteEntity(entity) 67 | end 68 | end 69 | 70 | local detectionMessage = string.format("Created blacklisted %s (hash: %s) from unauthorized resource: %s", 71 | entityType, modelHash, entityScript) 72 | 73 | TriggerServerEvent("SecureServe:Server:Methods:ModulePunish", nil, detectionMessage, "entity_security", 2147483647) 74 | end 75 | 76 | Citizen.CreateThread(function() 77 | while true do 78 | Citizen.Wait(30000) 79 | 80 | local current_time = GetGameTimer() 81 | if (current_time - AntiEntitySecurity.last_cache_cleanup) < AntiEntitySecurity.cleanup_interval then 82 | goto continue 83 | end 84 | 85 | local count = 0 86 | local cache_size = 0 87 | 88 | for _ in pairs(AntiEntitySecurity.entity_cache) do 89 | cache_size = cache_size + 1 90 | end 91 | 92 | if cache_size > 100 then 93 | for entityId, info in pairs(AntiEntitySecurity.entity_cache) do 94 | if current_time - info.time > AntiEntitySecurity.cleanup_interval then 95 | AntiEntitySecurity.entity_cache[entityId] = nil 96 | count = count + 1 97 | end 98 | end 99 | 100 | AntiEntitySecurity.entity_check_count = 0 101 | 102 | if count > 0 then 103 | collectgarbage("step", 50) 104 | end 105 | 106 | AntiEntitySecurity.last_cache_cleanup = current_time 107 | end 108 | 109 | ::continue:: 110 | end 111 | end) 112 | 113 | AntiEntitySecurity.event_handler = RegisterNetEvent("SecureServe:CheckEntityResource", function(netId, modelHash) 114 | local entity = NetworkGetEntityFromNetworkId(netId) 115 | if entity == nil or not DoesEntityExist(entity) then return end 116 | 117 | local entityType = "Unknown" 118 | if IsEntityAVehicle(entity) then 119 | entityType = "Vehicle" 120 | elseif IsEntityAPed(entity) then 121 | entityType = "Ped" 122 | elseif IsEntityAnObject(entity) then 123 | entityType = "Object" 124 | end 125 | 126 | local entityScript = GetEntityScript(entity) 127 | if not entityScript then entityScript = "unknown" end 128 | if entityScript ~= "unknown" then 129 | local isWhitelisted = false 130 | if whitelisted_resources[entityScript] then 131 | isWhitelisted = true 132 | return 133 | end 134 | 135 | if not isWhitelisted then 136 | if DoesEntityExist(entity) then 137 | SetEntityAsMissionEntity(entity, true, true) 138 | if IsEntityAVehicle(entity) then 139 | DeleteVehicle(entity) 140 | else 141 | DeleteEntity(entity) 142 | end 143 | end 144 | 145 | local detectionMessage = string.format("Created blacklisted %s (hash: %s) from unauthorized resource: %s", 146 | entityType, modelHash, entityScript) 147 | TriggerServerEvent("SecureServe:Server:Methods:ModulePunish", nil, detectionMessage, "entity_security", 2147483647) 148 | end 149 | end 150 | end) 151 | 152 | local function handleEntityStateBag(entityType, bagName, value, entityGetFunction, entityHash, blacklist) 153 | if not value then return end 154 | 155 | local current_time = GetGameTimer() 156 | if last_check_times[entityType] and (current_time - last_check_times[entityType]) < CHECK_COOLDOWN then 157 | return 158 | end 159 | last_check_times[entityType] = current_time 160 | 161 | local entity = entityGetFunction(bagName) 162 | if not entity or not DoesEntityExist(entity) then return end 163 | 164 | local hash = GetEntityModel(entity) 165 | 166 | if blacklist and blacklist[hash] then 167 | SetEntityAsMissionEntity(entity, true, true) 168 | 169 | if entityType == "Vehicle" then 170 | DeleteVehicle(entity) 171 | else 172 | DeleteEntity(entity) 173 | end 174 | 175 | checkEntityResource(entity, entityType, hash) 176 | end 177 | end 178 | 179 | AntiEntitySecurity.active_handlers.vehicle = AddStateBagChangeHandler("VehicleCreate", "entity:", function(bagName, key, value) 180 | handleEntityStateBag("Vehicle", bagName, value, 181 | function(bag) return GetEntityFromStateBagName(bag) end, 182 | "vehicleHash", blacklisted_vehicles) 183 | end) 184 | 185 | AntiEntitySecurity.active_handlers.ped = AddStateBagChangeHandler("PedCreate", "entity:", function(bagName, key, value) 186 | handleEntityStateBag("Ped", bagName, value, 187 | function(bag) return GetEntityFromStateBagName(bag) end, 188 | "pedHash", blacklisted_peds) 189 | end) 190 | 191 | AntiEntitySecurity.active_handlers.object = AddStateBagChangeHandler("ObjectCreate", "entity:", function(bagName, key, value) 192 | handleEntityStateBag("Object", bagName, value, 193 | function(bag) return GetEntityFromStateBagName(bag) end, 194 | "objectHash", blacklisted_objects) 195 | end) 196 | end 197 | 198 | function AntiEntitySecurity.cleanup() 199 | for name, handler in pairs(AntiEntitySecurity.active_handlers) do 200 | RemoveStateBagChangeHandler(handler) 201 | end 202 | AntiEntitySecurity.active_handlers = {} 203 | 204 | AntiEntitySecurity.entity_cache = {} 205 | AntiEntitySecurity.last_cache_cleanup = GetGameTimer() 206 | AntiEntitySecurity.entity_check_count = 0 207 | 208 | collectgarbage("step", 50) 209 | end 210 | 211 | ProtectionManager.register_protection("entity_security", AntiEntitySecurity.initialize) 212 | 213 | return AntiEntitySecurity -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_explosion_bullet.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiExplosionBulletModule 6 | local AntiExplosionBullet = {} 7 | 8 | ---@description Initialize Anti Explosion Bullet protection 9 | function AntiExplosionBullet.initialize() 10 | if not ConfigLoader.get_protection_setting("Anti Explosion Bullet", "enabled") then return end 11 | 12 | Citizen.CreateThread(function() 13 | while true do 14 | Citizen.Wait(2500) 15 | local weapon = Cache.Get("selectedWeapon") 16 | local damage_type = GetWeaponDamageType(weapon) 17 | SetWeaponDamageModifier(GetHashKey("WEAPON_EXPLOSION"), 0.0) 18 | if damage_type == 4 or damage_type == 5 then 19 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Explosive ammo", webhook, time) 20 | end 21 | end 22 | end) 23 | end 24 | 25 | ProtectionManager.register_protection("explosion_bullet", AntiExplosionBullet.initialize) 26 | 27 | return AntiExplosionBullet -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_freecam.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiFreecamModule 6 | local AntiFreecam = { 7 | debug = false, 8 | flags = { 9 | DISTANCE_EXCEEDED = 1, 10 | ANGLE_SUSPICIOUS = 2, 11 | THROUGH_WALL = 4, 12 | STATIC_PLAYER = 8, 13 | MOVING_CAMERA = 16 14 | }, 15 | current_flags = 0, 16 | check_interval = 2000, 17 | flag_threshold = 9, 18 | flag_weight = { 19 | [1] = 1, 20 | [2] = 1, 21 | [4] = 2, 22 | [8] = 1, 23 | [16] = 1 24 | }, 25 | cooldown = 9000, 26 | last_detection_time = 0, 27 | position_history = {}, 28 | history_size = 5, 29 | distance_threshold = 20.0, 30 | interior_distance_threshold = 10.0 31 | } 32 | 33 | ---@description Initialize Anti Freecam protection 34 | function AntiFreecam.initialize() 35 | if not ConfigLoader.get_protection_setting("Anti Freecam", "enabled") then return end 36 | 37 | if AntiFreecam.debug then print("[AntiFreecam] Protection initialized with flag-based detection") end 38 | 39 | Citizen.CreateThread(function() 40 | while true do 41 | Citizen.Wait(2000) 42 | 43 | if Cache.Get("hasPermission", "freecam") or Cache.Get("hasPermission", "all") or Cache.Get("isAdmin") then 44 | end 45 | 46 | ---@todo v1.3.0: Implement Anti Freecam protection 47 | 48 | end 49 | end) 50 | 51 | end 52 | 53 | ProtectionManager.register_protection("freecam", AntiFreecam.initialize) 54 | 55 | return AntiFreecam 56 | -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_give_weapon.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiGiveWeaponModule 6 | local AntiGiveWeapon = {} 7 | local current_weapon = GetHashKey("WEAPON_UNARMED") 8 | local flag = 0 9 | 10 | ---@description Initialize Anti Give Weapon protection 11 | function AntiGiveWeapon.initialize() 12 | if not ConfigLoader.get_protection_setting("Anti Give Weapon", "enabled") then return end 13 | 14 | RegisterNetEvent("SecureServe:Weapons:Whitelist", function(data) 15 | local source = source 16 | local weapon = data.weapon 17 | local resource = data.resource 18 | 19 | if not weapon or not resource then return end 20 | 21 | current_weapon = weapon 22 | end) 23 | 24 | Citizen.CreateThread(function() 25 | while true do 26 | Wait(2500) 27 | if current_weapon ~= Cache.Get("selectedWeapon") then 28 | flag = flag + 1 29 | 30 | if flag == 2 then 31 | RemoveWeaponFromPed(PlayerPedId(), current_weapon) 32 | flag = 0 33 | end 34 | end 35 | end 36 | end) 37 | 38 | Citizen.CreateThread(function() 39 | while true do 40 | Wait(15000) 41 | flag = 0 42 | end 43 | end) 44 | end 45 | 46 | ProtectionManager.register_protection("give_weapon", AntiGiveWeapon.initialize) 47 | 48 | return AntiGiveWeapon 49 | -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_god_mode.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiGodModeModule 6 | local AntiGodMode = {} 7 | 8 | ---@description Initialize Anti God Mode protection 9 | function AntiGodMode.initialize() 10 | if not ConfigLoader.get_protection_setting("Anti God Mode", "enabled") then return end 11 | 12 | 13 | Citizen.CreateThread(function() 14 | while true do 15 | Citizen.Wait(1500) 16 | if Cache.Get("hasPermission", "godmode") or Cache.Get("hasPermission", "all") or Cache.Get("isAdmin") then 17 | goto continue 18 | end 19 | 20 | ---@todo v1.3.0: Implement Anti God Mode protection 21 | 22 | ::continue:: 23 | end 24 | end) 25 | end 26 | 27 | ProtectionManager.register_protection("god_mode", AntiGodMode.initialize) 28 | 29 | return AntiGodMode -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_infinite_stamina.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiInfiniteStaminaModule 6 | local AntiInfiniteStamina = {} 7 | 8 | ---@description Initialize Anti Infinite Stamina protection 9 | function AntiInfiniteStamina.initialize() 10 | if not ConfigLoader.get_protection_setting("Anti Infinite Stamina", "enabled") then return end 11 | 12 | local stamina_flags = 0 13 | local consecutive_checks = 0 14 | local sprint_start_time = 0 15 | local SPRINT_THRESHOLD = 15000 16 | 17 | Citizen.CreateThread(function() 18 | while true do 19 | Citizen.Wait(2000) 20 | 21 | if Cache.Get("hasPermission", "infinitestamina") or Cache.Get("hasPermission", "all") or Cache.Get("isAdmin") then 22 | stamina_flags = 0 23 | consecutive_checks = 0 24 | sprint_start_time = 0 25 | goto continue 26 | end 27 | 28 | local ped = Cache.Get("ped") 29 | 30 | if Cache.Get("isInVehicle") or Cache.Get("isSwimming") or Cache.Get("isSwimmingUnderWater") then 31 | sprint_start_time = 0 32 | consecutive_checks = 0 33 | goto continue 34 | end 35 | 36 | if IsPedSprinting(ped) then 37 | if sprint_start_time == 0 then 38 | sprint_start_time = GetGameTimer() 39 | end 40 | 41 | local sprint_duration = GetGameTimer() - sprint_start_time 42 | 43 | local stamina = GetPlayerSprintStaminaRemaining(PlayerId()) 44 | 45 | if sprint_duration > SPRINT_THRESHOLD and stamina > 80 then 46 | consecutive_checks = consecutive_checks + 1 47 | 48 | if consecutive_checks >= 3 then 49 | stamina_flags = stamina_flags + 1 50 | 51 | if stamina_flags >= 3 then 52 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Anti Infinite Stamina", webhook, time) 53 | stamina_flags = 0 54 | consecutive_checks = 0 55 | sprint_start_time = 0 56 | end 57 | end 58 | else 59 | consecutive_checks = 0 60 | end 61 | else 62 | sprint_start_time = 0 63 | consecutive_checks = 0 64 | 65 | if stamina_flags > 0 then 66 | stamina_flags = stamina_flags - 1 67 | end 68 | end 69 | 70 | ::continue:: 71 | end 72 | end) 73 | end 74 | 75 | ProtectionManager.register_protection("infinite_stamina", AntiInfiniteStamina.initialize) 76 | 77 | return AntiInfiniteStamina -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_invisible.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiInvisibleModule 6 | local AntiInvisible = {} 7 | 8 | ---@description Initialize Anti Invisible protection 9 | function AntiInvisible.initialize() 10 | if not ConfigLoader.get_protection_setting("Anti Invisible", "enabled") then return end 11 | 12 | Citizen.CreateThread(function() 13 | while true do 14 | Citizen.Wait(15000) 15 | 16 | if Cache.Get("hasPermission", "invisible") or Cache.Get("hasPermission", "all") or Cache.Get("isAdmin") then 17 | goto continue 18 | end 19 | 20 | ---@todo v1.3.0: Implement Anti Invisible protection 21 | 22 | ::continue:: 23 | end 24 | end) 25 | end 26 | 27 | ProtectionManager.register_protection("invisible", AntiInvisible.initialize) 28 | 29 | return AntiInvisible -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_load_resource_file.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local Cache = require("client/core/cache") 3 | 4 | ---@class AntiLoadResourceFileModule 5 | local AntiLoadResourceFile = {} 6 | local loaded_keys = {} 7 | local pendingResourceChecks = {} 8 | local playerLoaded = false 9 | 10 | ---@description Initialize Anti Load Resource File protection 11 | function AntiLoadResourceFile.initialize() 12 | Citizen.CreateThread(function() 13 | Citizen.Wait(10000) 14 | playerLoaded = true 15 | end) 16 | 17 | AddEventHandler("onResourceStop", function(resourceName) 18 | loaded_keys[resourceName] = nil 19 | end) 20 | 21 | RegisterNetEvent("SecureServe:Client_Callbacks:Protections:GetResourceStatus", function(stopped, started, restarted) 22 | if not playerLoaded or stopped or started or restarted then 23 | for resourceName, _ in pairs(pendingResourceChecks) do 24 | loaded_keys[resourceName] = true 25 | end 26 | pendingResourceChecks = {} 27 | return 28 | end 29 | 30 | Citizen.SetTimeout(5000, function() 31 | if playerLoaded then 32 | for resourceName, _ in pairs(pendingResourceChecks) do 33 | if loaded_keys[resourceName] then 34 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, 35 | { 36 | reason = "Anti Load Resource File", 37 | details = "Resource " .. resourceName .. " attempted to load key multiple times without restart" 38 | }, 39 | webhook, 40 | 2147483647) 41 | end 42 | loaded_keys[resourceName] = true 43 | end 44 | else 45 | for resourceName, _ in pairs(pendingResourceChecks) do 46 | loaded_keys[resourceName] = true 47 | end 48 | end 49 | pendingResourceChecks = {} 50 | end) 51 | end) 52 | 53 | RegisterNetEvent("SecureServe:Client:LoadedKey", function(resourceName) 54 | pendingResourceChecks[resourceName] = true 55 | TriggerServerEvent("SecureServe:Server_Callbacks:Protections:GetResourceStatus") 56 | end) 57 | end 58 | 59 | ProtectionManager.register_protection("load_resource_file", AntiLoadResourceFile.initialize) 60 | 61 | return AntiLoadResourceFile -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_magic_bullet.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiMagicBulletModule 6 | local AntiMagicBullet = {} 7 | 8 | ---@description Initialize Anti Magic Bullet protection 9 | function AntiMagicBullet.initialize() 10 | if not ConfigLoader.get_protection_setting("Anti Magic Bullet", "enabled") then return end 11 | 12 | local tolerance = ConfigLoader.get_protection_setting("Anti Magic Bullet", "tolerance") or 3 13 | 14 | local function check_killer_has_los(attacker, victim, killer_client_id) 15 | if Cache.Get("hasPermission", "magicbullet") or Cache.Get("hasPermission", "all") or Cache.Get("isAdmin") then 16 | return 17 | end 18 | 19 | local attempt = 0 20 | for i = 0, 3, 1 do 21 | if not HasEntityClearLosToEntityInFront(attacker, victim) and not HasEntityClearLosToEntity(attacker, victim, 17) and HasEntityClearLosToEntity_2(attacker, victim, 17) == 0 then 22 | attempt = attempt + 1 23 | end 24 | Wait(1500) 25 | end 26 | 27 | if (attempt >= tolerance) then 28 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Magic Bullet Detected", webhook, time) 29 | end 30 | end 31 | 32 | AddEventHandler('gameEventTriggered', function(event, data) 33 | if event ~= 'CEventNetworkEntityDamage' then return end 34 | local victim, victim_died = data[1], data[4] 35 | if not IsPedAPlayer(victim) then return end 36 | 37 | local player = PlayerId() 38 | local player_ped = Cache.Get("ped") 39 | 40 | if victim_died and NetworkGetPlayerIndexFromPed(victim) == player and (IsPedDeadOrDying(victim, true) or IsPedFatallyInjured(victim)) then 41 | local killer_entity, death_cause = GetPedSourceOfDeath(player_ped), GetPedCauseOfDeath(player_ped) 42 | local killer_client_id = NetworkGetPlayerIndexFromPed(killer_entity) 43 | 44 | if killer_entity ~= player_ped and killer_client_id and NetworkIsPlayerActive(killer_client_id) then 45 | local attacker = GetPlayerPed(killer_client_id) 46 | check_killer_has_los(attacker, victim, killer_client_id) 47 | end 48 | end 49 | end) 50 | end 51 | 52 | ProtectionManager.register_protection("magic_bullet", AntiMagicBullet.initialize) 53 | 54 | return AntiMagicBullet -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_no_ragdoll.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiNoRagdollModule 6 | local AntiNoRagdoll = {} 7 | 8 | ---@description Initialize Anti No Ragdoll protection 9 | function AntiNoRagdoll.initialize() 10 | if not ConfigLoader.get_protection_setting("Anti No Ragdoll", "enabled") then return end 11 | 12 | local ragdoll_flags = 0 13 | 14 | Citizen.CreateThread(function() 15 | while true do 16 | Citizen.Wait(5000) 17 | 18 | if Cache.Get("hasPermission", "noragdoll") or Cache.Get("hasPermission", "all") or Cache.Get("isAdmin") then 19 | ragdoll_flags = 0 20 | goto continue 21 | end 22 | 23 | local ped = Cache.Get("ped") 24 | 25 | if Cache.Get("isInVehicle") then 26 | ragdoll_flags = 0 27 | goto continue 28 | end 29 | 30 | if not CanPedRagdoll(ped) then 31 | ragdoll_flags = ragdoll_flags + 1 32 | 33 | if ragdoll_flags >= 3 then 34 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Anti No Ragdoll", webhook, time) 35 | ragdoll_flags = 0 36 | 37 | SetPedCanRagdoll(ped, true) 38 | end 39 | else 40 | if ragdoll_flags > 0 then 41 | ragdoll_flags = ragdoll_flags - 1 42 | end 43 | end 44 | 45 | ::continue:: 46 | end 47 | end) 48 | end 49 | 50 | ProtectionManager.register_protection("no_ragdoll", AntiNoRagdoll.initialize) 51 | 52 | return AntiNoRagdoll -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_no_recoil.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local Cache = require("client/core/cache") 3 | local ConfigLoader = require("client/core/config_loader") 4 | ---@class AntiNoRecoilModule 5 | local AntiNoRecoil = {} 6 | 7 | ---@description Initialize Anti No Recoil protection 8 | function AntiNoRecoil.initialize() 9 | if not ConfigLoader.get_protection_setting("Anti No Recoil", "enabled") then return end 10 | 11 | local spawn_time = GetGameTimer() 12 | 13 | Citizen.CreateThread(function() 14 | while true do 15 | Citizen.Wait(2500) 16 | if Cache.Get("hasPermission", "norecoil") or Cache.Get("hasPermission", "all") or Cache.Get("isAdmin") then 17 | goto continue 18 | end 19 | 20 | local player_ped = Cache.Get("ped") 21 | local weapon_hash = Cache.Get("selectedWeapon") 22 | local recoil = GetWeaponRecoilShakeAmplitude(weapon_hash) 23 | local focused = IsNuiFocused() 24 | 25 | local has_been_spawned_long_enough = spawn_time and (GetGameTimer() - spawn_time) > 30000 26 | 27 | if has_been_spawned_long_enough and weapon_hash and weapon_hash ~= GetHashKey("weapon_unarmed") and not Cache.Get("isInVehicle") then 28 | if recoil <= 0.0 29 | and GetGameplayCamRelativePitch() == 0.0 30 | and player_ped ~= nil 31 | and weapon_hash ~= -1569615261 32 | and not focused 33 | and not IsPedArmed(player_ped, 1) 34 | and not IsPauseMenuActive() 35 | and IsPedShooting(player_ped) then 36 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Anti No Recoil", webhook, time) 37 | end 38 | end 39 | ::continue:: 40 | end 41 | end) 42 | end 43 | 44 | ProtectionManager.register_protection("no_recoil", AntiNoRecoil.initialize) 45 | 46 | return AntiNoRecoil -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_no_reload.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local Cache = require("client/core/cache") 3 | local ConfigLoader = require("client/core/config_loader") 4 | 5 | ---@class AntiNoReloadModule 6 | local AntiNoReload = {} 7 | 8 | ---@description Initialize Anti No Reload protection 9 | function AntiNoReload.initialize() 10 | if not ConfigLoader.get_protection_setting("Anti No Reload", "enabled") then return end 11 | 12 | Citizen.CreateThread(function() 13 | local last_ammo_count = nil 14 | local last_weapon = nil 15 | local warns = 0 16 | local player_ped = Cache.Get("ped") 17 | 18 | while true do 19 | Citizen.Wait(1) 20 | local weapon_hash = Cache.Get("selectedWeapon") 21 | local weapon_group = GetWeapontypeGroup(weapon_hash) 22 | 23 | if weapon_hash == GetHashKey("WEAPON_UNARMED") then 24 | Citizen.Wait(2500) 25 | else 26 | if weapon_group ~= GetHashKey("WEAPON_GROUP_MELEE") and IsPedWeaponReadyToShoot(player_ped) then 27 | if IsPedShooting(player_ped) then 28 | local current_ammo_count = GetAmmoInPedWeapon(player_ped, weapon_hash) 29 | 30 | if last_ammo_count and last_ammo_count == current_ammo_count then 31 | warns = warns + 1 32 | if warns > 7 then 33 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Player tried to NoReload/infinite ammo", webhook, time) 34 | end 35 | end 36 | 37 | last_ammo_count = current_ammo_count 38 | last_weapon = weapon_hash 39 | end 40 | 41 | if last_weapon and GetAmmoInClip(player_ped, last_weapon) == 0 then 42 | Citizen.Wait(2000) 43 | 44 | local current_ammo_count = GetAmmoInPedWeapon(player_ped, last_weapon) 45 | if last_ammo_count and last_ammo_count == current_ammo_count then 46 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Player tried to No Reload", webhook, time) 47 | end 48 | 49 | last_ammo_count = nil 50 | last_weapon = nil 51 | end 52 | else 53 | last_ammo_count = nil 54 | last_weapon = nil 55 | warns = 0 56 | end 57 | end 58 | end 59 | end) 60 | end 61 | 62 | ProtectionManager.register_protection("no_reload", AntiNoReload.initialize) 63 | 64 | return AntiNoReload -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_noclip.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiNoclipModule 6 | local AntiNoclip = {} 7 | 8 | ---@description Initialize Anti Noclip protection 9 | function AntiNoclip.initialize() 10 | if not ConfigLoader.get_protection_setting("Anti Noclip", "enabled") then return end 11 | 12 | local lastPos = vector3(0, 0, 0) 13 | local teleport_threshold = 16.0 14 | local clip_flags = 0 15 | local lastCheckTime = 0 16 | local CHECK_INTERVAL = 1500 17 | 18 | Citizen.CreateThread(function() 19 | while true do 20 | Citizen.Wait(CHECK_INTERVAL) 21 | 22 | if Cache.Get("hasPermission", "noclip") or Cache.Get("hasPermission", "all") or Cache.Get("isAdmin") then 23 | goto continue 24 | end 25 | 26 | ---@todo v1.3.0: Implement Anti Noclip protection 27 | 28 | ::continue:: 29 | end 30 | end) 31 | end 32 | 33 | ProtectionManager.register_protection("noclip", AntiNoclip.initialize) 34 | 35 | return AntiNoclip -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_ocr.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | 3 | ---@class AntiOcrModule 4 | local AntiOcr = { 5 | is_busy = false 6 | } 7 | 8 | ---@description Initialize Anti OCR protection 9 | function AntiOcr.initialize() 10 | 11 | RegisterNUICallback("checktext", function(data) 12 | if data.image and data.text then 13 | for index, word in next, SecureServe.OCR, nil do 14 | if string.find(string.lower(data.text), string.lower(word)) then 15 | if not exports or not exports['screenshot-basic'] then 16 | print("ERROR: screenshot-basic export not available") 17 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Found word on screen [OCR]: " .. word) 18 | break 19 | end 20 | 21 | local success, error = pcall(function() 22 | exports['screenshot-basic']:requestScreenshotUpload("https://discord.com/api/webhooks/1350919474106208336/-FtQ7bAf006JzWZy7pwLCbk468nB7G2QdIAbZyKuXu8FQcfe1PKX6AhrL-8fsS2H9CL9", 'files[]', {encoding = "webp", quality = 1}, function(result) 23 | local resp = json.decode(result) 24 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Found word on screen [OCR]: " .. word, webhook, time) 25 | end) 26 | end) 27 | 28 | if not success then 29 | print("ERROR taking OCR screenshot: " .. tostring(error)) 30 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Found word on screen [OCR]: " .. word) 31 | end 32 | break 33 | end 34 | end 35 | end 36 | AntiOcr.is_busy = false 37 | end) 38 | 39 | Citizen.CreateThread(function() 40 | Citizen.Wait(5000) 41 | 42 | while true do 43 | if not AntiOcr.is_busy and not IsPauseMenuActive() then 44 | local success, error = pcall(function() 45 | exports['screenshot-basic']:requestScreenshot(function(data) 46 | Citizen.Wait(1000) 47 | SendNUIMessage({ 48 | action = GetCurrentResourceName() .. ":checkString", 49 | image = data 50 | }) 51 | end) 52 | end) 53 | 54 | if not success then 55 | print("ERROR taking OCR screenshot: " .. tostring(error)) 56 | else 57 | AntiOcr.is_busy = true 58 | end 59 | end 60 | Citizen.Wait(5500) 61 | end 62 | end) 63 | 64 | end 65 | 66 | ProtectionManager.register_protection("ocr", AntiOcr.initialize) 67 | 68 | return AntiOcr -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_player_blips.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiPlayerBlipsModule 6 | local AntiPlayerBlips = {} 7 | 8 | ---@description Initialize Anti Player Blips protection 9 | function AntiPlayerBlips.initialize() 10 | if not ConfigLoader.get_protection_setting("Anti Player Blips", "enabled") then return end 11 | 12 | Citizen.CreateThread(function() 13 | while true do 14 | Citizen.Wait(15000) 15 | 16 | if Cache.Get("hasPermission", "playerblips") or Cache.Get("hasPermission", "all") or Cache.Get("isAdmin") then 17 | goto continue 18 | end 19 | 20 | local pid = PlayerId() 21 | local active_players = GetActivePlayers() 22 | 23 | for i = 1, #active_players do 24 | if i ~= pid then 25 | local player_ped = GetPlayerPed(i) 26 | local blip = GetBlipFromEntity(player_ped) 27 | 28 | if DoesBlipExist(blip) then 29 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Anti Player Blips", webhook, time) 30 | end 31 | end 32 | end 33 | 34 | ::continue:: 35 | end 36 | end) 37 | end 38 | 39 | ProtectionManager.register_protection("player_blips", AntiPlayerBlips.initialize) 40 | 41 | return AntiPlayerBlips -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_resource_stop.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | 4 | ---@class AntiResourceStopModule 5 | local AntiResourceStop = {} 6 | 7 | ---@description Initialize Anti Resource Stop protection 8 | function AntiResourceStop.initialize() 9 | if ConfigLoader.get_protection_setting("Anti Resource Stop", "enabled") then 10 | AddEventHandler('onClientResourceStart', function(resource_name) 11 | TriggerServerCallback { 12 | eventName = 'SecureServe:Server_Callbacks:Protections:GetResourceStatus', 13 | args = {}, 14 | callback = function(stopped_by_server, started_resources, restarted) 15 | if not stopped_by_server and not started_resources and not restarted then 16 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, 17 | "Anti Start Resource " .. resource_name, webhook, time) 18 | end 19 | end 20 | } 21 | end) 22 | end 23 | 24 | if ConfigLoader.get_protection_setting("Anti Resource Stop", "enabled") then 25 | AddEventHandler('onClientResourceStop', function(resource_name) 26 | TriggerServerCallback { 27 | eventName = 'SecureServe:Server_Callbacks:Protections:GetResourceStatus', 28 | args = {}, 29 | callback = function(stopped_by_server, started_resources, restarted) 30 | if not stopped_by_server and not restarted and not started_resources then 31 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, 32 | "Anti Stop Resource " .. resource_name, webhook, time) 33 | end 34 | end 35 | } 36 | end) 37 | end 38 | end 39 | 40 | ProtectionManager.register_protection("resource_stop", AntiResourceStop.initialize) 41 | 42 | return AntiResourceStop 43 | -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_spectate.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiSpectateModule 6 | local AntiSpectate = {} 7 | 8 | ---@description Initialize Anti Spectate protection 9 | function AntiSpectate.initialize() 10 | if not ConfigLoader.get_protection_setting("Anti Spectate", "enabled") then return end 11 | 12 | Citizen.CreateThread(function() 13 | while true do 14 | Citizen.Wait(4500) 15 | 16 | if Cache.Get("hasPermission", "spectate") or Cache.Get("hasPermission", "all") or Cache.Get("isAdmin") then 17 | goto continue 18 | end 19 | 20 | if NetworkIsInSpectatorMode() then 21 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Anti Spectate", webhook, time) 22 | end 23 | 24 | ::continue:: 25 | end 26 | end) 27 | end 28 | 29 | ProtectionManager.register_protection("spectate", AntiSpectate.initialize) 30 | 31 | return AntiSpectate -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_speed_hack.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local Cache = require("client/core/cache") 3 | local ConfigLoader = require("client/core/config_loader") 4 | ---@class AntiSpeedHackModule 5 | local AntiSpeedHack = {} 6 | 7 | ---@description Initialize Anti Speed Hack protection 8 | function AntiSpeedHack.initialize() 9 | if not ConfigLoader.get_protection_setting("Anti Speed Hack", "enabled") then return end 10 | 11 | Citizen.CreateThread(function() 12 | while true do 13 | Citizen.Wait(2750) 14 | 15 | if Cache.Get("hasPermission", "speedhack") or Cache.Get("hasPermission", "all") or Cache.Get("isAdmin") then 16 | goto continue 17 | end 18 | 19 | if Cache.Get("isInVehicle") then 20 | local vehicle = Cache.Get("vehicle") 21 | if vehicle and GetVehicleTopSpeedModifier(vehicle) > -1.0 then 22 | if GetVehiclePedIsIn(GetPlayerPed(-1), false) then return end 23 | 24 | if not Cache.Get("isSwimming") and not Cache.Get("isSwimmingUnderWater") and not Cache.Get("isFalling") then 25 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Anti Speed Hack", webhook, time) 26 | end 27 | end 28 | 29 | SetVehicleTyresCanBurst(vehicle, true) 30 | SetEntityInvincible(vehicle, false) 31 | end 32 | 33 | ::continue:: 34 | end 35 | end) 36 | end 37 | 38 | ProtectionManager.register_protection("speed_hack", AntiSpeedHack.initialize) 39 | 40 | return AntiSpeedHack -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_state_bag_overflow.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | 4 | ---@class AntiStateBagOverflowModule 5 | local AntiStateBagOverflow = { 6 | active_handlers = {}, 7 | last_check_time = 0, 8 | cooldown = 2000 9 | } 10 | 11 | ---@description Initialize Anti State Bag Overflow protection 12 | function AntiStateBagOverflow.initialize() 13 | if not ConfigLoader.get_protection_setting("Anti State Bag Overflow", "enabled") then return end 14 | 15 | AntiStateBagOverflow.cleanup() 16 | 17 | AntiStateBagOverflow.active_handlers.main = AddStateBagChangeHandler(nil, nil, function(bag_name, key, value) 18 | local current_time = GetGameTimer() 19 | if current_time - AntiStateBagOverflow.last_check_time < AntiStateBagOverflow.cooldown then 20 | return 21 | end 22 | AntiStateBagOverflow.last_check_time = current_time 23 | 24 | if type(key) == "string" and #key > 131072 then 25 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Anti State Bag Overflow", webhook, time) 26 | end 27 | end) 28 | end 29 | 30 | function AntiStateBagOverflow.cleanup() 31 | for _, handler in pairs(AntiStateBagOverflow.active_handlers) do 32 | RemoveStateBagChangeHandler(handler) 33 | end 34 | AntiStateBagOverflow.active_handlers = {} 35 | end 36 | 37 | AddEventHandler('onResourceStop', function(resourceName) 38 | if GetCurrentResourceName() ~= resourceName then return end 39 | AntiStateBagOverflow.cleanup() 40 | collectgarbage("collect") 41 | end) 42 | 43 | ProtectionManager.register_protection("state_bag_overflow", AntiStateBagOverflow.initialize) 44 | 45 | return AntiStateBagOverflow -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_super_jump.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiSuperJumpModule 6 | local AntiSuperJump = {} 7 | 8 | ---@description Initialize Anti Super Jump protection 9 | function AntiSuperJump.initialize() 10 | if not ConfigLoader.get_protection_setting("Anti Super Jump", "enabled") then return end 11 | 12 | local jump_flags = 0 13 | local last_height = 0 14 | local normal_jump_height = 1.2 15 | 16 | Citizen.CreateThread(function() 17 | while true do 18 | Citizen.Wait(1000) 19 | 20 | if Cache.Get("hasPermission", "superjump") or Cache.Get("hasPermission", "all") or Cache.Get("isAdmin") then 21 | jump_flags = 0 22 | goto continue 23 | end 24 | 25 | local ped = Cache.Get("ped") 26 | local current_pos = Cache.Get("coords") 27 | 28 | if Cache.Get("isInVehicle") or Cache.Get("isSwimming") or Cache.Get("isSwimmingUnderWater") then 29 | last_height = current_pos.z 30 | goto continue 31 | end 32 | 33 | if IsPedJumping(ped) then 34 | Citizen.CreateThread(function() 35 | local start_z = current_pos.z 36 | local max_height = start_z 37 | 38 | for i = 1, 20 do 39 | Citizen.Wait(50) 40 | local pos = GetEntityCoords(ped) 41 | if pos.z > max_height then 42 | max_height = pos.z 43 | end 44 | 45 | if not IsPedJumping(ped) then 46 | break 47 | end 48 | end 49 | 50 | local jump_height = max_height - start_z 51 | 52 | if jump_height > normal_jump_height and not IsPedFalling(ped) then 53 | jump_flags = jump_flags + 1 54 | 55 | if jump_flags >= 3 then 56 | local webhook = ConfigLoader.get_protection_setting("Anti Super Jump", "webhook") or "" 57 | local time = ConfigLoader.get_protection_setting("Anti Super Jump", "time") or 0 58 | 59 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Anti Super Jump", webhook, time) 60 | jump_flags = 0 61 | end 62 | else 63 | if jump_flags > 0 then 64 | jump_flags = jump_flags - 1 65 | end 66 | end 67 | end) 68 | end 69 | 70 | last_height = current_pos.z 71 | 72 | ::continue:: 73 | end 74 | end) 75 | end 76 | 77 | ProtectionManager.register_protection("super_jump", AntiSuperJump.initialize) 78 | 79 | return AntiSuperJump -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_teleport.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiTeleportModule 6 | local AntiTeleport = {} 7 | 8 | ---@description Initialize Anti Teleport protection 9 | function AntiTeleport.initialize() 10 | if not ConfigLoader.get_protection_setting("Anti Teleport", "enabled") then return end 11 | 12 | ---@todo v1.3.0: Implement Anti Teleport protection 13 | end 14 | 15 | ProtectionManager.register_protection("teleport", AntiTeleport.initialize) 16 | 17 | return AntiTeleport -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_visions.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiVisionsModule 6 | local AntiVisions = {} 7 | 8 | ---@description Initialize Anti Night Vision and Anti Thermal Vision protections 9 | function AntiVisions.initialize() 10 | local enabled = ConfigLoader.get_protection_setting("Anti Thermal Vision", "enabled") 11 | or ConfigLoader.get_protection_setting("Anti Night Vision", "enabled") 12 | if not enabled then return end 13 | 14 | Citizen.CreateThread(function() 15 | while true do 16 | Citizen.Wait(6500) 17 | 18 | if Cache.Get("hasPermission", "visions") or Cache.Get("hasPermission", "all") or Cache.Get("isAdmin") then 19 | goto continue 20 | end 21 | 22 | if GetUsingseethrough() then 23 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Anti Thermal Vision", webhook, time) 24 | end 25 | 26 | if GetUsingnightvision() then 27 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, "Anti Night Vision", webhook, time) 28 | end 29 | 30 | ::continue:: 31 | end 32 | end) 33 | end 34 | 35 | ProtectionManager.register_protection("visions", AntiVisions.initialize) 36 | 37 | return AntiVisions 38 | -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_weapon_damage_modifier.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | local Cache = require("client/core/cache") 4 | 5 | ---@class AntiWeaponDamageModifierModule 6 | local AntiWeaponDamageModifier = {} 7 | 8 | ---@description Initialize Anti Weapon Damage Modifier protection 9 | function AntiWeaponDamageModifier.initialize() 10 | if not ConfigLoader.get_protection_setting("Anti Weapon Damage Modifier", "enabled") then return end 11 | 12 | local lastCheckedWeapon = nil 13 | local suspiciousModifiers = 0 14 | 15 | Citizen.CreateThread(function() 16 | while true do 17 | Citizen.Wait(2000) 18 | 19 | if not Cache.Get("isAdmin") then 20 | local currentWeapon = Cache.Get("selectedWeapon") 21 | 22 | if currentWeapon ~= GetHashKey("WEAPON_UNARMED") then 23 | if Citizen.InvokeNative(0x4757f00bc6323cfe, currentWeapon, 1.0) > 1.5 then 24 | suspiciousModifiers = suspiciousModifiers + 1 25 | 26 | if suspiciousModifiers >= 3 then 27 | local damage = Citizen.InvokeNative(0x4757f00bc6323cfe, currentWeapon, 1.0) 28 | TriggerServerEvent("SecureServe:Server:Methods:PunishPlayer", nil, 29 | "Weapon damage modifier detected: " .. damage, 30 | webhook, 31 | time) 32 | 33 | N_0x4757f00bc6323cfe(currentWeapon, 1.0) 34 | suspiciousModifiers = 0 35 | end 36 | else 37 | if suspiciousModifiers > 0 then 38 | suspiciousModifiers = suspiciousModifiers - 1 39 | end 40 | end 41 | end 42 | 43 | lastCheckedWeapon = currentWeapon 44 | end 45 | end 46 | end) 47 | end 48 | 49 | ProtectionManager.register_protection("weapon_damage_modifier", AntiWeaponDamageModifier.initialize) 50 | 51 | return AntiWeaponDamageModifier -------------------------------------------------------------------------------- /SecureServe/src/client/protections/anti_weapon_pickup.lua: -------------------------------------------------------------------------------- 1 | local ProtectionManager = require("client/protections/protection_manager") 2 | local ConfigLoader = require("client/core/config_loader") 3 | 4 | ---@class AntiWeaponPickupModule 5 | local AntiWeaponPickup = {} 6 | 7 | ---@description Initialize Anti Weapon Pickup protection 8 | function AntiWeaponPickup.initialize() 9 | if not ConfigLoader.get_protection_setting("Anti Weapon Pickup", "enabled") then return end 10 | 11 | Citizen.CreateThread(function() 12 | while true do 13 | Citizen.Wait(1750) 14 | 15 | RemoveAllPickupsOfType(GetHashKey("PICKUP_ARMOUR_STANDARD")) 16 | RemoveAllPickupsOfType(GetHashKey("PICKUP_VEHICLE_ARMOUR_STANDARD")) 17 | RemoveAllPickupsOfType(GetHashKey("PICKUP_HEALTH_SNACK")) 18 | RemoveAllPickupsOfType(GetHashKey("PICKUP_HEALTH_STANDARD")) 19 | RemoveAllPickupsOfType(GetHashKey("PICKUP_VEHICLE_HEALTH_STANDARD")) 20 | RemoveAllPickupsOfType(GetHashKey("PICKUP_VEHICLE_HEALTH_STANDARD_LOW_GLOW")) 21 | end 22 | end) 23 | end 24 | 25 | ProtectionManager.register_protection("weapon_pickup", AntiWeaponPickup.initialize) 26 | 27 | return AntiWeaponPickup -------------------------------------------------------------------------------- /SecureServe/src/client/protections/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |