├── README.md ├── client.lua ├── config.lua ├── fxmanifest.lua └── server.lua /README.md: -------------------------------------------------------------------------------- 1 | # ogsr 2 | simple gsr, ox_lib and ox_target, and ox_inventory dependent 3 | 4 | 5 | Basically drag and drop, job check depends solely on the target in the client.lua 6 | 7 | 8 | Join my discord for announcements and my other scripts, conversions, and snippets 9 | 10 | https://discord.gg/bJSW7k4aAP 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /client.lua: -------------------------------------------------------------------------------- 1 | 2 | local ped = cache.ped 3 | local shot = false 4 | local lastShot = 0 5 | local timeInWater = 0 6 | local beenInWater = false 7 | local GetGameTimer = GetGameTimer 8 | local inWater = false 9 | 10 | if LocalPlayer.state.shot then 11 | shot = true 12 | lastShot = LocalPlayer.state.lastShot 13 | end 14 | 15 | CreateThread(function() 16 | while true do 17 | Wait(100) 18 | local shot = LocalPlayer.state.shot 19 | if shot == true then 20 | if IsEntityInWater(ped) then 21 | if inWater == false then 22 | timeInWater = GetGameTimer() 23 | end 24 | beenInWater = true 25 | inWater = true 26 | else 27 | inWater = false 28 | beenInWater = false 29 | timeInWater = 0 30 | end 31 | end 32 | local timer = GetGameTimer() 33 | local lastShot = LocalPlayer.state.lastShot 34 | if shot and beenInWater and timer - timeInWater >= (Config.clearGSRinWater * 60 * 1000) then 35 | ClearPedBloodDamage(ped) 36 | ClearPedEnvDirt(ped) 37 | ResetPedVisibleDamage(ped) 38 | lib.notify({ 39 | description = 'GSR Washed off', 40 | type = 'error' 41 | }) 42 | LocalPlayer.state:set('shot', false, true) 43 | shot = false 44 | end 45 | if shot and timer - lastShot >= (Config.clearGSR * 60 * 1000) then 46 | lib.notify({ 47 | description = 'GSR has faded', 48 | type = 'error' 49 | }) 50 | LocalPlayer.state:set('shot', false, true) 51 | shot = false 52 | end 53 | end 54 | end) 55 | 56 | exports.ox_target:addGlobalPlayer({ 57 | { 58 | icon = '', 59 | label = 'GSR Test', 60 | groups = 'police', 61 | distance = 1.5, 62 | onSelect = function(data) 63 | TriggerServerEvent('gsrTest', GetPlayerServerId(NetworkGetPlayerIndexFromPed(data.entity))) 64 | end 65 | } 66 | }) 67 | 68 | -------------------------------------------------------------------------------- /config.lua: -------------------------------------------------------------------------------- 1 | Config = {} 2 | Config.clearGSR = 15 3 | Config.clearGSRinWater = 1 4 | 5 | 6 | -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'cerulean' 2 | games { 'gta5' } 3 | lua54 'yes' 4 | author 'testarossa' 5 | 6 | shared_script '@ox_lib/init.lua' 7 | 8 | server_scripts { 9 | 'config.lua', 10 | 'server.lua', 11 | } 12 | 13 | client_scripts { 14 | 'config.lua', 15 | 'bridge_cl.lua', 16 | "client.lua" 17 | } 18 | 19 | -------------------------------------------------------------------------------- /server.lua: -------------------------------------------------------------------------------- 1 | RegisterNetEvent('gsrTest', function(target) 2 | local src = source 3 | local ply = Player(target) 4 | if ply.state.shot == true then 5 | TriggerClientEvent('ox_lib:notify', src, {type = 'success', description = 'Test comes back POSITIVE (Has Shot)'}) 6 | else 7 | TriggerClientEvent('ox_lib:notify', src, {type = 'error', description = 'Test comes back NEGATIVE (Has Not Shot)'}) 8 | end 9 | end) 10 | 11 | RegisterNetEvent('ox_inventory:updateWeapon', function(action) 12 | if action ~= 'ammo' then return end 13 | local lastShot = GetGameTimer() 14 | Player(source).state:set('shot', true, true) 15 | Player(source).state:set('lastShot', lastShot, true) 16 | end) 17 | 18 | --------------------------------------------------------------------------------