1
+ --[[
2
+ Cops_FiveM - A cops script for FiveM RP servers.
3
+ Copyright (C) 2018 FiveM-Scripts
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+ You should have received a copy of the GNU Affero General Public License
14
+ along with Cops_FiveM in the file "LICENSE". If not, see <http://www.gnu.org/licenses/>.
15
+ ]]
16
+
1
17
local buttonsCategories = {}
2
18
local buttonWeaponList = {}
3
19
@@ -14,53 +30,99 @@ function load_armory()
14
30
buttonsCategories [# buttonsCategories + 1 ] = {name = i18n .translate (" armory_add_bulletproof_vest_title" ), func = " addBulletproofVest" , params = " " }
15
31
buttonsCategories [# buttonsCategories + 1 ] = {name = i18n .translate (" armory_remove_bulletproof_vest_title" ), func = " removeBulletproofVest" , params = " " }
16
32
buttonsCategories [# buttonsCategories + 1 ] = {name = i18n .translate (" armory_weapons_list" ), func = " openWeaponListMenu" , params = " " }
33
+ buttonsCategories [# buttonsCategories + 1 ] = {name = " Close" , func = " CloseArmory" , params = " " }
17
34
18
- buttonWeaponList [# buttonWeaponList + 1 ] = {name = i18n .translate (" WEAPON_COMBATPISTOL" ), func = ' giveCombatPistol' , params = " " }
19
- buttonWeaponList [# buttonWeaponList + 1 ] = {name = i18n .translate (" WEAPON_PISTOL50" ), func = ' givePistol50' , params = " " }
20
- buttonWeaponList [# buttonWeaponList + 1 ] = {name = i18n .translate (" WEAPON_PUMPSHOTGUN" ), func = ' givePumpShotgun' , params = " " }
21
-
22
- buttonWeaponList [# buttonWeaponList + 1 ] = {name = i18n .translate (" WEAPON_ASSAULTSMG" ), func = ' giveAssaultSmg' , params = " " }
23
- buttonWeaponList [# buttonWeaponList + 1 ] = {name = i18n .translate (" WEAPON_ASSAULTSHOTGUN" ), func = ' giveAssaultShotgun' , params = " " }
24
- buttonWeaponList [# buttonWeaponList + 1 ] = {name = i18n .translate (" WEAPON_HEAVYSNIPER" ), func = ' giveHeavySniper' , params = " " }
35
+ for k ,v in pairs (weapons ) do
36
+ buttonWeaponList [# buttonWeaponList + 1 ] = {name = tostring (v .name ), func = ' GiveCustomWeapon' , params = tostring (v .hash )}
37
+ end
25
38
end
26
39
27
40
local hashSkin = GetHashKey (" mp_m_freemode_01" )
28
41
42
+ function createArmoryPed ()
43
+ if not DoesEntityExist (armoryPed ) then
44
+ local model = GetHashKey (" s_m_y_cop_01" )
45
+
46
+ RequestModel (model )
47
+ while not HasModelLoaded (model ) do
48
+ Wait (0 )
49
+ end
50
+
51
+ local armoryPed = CreatePed (26 , model , 454.165 , - 979.999 , 30.690 , 92.298 , false , false )
52
+ SetEntityInvincible (armoryPed , true )
53
+ TaskTurnPedToFaceEntity (armoryPed , PlayerId (), - 1 )
54
+
55
+ return armoryPed
56
+ end
57
+ end
58
+
29
59
function giveBasicKit ()
30
60
GiveWeaponToPed (PlayerPedId (), GetHashKey (" WEAPON_STUNGUN" ), - 1 , true , true )
31
61
GiveWeaponToPed (PlayerPedId (), GetHashKey (" WEAPON_NIGHTSTICK" ), - 1 , true , true )
32
62
GiveWeaponToPed (PlayerPedId (), GetHashKey (" WEAPON_FLASHLIGHT" ), 200 , true , true )
63
+
64
+ PlaySoundFrontend (- 1 , " PICK_UP" , " HUD_FRONTEND_DEFAULT_SOUNDSET" , true )
33
65
end
34
66
35
67
function giveBasicPrisonKit ()
36
68
GiveWeaponToPed (PlayerPedId (), GetHashKey (" WEAPON_PISTOL50" ), - 1 , true , true )
37
69
GiveWeaponToPed (PlayerPedId (), GetHashKey (" WEAPON_STUNGUN" ), - 1 , true , true )
38
70
GiveWeaponToPed (PlayerPedId (), GetHashKey (" WEAPON_NIGHTSTICK" ), 200 , true , true )
39
71
GiveWeaponToPed (PlayerPedId (), GetHashKey (" WEAPON_FLASHLIGHT" ), 200 , true , true )
72
+
73
+ PlaySoundFrontend (- 1 , " PICK_UP" , " HUD_FRONTEND_DEFAULT_SOUNDSET" , true )
40
74
end
41
75
42
76
function addBulletproofVest ()
43
- Citizen .CreateThread (function ()
44
- if (config .enableOutfits == true ) then
45
- if (GetEntityModel (PlayerPedId ()) == hashSkin ) then
46
- SetPedComponentVariation (PlayerPedId (), 9 , 4 , 1 , 2 )
47
- else
48
- SetPedComponentVariation (PlayerPedId (), 9 , 6 , 1 , 2 )
49
- end
77
+ if (config .enableOutfits == true ) then
78
+ if (GetEntityModel (PlayerPedId ()) == hashSkin ) then
79
+ SetPedComponentVariation (PlayerPedId (), 9 , 4 , 1 , 2 )
80
+ else
81
+ SetPedComponentVariation (PlayerPedId (), 9 , 6 , 1 , 2 )
50
82
end
51
- SetPedArmour (PlayerPedId (), 100 )
52
- end )
83
+ end
84
+
85
+ SetPedArmour (PlayerPedId (), 100 )
86
+ PlaySoundFrontend (- 1 , " PICK_UP" , " HUD_FRONTEND_DEFAULT_SOUNDSET" , true )
53
87
end
54
88
55
89
function removeBulletproofVest ()
56
- Citizen .CreateThread (function ()
57
- if (config .enableOutfits == true ) then
58
- SetPedComponentVariation (PlayerPedId (), 9 , 0 , 1 , 2 )
59
- end
60
- SetPedArmour (PlayerPedId (), 0 )
61
- end )
90
+ if (config .enableOutfits == true ) then
91
+ SetPedComponentVariation (PlayerPedId (), 9 , 0 , 1 , 2 )
92
+ end
93
+
94
+ SetPedArmour (PlayerPedId (), 0 )
95
+ PlaySoundFrontend (- 1 , " PICK_UP" , " HUD_FRONTEND_DEFAULT_SOUNDSET" , true )
96
+ end
97
+
98
+ function GiveCustomWeapon (weaponData )
99
+ GiveWeaponToPed (PlayerPedId (), GetHashKey (weaponData ), - 1 , false , true )
100
+ PlaySoundFrontend (- 1 , " PICK_UP" , " HUD_FRONTEND_DEFAULT_SOUNDSET" , true )
101
+ end
102
+
103
+ function CloseArmory ()
104
+ CloseMenu ()
105
+
106
+ RenderScriptCams (false , 1 , 1000 , 1 , 0 , 0 )
107
+ SetCamActive (ArmoryRoomCam , false )
108
+ DestroyCam (ArmoryRoomCam , true )
109
+
110
+ Citizen .Wait (500 )
111
+ DoScreenFadeOut (500 )
112
+ Citizen .Wait (600 )
113
+
114
+ if DoesEntityExist (armoryPed ) then
115
+ DeleteEntity (armoryPed )
116
+ end
117
+
118
+ FreezeEntityPosition (PlayerPedId (), false )
119
+ SetEntityCoords (PlayerPedId (), Lx , Ly , Lz )
120
+
121
+ Citizen .Wait (500 )
122
+ DoScreenFadeIn (500 )
62
123
end
63
124
125
+
64
126
function openWeaponListMenu ()
65
127
CloseMenu ()
66
128
SendNUIMessage ({
@@ -73,35 +135,6 @@ function openWeaponListMenu()
73
135
anyMenuOpen .isActive = true
74
136
end
75
137
76
- function giveCombatPistol ()
77
- GiveWeaponToPed (PlayerPedId (), GetHashKey (" WEAPON_COMBATPISTOL" ), - 1 , true , true )
78
- GiveWeaponComponentToPed (PlayerPedId (), GetHashKey (" WEAPON_COMBATPISTOL" ), GetHashKey (" COMPONENT_AT_PI_FLSH" ))
79
- end
80
-
81
- function givePistol50 ()
82
- GiveWeaponToPed (PlayerPedId (), GetHashKey (" WEAPON_PISTOL50" ), - 1 , true , true )
83
- GiveWeaponComponentToPed (PlayerPedId (), GetHashKey (" WEAPON_PISTOL50" ), GetHashKey (" COMPONENT_AT_PI_FLSH" ))
84
- end
85
-
86
- function givePumpShotgun ()
87
- GiveWeaponToPed (PlayerPedId (), GetHashKey (" WEAPON_PUMPSHOTGUN" ), - 1 , true , true )
88
- GiveWeaponComponentToPed (PlayerPedId (), GetHashKey (" WEAPON_PUMPSHOTGUN" ), GetHashKey (" COMPONENT_AT_AR_FLSH" ))
89
- end
90
-
91
- function giveAssaultSmg ()
92
- GiveWeaponToPed (PlayerPedId (), GetHashKey (" WEAPON_ASSAULTSMG" ), - 1 , true , true )
93
- GiveWeaponComponentToPed (PlayerPedId (), GetHashKey (" WEAPON_ASSAULTSMG" ), GetHashKey (" COMPONENT_AT_AR_FLSH" ))
94
- end
95
-
96
- function giveAssaultShotgun ()
97
- GiveWeaponToPed (PlayerPedId (), GetHashKey (" WEAPON_ASSAULTSHOTGUN" ), - 1 , true , true )
98
- GiveWeaponComponentToPed (PlayerPedId (), GetHashKey (" WEAPON_ASSAULTSHOTGUN" ), GetHashKey (" COMPONENT_AT_AR_FLSH" ))
99
- end
100
-
101
- function giveHeavySniper ()
102
- GiveWeaponToPed (PlayerPedId (), GetHashKey (" WEAPON_HEAVYSNIPER" ), - 1 , true , true )
103
- end
104
-
105
138
function OpenArmory ()
106
139
if ((anyMenuOpen .menuName ~= " armory" and anyMenuOpen .menuName ~= " armory-weapon_list" ) and not anyMenuOpen .isActive ) then
107
140
SendNUIMessage ({
0 commit comments