-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.lua
32 lines (29 loc) · 1.03 KB
/
server.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
RegisterServerEvent("toggleHandOnHolster")
AddEventHandler("toggleHandOnHolster", function()
local player = source
local holsterStatus = GetPlayerHolsterStatus(player)
if holsterStatus == "on" then
SetPlayerHolsterStatus(player, "off")
else
SetPlayerHolsterStatus(player, "on")
end
end)
function GetPlayerHolsterStatus(player)
local holsterStatus = "off"
if GetPedDrawableVariation(GetPlayerPed(player), 7) ~= 0 then
holsterStatus = "on"
end
return holsterStatus
end
function SetPlayerHolsterStatus(player, status)
local drawable, texture = 0, 0
if status == "on" then
drawable, texture = GetHashKey("WEAPON_PISTOL"), GetHashKey("COMPONENT_AT_PI_FLSH")
end
SetPedComponentVariation(GetPlayerPed(player), 7, drawable, texture, 0)
end
RegisterServerEvent("player:setHolsterStatus")
AddEventHandler("player:setHolsterStatus", function(status)
local source = source
TriggerClientEvent("player:setHolsterStatus", source, status)
end)