Main/resources/[jobs]/[civ]/gg_hunting/client/client.lua
2025-06-07 08:51:21 +02:00

127 lines
No EOL
5.1 KiB
Lua

local cachedPurchase = false
RegisterNetEvent('gg_hunting:client:openMenu', function(data)
-- Licenses Checked Here.
if Config.HuntingLicense.requireLicense and not cachedPurchase then
local hasLicense = lib.callback.await("gg_hunting:server:checkHuntingLicense", false)
cachedPurchase = hasLicense
if not hasLicense then
local alert = lib.alertDialog({
header = i18n.translations[i18n.language].AlertMenus.purchaseHuntingLicense,
content = string.format(i18n.translations[i18n.language].AlertMenus.purchaseHuntingLicenseContent, Config.HuntingLicense.licenseCost),
centered = true,
cancel = true
})
if alert == "confirm" then
local boughtLicense = lib.callback.await("gg_hunting:server:purchaseHuntingLicense", false)
if not boughtLicense then
Notifyx.NotifyPlayer({msg = i18n.translations[i18n.language].Notifications.error_money, status = "error", timeout = 5000})
return
end
cachedPurchase = boughtLicense
else
return
end
end
end
-- Hunting Menus opened Here
if distanceCheck(data.coords) then
if data.menu == "hunting_menu" then
local success = lib.callback.await("gg_hunting:server:getHuntingLodgeMenuData", false)
if not success then return end
if success.level < data.table.levelReq then Notifyx.NotifyPlayer({msg = i18n.translations[i18n.language].Notifications.error_level, status = "error", timeout = 5000}) return end
openLodgeMenu(success)
elseif data.menu == "meat_locker" then
local success = lib.callback.await("gg_hunting:server:getHuntingLodgeMenuData", false)
if not success then return end
if success.level < data.table.levelReq then Notifyx.NotifyPlayer({msg = i18n.translations[i18n.language].Notifications.error_level, status = "error", timeout = 5000}) return end
openMeatLocker(success)
elseif data.menu == "illegalhunter_menu" then
local success = lib.callback.await("gg_hunting:server:getHuntingLodgeMenuData", false)
if not success then return end
if success.level < data.table.levelReq then Notifyx.NotifyPlayer({msg = i18n.translations[i18n.language].Notifications.error_level, status = "error", timeout = 5000}) return end
openIllegalHunter(success)
end
end
end)
RegisterNetEvent('gg_hunting:client:notify', function(data)
Notifyx.NotifyPlayer({msg = data.message, status = data.result, timeout = 5000})
end)
-- For Users Who Need to Delete Vehicles With Parking Script
RegisterNetEvent('gg_hunting:client:returnhuntingvehicle', function(plate)
local entity = GetVehicleFromPlate(plate)
DeleteVehiclesByPlate(plate)
Framework.removeVehicleKeys({plate = plate})
if DoesEntityExist(entity) then
RemoveVehicle(entity)
end
end)
-- Just ensure however you want to do the minigame it returns true or false.
function butcherMiniGame(checkForHuntingKnife, entity)
local bloodEffect, particleDict = "blood_mist", "core"
RequestNamedPtfxAsset(particleDict)
while not HasNamedPtfxAssetLoaded(particleDict) do Citizen.Wait(10) end
UseParticleFxAssetNextCall(particleDict)
RequestAnimDict("amb@medic@standing@tendtodead@idle_a")
while not HasAnimDictLoaded("amb@medic@standing@tendtodead@idle_a") do
Wait(0)
end
for x = 1, checkForHuntingKnife do
-- We do the minigame once and it loops through 3 - 5 times depending on their hunting knife.
local skillSuccess = lib.skillCheck({'easy'}, {'w', 'a', 's', 'd'})
if not skillSuccess then
return false
end
performCuttingAnimation()
Wait(2000)
UseParticleFxAssetNextCall(particleDict)
StartParticleFxLoopedOnEntity(bloodEffect, entity, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, false, false, false)
end
return true
end
local shoot_timeout = false
AddEventHandler('gameEventTriggered', function (name, args)
if name == 'CEventNetworkEntityDamage' then
local victim, culprit, weapon, baseDamage, headshot, death = args[1], args[2], args[7], args[4], args[11], args[6]
if victim ~= PlayerPedId() then return end
local rifleHash = GetHashKey("WEAPON_HUNTINGRIFLE")
if weapon == rifleHash then
if shoot_timeout then
return
end
shoot_timeout = true
local health = GetEntityHealth(victim)
if headshot == 1 then
local newHealth = health + 3
SetEntityHealth(victim, newHealth)
else
local newHealth = health + 1
SetEntityHealth(victim, newHealth)
end
CreateThread(function()
Wait(500)
shoot_timeout = false
end)
end
end
end)