This repository has been archived by the owner on Jul 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.lua
68 lines (60 loc) · 2.25 KB
/
client.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
local QBCore = exports['qb-core']:GetCoreObject()
local models = {
'a_c_deer',
'a_c_boar',
'a_c_mtlion',
'a_c_coyote',
'a_c_rabbit_01',
'a_c_cow',
'a_c_pig'
}
CreateThread(function()
exports['qb-target']:AddTargetModel(models, {
options = {
{
type = "client",
action = function(entity)
TriggerEvent('rn-hunting:client:Processing', entity)
end,
icon = 'fas fa-solid fa-paw',
label = Lang:t('task.process'),
canInteract = function(entity)
if IsPedOnFoot(PlayerPedId()) and IsPedDeadOrDying(entity) and (GetSelectedPedWeapon(PlayerPedId()) == GetHashKey('weapon_knife') or GetSelectedPedWeapon(PlayerPedId()) == GetHashKey('weapon_dagger') or GetSelectedPedWeapon(PlayerPedId()) == GetHashKey('weapon_switchblade')) then return true end
return false
end,
}
},
distance = 1.5,
}
)
end)
RegisterNetEvent('rn-hunting:client:Processing', function(entity)
if NetworkGetPlayerIndexFromPed(PlayerPedId()) == NetworkGetEntityOwner(entity) then
QBCore.Functions.Progressbar('processAnimal', Lang:t('info.process'), 30000, false, true, {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
}, {
animDict = 'amb@world_human_gardener_plant@male@base',
anim = 'base',
flags = 1,
}, {}, {}, function() -- Done
StopAnimTask(PlayerPedId(), 'amb@world_human_gardener_plant@male@base', 'base', 1.0)
local meat
if GetEntityModel(entity) == GetHashKey('a_c_pig') then
meat = 'pork'
elseif GetEntityModel(entity) == GetHashKey('a_c_cow') then
meat = 'beef'
else
meat = 'meat'
end
TriggerServerEvent('rn-hunting:server:Reward', meat)
DeleteEntity(entity)
end, function() -- Cancel
StopAnimTask(PlayerPedId(), 'amb@world_human_gardener_plant@male@base', 'base', 1.0)
end)
else
QBCore.Functions.Notify(Lang:t('error.owner'), 'error')
end
end)