-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.lua
109 lines (89 loc) · 3.05 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
active = false
ESX = nil
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(250)
end
while ESX.GetPlayerData().job == nil do
Citizen.Wait(250)
end
ESX.PlayerData = ESX.GetPlayerData()
end)
Citizen.CreateThread(function()
while true do
if IsControlJustPressed(0, 289) then
TriggerServerEvent('requestInventory')
end
Citizen.Wait(0)
end
end)
RegisterNUICallback('trigger', function(data, cb)
if data.args[2] == "useInventoryItem" then
TriggerServerEvent("useInventoryItem", data.args[3])
end
if data.args[2] == "giveInventoryItem" then
TriggerEvent("giveInventoryItem", data.args[3], data.args[4])
end
if data.args[2] == "dropInventoryItem" then
TriggerEvent("dropInventoryItem", data.args[3], data.args[4])
end
cb('ok')
end)
RegisterNetEvent('responseInventory')
AddEventHandler('responseInventory', function(data)
openMenu(data)
end)
function loadAnimDict(dict)
while (not HasAnimDictLoaded(dict)) do
RequestAnimDict(dict)
Citizen.Wait(5)
end
end
RegisterNetEvent('giveInventoryItem')
AddEventHandler('giveInventoryItem', function(name, count)
if tonumber(count) > 0 then
local playerPed = GetPlayerPed(-1)
loadAnimDict('anim@mp_snowball')
local player, dist = ESX.Game.GetClosestPlayer()
if player == -1 or dist > 3.0 then
ESX.ShowNotification('Es ist keine Person in der Nähe')
else
TaskPlayAnim(PlayerPedId(), 'anim@mp_snowball', 'pickup_snowball', 8.0, -1, -1, 0, 1, 0, 0, 0)
Citizen.Wait(1300)
ClearPedTasksImmediately(playerPed)
TriggerServerEvent('giveInventoryItem', name, count, GetPlayerServerId(player))
ESX.ShowNotification(("Du hast jemanden %sx %s zugesteckt"):format(count, name))
end
else
ESX.ShowNotification("pls dont dupe :(!")
end
end)
RegisterNetEvent('dropInventoryItem')
AddEventHandler('dropInventoryItem', function(name, count)
if tonumber(count) > 0 then
local playerPed = GetPlayerPed(-1)
loadAnimDict('anim@mp_snowball')
local player, dist = ESX.Game.GetClosestPlayer()
TaskPlayAnim(PlayerPedId(), 'anim@mp_snowball', 'pickup_snowball', 8.0, -1, -1, 0, 1, 0, 0, 0)
Citizen.Wait(1300)
ClearPedTasksImmediately(playerPed)
TriggerServerEvent('dropInventoryItem', name, count)
ESX.ShowNotification(("Du wirfst %sx %s weg"):format(count, name))
else
ESX.ShowNotification("pls dont dupe :(!")
end
end)
RegisterNUICallback('close', function(data, cb)
closeMenu()
end)
function openMenu(data)
SendNUIMessage({
action = "open",
data = data
})
SetNuiFocus(true, true)
end
function closeMenu()
SetNuiFocus(false, false)
end