forked from bndzor/lx-prop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prop.lua
373 lines (311 loc) · 13.6 KB
/
prop.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
local dropkey = 161 -- change this number based on the key you want to use to drop the item
function GlobalObject(object)
NetworkRegisterEntityAsNetworked(object)
local netid = ObjToNet(object)
SetNetworkIdExistsOnAllMachines(netid, true)
NetworkSetNetworkIdDynamic(netid, true)
SetNetworkIdCanMigrate(netid, false)
for i = 1, 255 do
SetNetworkIdSyncToPlayer(netid, i, true)
end
print("New networked object: " .. netid)
end -- not needed anymore
attachedPropPerm = 0
function removeAttachedPropPerm()
if DoesEntityExist(attachedPropPerm) then
DeleteEntity(attachedPropPerm)
attachedPropPerm = 0
end
end
RegisterCommand("TVmic", function(source, args, raw)
local arg = args[1]
if arg ~= nil then
TriggerEvent("XP:removeall")
else
TriggerEvent("attach:tvmic")
end
end, false)
RegisterCommand("boombox", function(source, args, raw)
local arg = args[1]
if arg ~= nil then
TriggerEvent("XP:removeall")
else
TriggerEvent("attach:boombox")
end
end, false)
RegisterCommand("briefcase", function(source, args, raw)
local arg = args[1]
if arg ~= nil then
TriggerEvent("XP:removeall")
else
TriggerEvent("attach:suitcase")
end
end, false)
RegisterNetEvent('XP:DestroyProp')
AddEventHandler('XP:DestroyProp', function()
removeAttachedPropPerm()
end)
local APPbone = 0
local APPx = 0.0
local APPy = 0.0
local APPz = 0.0
local APPxR = 0.0
local APPyR = 0.0
local APPzR = 0.0
local holdingPackage = false
RegisterNetEvent('XP:attachProp')
AddEventHandler('XP:attachProp', function(attachModelSent,boneNumberSent,x,y,z,xR,yR,zR)
--exports['mythic_notify']:DoHudText('inform', "Press 7 to drop or pickup the object. Do /RE to delete the prop") -- Add your own notification system here instead
removeAttachedPropPerm()
holdingPackage = true
attachModel = GetHashKey(attachModelSent)
boneNumber = boneNumberSent
SetCurrentPedWeapon(GetPlayerPed(-1), 0xA2719263)
local bone = GetPedBoneIndex(GetPlayerPed(-1), boneNumberSent)
RequestModel(attachModel)
while not HasModelLoaded(attachModel) do
Citizen.Wait(100)
end
attachedPropPerm = CreateObject(attachModel, 1.0, 1.0, 1.0, 1, 1, 0)
AttachEntityToEntity(attachedPropPerm, GetPlayerPed(-1), bone, x, y, z, xR, yR, zR, 1, 1, 0, 0, 2, 1)
APPbone = bone
APPx = x
APPy = y
APPz = z
APPxR = xR
APPyR = yR
APPzR = zR
end)
function loadAnimDict( dict )
while ( not HasAnimDictLoaded( dict ) ) do
RequestAnimDict( dict )
Citizen.Wait( 5 )
end
end
function randPickupAnim()
local randAnim = math.random(7)
loadAnimDict('random@domestic')
TaskPlayAnim(GetPlayerPed(-1),'random@domestic', 'pickup_low',5.0, 1.0, 1.0, 48, 0.0, 0, 0, 0)
end
Citizen.CreateThread( function()
while true do
if attachedPropPerm ~= 0 then
Citizen.Wait(1)
if IsDisabledControlJustPressed(0, dropkey) or (GetHashKey("WEAPON_UNARMED") ~= GetSelectedPedWeapon(GetPlayerPed(-1)) and holdingPackage) then
if not holdingPackage then
local dst = GetDistanceBetweenCoords(GetEntityCoords(attachedPropPerm) ,GetEntityCoords(GetPlayerPed(-1)),true)
if dst < 2 then
holdingPackage = not holdingPackage
randPickupAnim()
Citizen.Wait(1000)
PropCarryAnim()
ClearPedTasks(GetPlayerPed(-1))
ClearPedSecondaryTask(GetPlayerPed(-1))
AttachEntityToEntity(attachedPropPerm, GetPlayerPed(-1), APPbone, APPx, APPy, APPz, APPxR, APPyR, APPzR, 1, 1, 0, 0, 2, 1)
end
else
holdingPackage = not holdingPackage
ClearPedTasks(GetPlayerPed(-1))
ClearPedSecondaryTask(GetPlayerPed(-1))
randPickupAnim()
Citizen.Wait(500)
DetachEntity(attachedPropPerm)
end
end
else
Citizen.Wait(1)
end
end
end)
function PropCarryAnim()
-- add animations you want here for things like cameras
end
attachedProp = 0
function removeAttachedProp()
if DoesEntityExist(attachedProp) then
DeleteEntity(attachedProp)
attachedProp = 0
end
end
RegisterNetEvent('XP:destroyProp')
AddEventHandler('XP:destroyProp', function()
removeAttachedProp()
end)
--[[RegisterNetEvent('attachProp')
AddEventHandler('attachProp', function(attachModelSent,boneNumberSent,x,y,z,xR,yR,zR)
removeAttachedProp()
attachModel = GetHashKey(attachModelSent)
boneNumber = boneNumberSent
SetCurrentPedWeapon(GetPlayerPed(-1), 0xA2719263)
local bone = GetPedBoneIndex(GetPlayerPed(-1), boneNumberSent)
RequestModel(attachModel)
while not HasModelLoaded(attachModel) do
Citizen.Wait(100)
end
attachedProp = CreateObject(attachModel, 1.0, 1.0, 1.0, 1, 1, 0)
AttachEntityToEntity(attachedProp, GetPlayerPed(-1), bone, x, y, z, xR, yR, zR, 1, 1, 0, 0, 2, 1)
end)]]
attachedPropPhone = 0
function removeAttachedPropPhone()
if DoesEntityExist(attachedPropPhone) then
DeleteEntity(attachedPropPhone)
attachedPropPhone = 0
end
end
attachPropList = {
["test"] = {
["model"] = "prop_cs_brain_chunk", ["bone"] = 28422, ["x"] = 0.062,["y"] = 0.02,["z"] = 0.0,["xR"] = 0.0,["yR"] = 0.0, ["zR"] = 0.0
},
["cigar01"] = {
["model"] = "prop_cigar_03", ["bone"] = 28422, ["x"] = 0.062,["y"] = 0.02,["z"] = 0.0,["xR"] = 0.0,["yR"] = 0.0, ["zR"] = 0.0
},
["cig01"] = {
["model"] = "prop_amb_ciggy_01", ["bone"] = 28422, ["x"] = -0.024,["y"] = 0.0,["z"] = 0.0,["xR"] = 0.0,["yR"] = 0.0, ["zR"] = 0.0
},
["cig02"] = {
["model"] = "prop_amb_ciggy_01", ["bone"] = 58867, ["x"] = 0.06,["y"] = 0.0,["z"] = -0.02,["xR"] = 0.0,["yR"] = 0.0, ["zR"] = 90.0
},
["healthpack01"] = {
["model"] = "prop_ld_health_pack", ["bone"] = 28422, ["x"] = 0.18,["y"] = 0.0,["z"] = 0.0,["xR"] = 135.0,["yR"] = -100.0, ["zR"] = 0.0
},
["briefcase01"] = {
["model"] = "prop_ld_case_01", ["bone"] = 28422, ["x"] = 0.08,["y"] = 0.0,["z"] = 0.0,["xR"] = 315.0,["yR"] = 288.0, ["zR"] = 0.0
},
["cashcase01"] = {
["model"] = "prop_cash_case_01", ["bone"] = 28422, ["x"] = 0.05,["y"] = 0.0,["z"] = 0.0,["xR"] = 135.0,["yR"] = -100.0, ["zR"] = 0.0
},
["cashbag01"] = {
["model"] = "prop_cs_heist_bag_01", ["bone"] = 24816, ["x"] = 0.15,["y"] = -0.4,["z"] = -0.38,["xR"] = 90.0,["yR"] = 0.0, ["zR"] = 0.0
},
["notepad01"] = {
["model"] = "prop_notepad_01", ["bone"] = 60309, ["x"] = 0.0,["y"] = -0.0,["z"] = -0.0,["xR"] = 0.0,["yR"] = 0.0, ["zR"] = 0.0
},
["phone01"] = {
["model"] = "prop_player_phone_01", ["bone"] = 57005, ["x"] = 0.14,["y"] = 0.01,["z"] = -0.02,["xR"] = 110.0,["yR"] = 120.0, ["zR"] = -15.0
},
["tablet01"] = {
["model"] = "prop_cs_tablet", ["bone"] = 60309, ["x"] = 0.03,["y"] = 0.002,["z"] = -0.0,["xR"] = 10.0,["yR"] = 160.0, ["zR"] = 0.0
},
["pencil01"] = {
["model"] = "prop_pencil_01", ["bone"] = 58870, ["x"] = 0.04,["y"] = 0.0225,["z"] = 0.08,["xR"] = 320.0,["yR"] = 0.0, ["zR"] = 220.0
},
["drugpackage01"] = {
["model"] = "prop_meth_bag_01", ["bone"] = 28422, ["x"] = 0.1,["y"] = 0.0,["z"] = -0.01,["xR"] = 135.0,["yR"] = -100.0, ["zR"] = 40.0
},
["drugpackage02"] = {
["model"] = "prop_weed_bottle", ["bone"] = 28422, ["x"] = 0.09,["y"] = 0.0,["z"] = -0.03,["xR"] = 135.0,["yR"] = -100.0, ["zR"] = 40.0
},
["drugtest01"] = {
["model"] = "prop_cash_case_02", ["bone"] = 28422, ["x"] = -0.01,["y"] = -0.1,["z"] = -0.138,["xR"] = 0.0,["yR"] = 0.0, ["zR"] = 0.0
},
["box01"] = {
["model"] = "prop_cs_cardbox_01", ["bone"] = 28422, ["x"] = 0.01,["y"] = 0.01,["z"] = 0.0,["xR"] = -255.0,["yR"] = -120.0, ["zR"] = 40.0
},
["bomb01"] = {
["model"] = "prop_ld_bomb", ["bone"] = 28422, ["x"] = 0.22,["y"] = -0.01,["z"] = 0.0,["xR"] = -25.0,["yR"] = -100.0, ["zR"] = 0.0
},
["money01"] = {
["model"] = "prop_anim_cash_note", ["bone"] = 28422, ["x"] = 0.1,["y"] = 0.04,["z"] = 0.0,["xR"] = 25.0,["yR"] = 0.0, ["zR"] = 10.0
},
["armor01"] = {
["model"] = "prop_armour_pickup", ["bone"] = 28422, ["x"] = 0.3,["y"] = 0.01,["z"] = 0.0,["xR"] = 255.0,["yR"] = -90.0, ["zR"] = 10.0
},
["terd01"] = {
["model"] = "prop_big_shit_01", ["bone"] = 61839, ["x"] = 0.015,["y"] = 0.0,["z"] = -0.01,["xR"] = 3.0,["yR"] = -90.0, ["zR"] = 180.0
},
["boombox01"] = {
["model"] = "prop_boombox_01", ["bone"] = 28422, ["x"] = 0.2,["y"] = 0.0,["z"] = 0.0,["xR"] = -35.0,["yR"] = -100.0, ["zR"] = 0.0
},
["bowlball01"] = {
["model"] = "prop_bowling_ball", ["bone"] = 28422, ["x"] = 0.12,["y"] = 0.0,["z"] = 0.0,["xR"] = 75.0,["yR"] = 280.0, ["zR"] = -80.0
},
["bowlpin01"] = {
["model"] = "prop_bowling_pin", ["bone"] = 28422, ["x"] = 0.12,["y"] = 0.0,["z"] = 0.0,["xR"] = 75.0,["yR"] = 280.0, ["zR"] = -80.0
},
["crate01"] = {
["model"] = "prop_cs_cardbox_01", ["bone"] = 28422, ["x"] = 0.0,["y"] = 0.0,["z"] = 0.0,["xR"] = 0.0,["yR"] = 0.0, ["zR"] = 0.0
},
["tvcamera01"] = {
["model"] = "prop_v_cam_01", ["bone"] = 57005, ["x"] = 0.13,["y"] = 0.25,["z"] = -0.03,["xR"] = -85.0,["yR"] = 0.0, ["zR"] = -80.0
},
["boomMIKE01"] = {
["model"] = "prop_v_bmike_01", ["bone"] = 57005, ["x"] = 0.1,["y"] = 0.0,["z"] = -0.03,["xR"] = 85.0,["yR"] = 0.0, ["zR"] = 96.0
},
["minigameThermite"] = {
["model"] = "prop_oiltub_06", ["bone"] = 57005, ["x"] = 0.1,["y"] = 0.0,["z"] = -0.09,["xR"] = 145.0,["yR"] = 20.0, ["zR"] = 80.0
},
["minigameDrill"] = {
["model"] = "hei_prop_heist_drill", ["bone"] = 57005, ["x"] = 0.15,["y"] = 0.0,["z"] = -0.05,["xR"] = 0.0,["yR"] = 90.0, ["zR"] = 90.0
},
-- 18905 left hand - 57005 right hand
["tvmic01"] = {
["model"] = "p_ing_microphonel_01", ["bone"] = 18905, ["x"] = 0.1,["y"] = 0.05,["z"] = 0.0,["xR"] = -85.0,["yR"] = -80.0, ["zR"] = -80.0
},
["newspaper01"] = {
["model"] = "prop_cliff_paper", ["bone"] = 28422, ["x"] = -0.07,["y"] = 0.0,["z"] = 0.0,["xR"] = 90.0,["yR"] = 0.0, ["zR"] = 0.0
},
["golfbag01"] = {
["model"] = "prop_golf_bag_01", ["bone"] = 24816, ["x"] = 0.12,["y"] = -0.3,["z"] = 0.0,["xR"] = -75.0,["yR"] = 190.0, ["zR"] = 92.0
},
["golfputter01"] = {
["model"] = "prop_golf_putter_01", ["bone"] = 57005, ["x"] = 0.0,["y"] = -0.05,["z"] = 0.0,["xR"] = 90.0,["yR"] = -118.0, ["zR"] = 44.0
},
["golfiron01"] = {
["model"] = "prop_golf_iron_01", ["bone"] = 57005, ["x"] = 0.125,["y"] = 0.04,["z"] = 0.0,["xR"] = 90.0,["yR"] = -118.0, ["zR"] = 44.0
},
["golfiron03"] = {
["model"] = "prop_golf_iron_01", ["bone"] = 57005, ["x"] = 0.126,["y"] = 0.041,["z"] = 0.0,["xR"] = 90.0,["yR"] = -118.0, ["zR"] = 44.0
},
["golfiron05"] = {
["model"] = "prop_golf_iron_01", ["bone"] = 57005, ["x"] = 0.127,["y"] = 0.042,["z"] = 0.0,["xR"] = 90.0,["yR"] = -118.0, ["zR"] = 44.0
},
["golfiron07"] = {
["model"] = "prop_golf_iron_01", ["bone"] = 57005, ["x"] = 0.128,["y"] = 0.043,["z"] = 0.0,["xR"] = 90.0,["yR"] = -118.0, ["zR"] = 44.0
},
["golfwedge01"] = {
["model"] = "prop_golf_pitcher_01", ["bone"] = 57005, ["x"] = 0.17,["y"] = 0.04,["z"] = 0.0,["xR"] = 90.0,["yR"] = -118.0, ["zR"] = 44.0
},
["golfdriver01"] = {
["model"] = "prop_golf_driver", ["bone"] = 57005, ["x"] = 0.14,["y"] = 0.00,["z"] = 0.0,["xR"] = 160.0,["yR"] = -60.0, ["zR"] = 10.0
}
}
RegisterNetEvent('XP:attachItem')
AddEventHandler('XP:attachItem', function(item)
TriggerEvent("XP:attachProp",attachPropList[item]["model"], attachPropList[item]["bone"], attachPropList[item]["x"], attachPropList[item]["y"], attachPropList[item]["z"], attachPropList[item]["xR"], attachPropList[item]["yR"], attachPropList[item]["zR"])
end)
--tvmic01
RegisterNetEvent('attach:tvmic')
AddEventHandler('attach:tvmic', function()
TriggerEvent("XP:attachItem","tvmic01")
end)
--boomMIKE01
RegisterNetEvent('attach:tvcamera')
AddEventHandler('attach:tvcamera', function()
TriggerEvent("XP:attachItem","tvcamera01")
end)
RegisterNetEvent('attach:suitcase')
AddEventHandler('attach:suitcase', function()
TriggerEvent("XP:attachItem","briefcase01")
end)
RegisterNetEvent('attach:boombox')
AddEventHandler('attach:boombox', function()
TriggerEvent("XP:attachItem","boombox01")
end)
RegisterCommand("RE", function() -- remove entity
TriggerEvent("disabledWeapons",false)
TriggerEvent("XP:DestroyProp")
end, false)
RegisterNetEvent('XP:removeall')
AddEventHandler('XP:removeall', function()
TriggerEvent("disabledWeapons",false)
TriggerEvent("XP:DestroyProp")
end)
local function errorMsg(msg)
TriggerEvent("chatMessage", "Error", {255, 0, 0}, msg)
end
local disabledWeapons = false
RegisterNetEvent("disabledWeapons")
AddEventHandler("disabledWeapons", function(sentinfo)
SetCurrentPedWeapon(GetPlayerPed(-1), GetHashKey("weapon_unarmed"), 1)
disabledWeapons = sentinfo
end)