This repository was archived by the owner on Mar 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathclient.lua
More file actions
82 lines (69 loc) · 2.29 KB
/
client.lua
File metadata and controls
82 lines (69 loc) · 2.29 KB
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
local shieldActive = false
local shieldEntity = nil
local hadPistol = false
-- ANIM
local animDict = "combat@gestures@gang@pistol_1h@beckon"
local animName = "0"
local prop = "prop_ballistic_shield"
local pistol = GetHashKey("WEAPON_PISTOL")
RegisterCommand("shield", function()
if shieldActive then
DisableShield()
else
EnableShield()
end
end, false)
function EnableShield()
shieldActive = true
local ped = GetPlayerPed(-1)
local pedPos = GetEntityCoords(ped, false)
RequestAnimDict(animDict)
while not HasAnimDictLoaded(animDict) do
Citizen.Wait(100)
end
TaskPlayAnim(ped, animDict, animName, 8.0, -8.0, -1, (2 + 16 + 32), 0.0, 0, 0, 0)
RequestModel(GetHashKey(prop))
while not HasModelLoaded(GetHashKey(prop)) do
Citizen.Wait(100)
end
local shield = CreateObject(GetHashKey(prop), pedPos.x, pedPos.y, pedPos.z, 1, 1, 1)
shieldEntity = shield
AttachEntityToEntity(shieldEntity, ped, GetEntityBoneIndexByName(ped, "IK_L_Hand"), 0.0, -0.05, -0.10, -30.0, 180.0, 40.0, 0, 0, 1, 0, 0, 1)
SetWeaponAnimationOverride(ped, GetHashKey("Gang1H"))
if HasPedGotWeapon(ped, pistol, 0) or GetSelectedPedWeapon(ped) == pistol then
SetCurrentPedWeapon(ped, pistol, 1)
hadPistol = true
else
GiveWeaponToPed(ped, pistol, 300, 0, 1)
SetCurrentPedWeapon(ped, pistol, 1)
hadPistol = false
end
SetEnableHandcuffs(ped, true)
end
function DisableShield()
local ped = GetPlayerPed(-1)
DeleteEntity(shieldEntity)
ClearPedTasksImmediately(ped)
SetWeaponAnimationOverride(ped, GetHashKey("Default"))
if not hadPistol then
RemoveWeaponFromPed(ped, pistol)
end
SetEnableHandcuffs(ped, false)
hadPistol = false
shieldActive = false
end
Citizen.CreateThread(function()
while true do
if shieldActive then
local ped = GetPlayerPed(-1)
if not IsEntityPlayingAnim(ped, animDict, animName, 1) then
RequestAnimDict(animDict)
while not HasAnimDictLoaded(animDict) do
Citizen.Wait(100)
end
TaskPlayAnim(ped, animDict, animName, 8.0, -8.0, -1, (2 + 16 + 32), 0.0, 0, 0, 0)
end
end
Citizen.Wait(500)
end
end)