This repository was archived by the owner on Nov 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.lua
More file actions
677 lines (605 loc) · 21.1 KB
/
client.lua
File metadata and controls
677 lines (605 loc) · 21.1 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
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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
-- VAR
local AllowedAuto = {
[GetHashKey('GROUP_RIFLE')] = true,
[GetHashKey('GROUP_SMG')] = true,
}
-- Don't change these!
local healCooldown = false
local armorCooldown = false
local firstJoin = true
local Weapons = {}
local Constants = {
SEMI_AUTO = 1,
BURST_FIRE = 2,
FULL_AUTO = 3,
}
DoorIndex = {
['driver'] = 1,
['left'] = 1,
['passenger'] = 2,
['right'] = 2,
['rear left passenger'] = 3,
['rear left'] = 3,
['rear right passenger'] = 4,
['rear right'] = 4,
['hood'] = 5,
['bonnet'] = 5,
['trunk'] = 6,
['boot'] = 6,
}
-- INIT
DistantCopCarSirens(false) -- Disables distant cop car sirens
SetFlashLightKeepOnWhileMoving(true) -- Keep weapon flashlight on
SetWeaponsNoAutoreload(true) -- Stop automatic reloads
SetWeaponsNoAutoswap(true) -- Stop automatic swap weapon on empty
DisableIdleCamera(true) -- Stop Idle Cam
-- LOOP 0
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
SetArtificialLightsStateAffectsVehicles(false) -- Re-enables vehicle lights during blackout mode
HideHudComponentThisFrame(14) -- Hide Reticule
HideHudComponentThisFrame(2) -- Hide Ammo HUD
-- decrease dmg output of taser & baton
SetWeaponDamageModifierThisFrame(GetHashKey('WEAPON_STUNGUN'), .1)
SetWeaponDamageModifierThisFrame(GetHashKey('WEAPON_NIGHTSTICK'), .1)
SetWeaponDamageModifierThisFrame(GetHashKey('WEAPON_BEANBAG'), .1)
SetWeaponDamageModifierThisFrame(GetHashKey('WEAPON_BATON'), .01)
-- Disable combat rolling & Climbing whilst aiming
-- CREDIT: https://github.com/TFNRP/framework
if IsPlayerFreeAiming(PlayerId()) then
DisableControlAction(0, 22, true)
end
-- disable pistol-whip
-- CREDIT: https://github.com/TFNRP/framework
if IsPedArmed(PlayerPedId(), 6) and not IsPedInAnyVehicle(PlayerPedId()) then
DisableControlAction(1, 140, true)
DisableControlAction(1, 141, true)
DisableControlAction(1, 142, true)
end
-- Weapon Stuff
-- Credit: https://github.com/TFNRP/WeaponControl
end
end)
-- LOOP 500
Citizen.CreateThread(function()
while true do
-- Hide radar when on foot
if HideMinimapOnFoot then
local radarEnabled = IsRadarEnabled()
if not IsPedInAnyVehicle(PlayerPedId()) and radarEnabled then
DisplayRadar(false)
elseif IsPedInAnyVehicle(PlayerPedId()) and not radarEnabled then
DisplayRadar(true)
end
end
-- Loop Wait 500ms
Citizen.Wait(500)
end
end)
-- SHOW MESSAGE ON JOIN
AddEventHandler("playerSpawned", function(spawn)
if firstJoin then
Citizen.Wait(2500)
PlaySoundFrontend(-1, "Click", "DLC_HEIST_HACKING_SNAKE_SOUNDS", true)
ShowInfo(WelcomeMessage)
if WelcomeMessage2 ~= nil then
Citizen.Wait(11000)
PlaySoundFrontend(-1, "Click", "DLC_HEIST_HACKING_SNAKE_SOUNDS", true)
ShowInfo(WelcomeMessage2)
end
firstJoin = false
end
end)
-- RECOIL, FIRING MODES, RANDOM MALFUNCTIONS
-- Credit: https://github.com/TFNRP/WeaponControl
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
-- VAR
local ped = PlayerPedId()
local _, weapon = GetCurrentPedWeapon(ped)
local Weapon = GetWeapon(weapon)
if IsPedShooting(ped) then
--[[if not IsPedInAnyVehicle(ped) then
local iter = 2
if IsPedSprinting(ped) then
iter = iter + 1
end
CreateThread(function()
local last = GetGameplayCamRelativePitch()
for _ = 1, iter do
local camera = GetGameplayCamRelativePitch()
local amount = camera - last
if GetFollowPedCamViewMode() == 4 then
amount = -amount
end
print(amount)
SetGameplayCamRelativePitch(camera - amount, 1.0)
last = camera
Wait(1)
end
end)
end]]
if AllowedAuto[GetWeapontypeGroup(weapon)] then
({
function()
repeat
DisablePlayerFiring(PlayerId(), true)
Wait(0)
until not (IsControlPressed(0, 24) or IsDisabledControlPressed(0, 24))
end,
function()
Wait(300)
while IsControlPressed(0, 24) or IsDisabledControlPressed(0, 24) do
DisablePlayerFiring(PlayerId(), true)
Wait(0)
end
end,
function() end,
})[Weapon.FiringMode]()
end
-- Jamming
local _, clipAmmo = GetAmmoInClip(ped, weapon)
-- 1 in 1000 chance to jam for each bullet
-- that's 40 mags of a carbine rifle or 100 mags of a pistol
if math.random(1, 1.2e3) == 1 and clipAmmo > 0 then
SetAmmoInClip(ped, weapon, 0)
AddAmmoToPed(ped, weapon, clipAmmo)
ShowNotification('Your gun is jammed.')
end
end
end
end)
RegisterKeyMapping('firingmode', 'Change Firing Mode', 'keyboard', 'x')
RegisterCommand('firingmode', function()
local ped = PlayerPedId()
if DoesEntityExist(ped) and not IsEntityDead(ped) and IsArmed() then
local _, weapon = GetCurrentPedWeapon(ped)
if AllowedAuto[GetWeapontypeGroup(weapon)] then
local Weapon = GetWeapon(weapon)
Weapon.FiringMode = ({ 2, 3, 1 })[Weapon.FiringMode]
ShowNotification(({
[Constants.SEMI_AUTO] = 'Switched firing mode to ~r~semi-auto.',
[Constants.BURST_FIRE] = 'Switched firing mode to ~y~burst fire.',
[Constants.FULL_AUTO] = 'Switched firing mode to ~g~full-auto.',
})[Weapon.FiringMode])
PlayClick(ped)
end
end
end)
-- Save Wheel Position
-- Credit: https://github.com/TFNRP/framework
Citizen.CreateThread(function()
local vehicle
local angle
while true do
Citizen.Wait(1)
local ped = PlayerPedId()
if IsPedInAnyVehicle(ped) then
vehicle = GetVehiclePedIsIn(ped)
local current = GetVehicleSteeringAngle(vehicle)
if current > 20 then
angle = 40.0
elseif current < -20 then
angle = -40.0
elseif current > 5 or current < -5 then
angle = current
end
end
if angle and vehicle and DoesEntityExist(vehicle) and (IsPedOnFoot(ped) or IsPedStopped(ped)) then
SetVehicleSteeringAngle(vehicle, angle)
end
end
end)
-- Delete vehicle
-- Credit: https://github.com/TFNRP/framework
RegisterFrameworkCommand({ 'dv', 'delveh' }, function()
local ped = GetPlayerPed(-1)
local vehicle = GetVehiclePedIsInOrNear(ped, false)
if vehicle and vehicle > 1 then
if IsPedSittingInVehicle(ped, vehicle) and not GetPedInVehicleSeat(vehicle, -1) == ped then
ShowNotification('~r~Error: ~s~You must be the driver of the vehicle.')
else
NetworkRequestControlOfEntity(vehicle)
SetEntityAsMissionEntity(vehicle, true, true)
DeleteVehicle(vehicle)
if not (DoesEntityExist(vehicle)) then
ShowNotification('~g~Success: ~s~Vehicle deleted.')
end
end
else
ShowNotification('~r~Error: ~w~You must be close to or in a vehicle.')
end
end)
-- Keep AI Calm, Disable emergency response
-- Credit: https://github.com/TFNRP/keepcalm
function SetPedsToCalm(exists, handle, iter)
if exists then
SetBlockingOfNonTemporaryEvents(handle, true)
SetPedFleeAttributes(handle, 0, 0)
SetPedCombatAttributes(handle, 17, 1)
local exists, handle = FindNextPed(iter)
SetPedsToCalm(exists, handle, iter)
else
EndFindPed(iter)
end
end
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
for i = 1, 12 do
EnableDispatchService(i, false)
end
local player = PlayerId()
SetPoliceIgnorePlayer(player, true)
SetDispatchCopsForPlayer(player, false)
SetPlayerCanBeHassledByGangs(player, true)
SetIgnoreLowPriorityShockingEvents(player, true)
SetPlayerWantedLevel(player, 0, false)
SetPlayerWantedLevelNow(player, false)
SetPlayerWantedLevel(player, 0, false)
local iter, handle = FindFirstPed()
SetPedsToCalm(true, handle, iter)
end
end)
-- Heal self and replenish armor commands
TriggerEvent('chat:addSuggestion', '/heal', 'Refill your health.')
RegisterCommand('heal', function(source, args, rawCommand)
TriggerServerEvent('txaLogger:CommandExecuted', rawCommand)
SetEntityHealth(GetPlayerPed(-1), 200)
ShowInfo("You have been healed.")
end)
RegisterCommandSuggestion({ 'armour', 'armor' }, 'Set your armour.', {
{ name = 'amount', help = '0 = none, 1 = some, 2 = under half, 3 = over half, 4 = almost max, 5 = max.' }
})
RegisterFrameworkCommand({ 'armour', 'armor' }, function(source, args, raw)
local amount = (tonumber(args[1]) or 5) * 20
TriggerServerEvent('txaLogger:CommandExecuted', rawCommand)
if not IsPlayerDead(PlayerId()) then
if amount > 100 then
amount = 100
elseif amount < 0 then
amount = 0
end
SetPedArmour(PlayerPedId(), amount)
armorCooldown = false
else
ShowInfo("You cannot replenish your armor now.")
end
end)
-- Toggle Engine
--https://github.com/TFNRP/framework/blob/main/client.lua
RegisterKeyMapping('engine', 'Toggle Engine', 'keyboard', 'F7')
RegisterFrameworkCommand({ 'engine', 'eng' }, function(source, args, raw)
local ped = PlayerPedId()
if IsPedInAnyVehicle(ped) then
local vehicle = GetVehiclePedIsIn(ped)
local on = GetIsVehicleEngineRunning(vehicle)
SetVehicleEngineOn(vehicle, not on, false, true)
end
end)
-- Synchronize Vehicle Weapon with Foot Weapon
-- Credit: https://github.com/TFNRP/framework/blob/main/client.lua
Citizen.CreateThread(function()
local lastHash
local lastNotInVehicle = true
local lastNotInVehicleHash
local switchedWeapon
while true do
Citizen.Wait(1)
local ped = PlayerPedId()
if IsPedInAnyVehicle(ped) then
if lastNotInVehicle then
SetCurrentPedWeapon(ped, lastNotInVehicleHash, true)
lastHash = lastNotInVehicleHash
else
local _, hash = GetCurrentPedWeapon(ped)
if hash ~= lastHash then
Citizen.Wait(1)
switchedWeapon = true
SetCurrentPedWeapon(ped, hash, true)
lastHash = hash
end
end
lastNotInVehicle = false
else
if not lastNotInVehicle and lastNotInVehicleHash ~= GetHashKey('WEAPON_UNARMED') and (not CanUseWeaponOnParachute(lastNotInVehicleHash) or not switchedWeapon) then
SetCurrentPedWeapon(ped, lastNotInVehicleHash, true)
end
_, lastNotInVehicleHash = GetCurrentPedWeapon(ped)
switchedWeapon = false
lastNotInVehicle = true
end
GetCurrentPedVehicleWeapon(ped)
end
end)
-- Hood, Trunk, Door and Window commands
-- Credit: https://github.com/TFNRP/framework/blob/main/client.lua
RegisterCommandSuggestion('hood', 'Open the hood of the vehicle you\'re near.')
RegisterCommandSuggestion('bonnet', 'Open the bonnet of the vehicle you\'re near.')
RegisterCommandSuggestion('trunk', 'Open the trunk of the vehicle you\'re near.')
RegisterCommandSuggestion('boot', 'Open the boot of the vehicle you\'re near.')
RegisterCommandSuggestion('door', 'Open a door of the vehicle you\'re near.', {
{ name = 'door', help = 'Can be the number of the door or the door\'s name. i.e. "driver", "passenger", "1", "2"' }
})
RegisterCommandSuggestion('door f', 'Just like /door, but forces the door to stay open.', {
{ name = 'door', help = 'Can be the number of the door or the door\'s name. i.e. "driver", "passenger", "1", "2"' }
})
RegisterCommandSuggestion('door q', 'Just like /door, but instantly opens/closes doors.', {
{ name = 'door', help = 'Can be the number of the door or the door\'s name. i.e. "driver", "passenger", "1", "2"' }
})
RegisterFrameworkCommand({'hood', 'bonnet'}, function()
local vehicle = GetVehiclePedIsInOrNear(PlayerPedId(), false)
if vehicle and vehicle > 1 then
NetworkRequestControlOfEntity(vehicle)
if GetVehicleDoorAngleRatio(vehicle, 4) > 0 then
SetVehicleDoorShut(vehicle, 4, false)
else
SetVehicleDoorOpen(vehicle, 4, false, false)
Wait(1e3)
SetVehicleDoorOpen(vehicle, 4, true, false)
end
end
end)
RegisterFrameworkCommand({ 'trunk', 'boot' }, function()
local vehicle = GetVehiclePedIsInOrNear(PlayerPedId(), false)
if vehicle and vehicle > 1 then
NetworkRequestControlOfEntity(vehicle)
if GetVehicleDoorAngleRatio(vehicle, 5) > 0 then
SetVehicleDoorShut(vehicle, 5, false)
else
SetVehicleDoorOpen(vehicle, 5, false, false)
Wait(1e3)
SetVehicleDoorOpen(vehicle, 5, true, false)
end
end
end)
RegisterKeyMapping("door 1", "Open/Close Front Driver Door", "keyboard", "")
RegisterKeyMapping("door 2", "Open/Close Front Passenger Door", "keyboard", "")
RegisterKeyMapping("door 3", "Open/Close Rear Driver Door", "keyboard", "")
RegisterKeyMapping("door 4", "Open/Close Rear Passenger Door", "keyboard", "")
RegisterFrameworkCommand('door', function(source, args, raw)
local vehicle = GetVehiclePedIsInOrNear(PlayerPedId(), false)
local loose = true
local instant = false
if #args == 0 then table.insert(args, 1) end
for _, arg in ipairs(args) do
local door = tonumber(arg)
if not door then
arg = arg:lower()
if DoorIndex[arg] then
door = DoorIndex[arg]
elseif ({ f = true, force = true })[arg] then
loose = false
elseif ({ q = true, quick = true })[arg] then
instant = true
else
CommandWarning('Didn\'t understand what "' .. arg .. '" was.')
end
end
if door then
door = door - 1
if vehicle and vehicle > 1 then
local doors = GetNumberOfVehicleDoors(vehicle) - 1
if doors < door then door = doors
elseif door < 0 then door = 0 end
NetworkRequestControlOfEntity(vehicle)
if GetVehicleDoorAngleRatio(vehicle, door) > 0 then
SetVehicleDoorShut(vehicle, door, instant)
else
CreateThread(function()
SetVehicleDoorOpen(vehicle, door, false, instant)
Wait(1e3)
SetVehicleDoorOpen(vehicle, door, loose, instant)
end)
end
end
end
end
end)
RegisterCommandSuggestion('window', 'Open a window of the vehicle you\'re in.', {
{ name = 'door', help = 'Can be the number of the window or the window\'s name. i.e. "driver", "passenger", "1", "2"' }
})
RegisterFrameworkCommand('window', function(source, args, raw)
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
local window = (tonumber(args[1]) or 1) - 1
if vehicle and vehicle > 1 then
if window > 11 then window = 11
elseif window < 0 then window = 0 end
local decoratorName = 'WindowRolledDown' .. window
if not DecorIsRegisteredAsType(decoratorName, 2) then
DecorRegister(decoratorName, 2)
end
if not DecorGetBool(vehicle, decoratorName) then
DecorSetBool(vehicle, decoratorName, true)
RollDownWindow(vehicle, window)
else
DecorSetBool(vehicle, decoratorName, false)
RollUpWindow(vehicle, window)
end
end
end)
-- leave engine running
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
local ped = PlayerPedId()
if DoesEntityExist(ped) and IsPedInAnyVehicle(ped, false) and IsControlPressed(2, 75) and not IsEntityDead(ped) and not IsPauseMenuActive() then
Citizen.Wait(200)
if IsPedInAnyVehicle(ped, false) and IsControlPressed(2, 75) and not IsEntityDead(ped) then
local vehicle = GetVehiclePedIsIn(ped, true)
SetVehicleEngineOn(vehicle, true, true, false)
TaskLeaveVehicle(ped, vehicle, 0)
end
end
end
end)
-- Persistent Flashlight compatibility with BetterFlashlight
Citizen.CreateThread(function()
while true do
Citizen.Wait(2500)
if BetterFlashlightInstalled then
SetFlashLightKeepOnWhileMoving(true)
end
end
end)
-- Get into closest vehicle door
-- https://github.com/itsJarrett/FiveM-seat_seater/
Citizen.CreateThread(function()
local getInDoors = {
{"seat_dside_f", -1},
{"seat_pside_f", 0},
{"seat_dside_r", 1},
{"seat_pside_r", 2}
}
while true do
Citizen.Wait(0)
local ped = PlayerPedId()
if IsControlJustReleased(0, 23) and running ~= true and GetVehiclePedIsIn(ped, false) == 0 then
local vehicle = VehicleInFront(ped)
running = true
if vehicle ~= nil then
local plyCoords = GetEntityCoords(ped, false)
local doorDistances = {}
for k, door in pairs(getInDoors) do
local doorBone = GetEntityBoneIndexByName(vehicle, door[1])
local doorPos = GetWorldPositionOfEntityBone(vehicle, doorBone)
local distance = Vdist(plyCoords.x, plyCoords.y, plyCoords.z, doorPos.x, doorPos.y, doorPos.z)
table.insert(doorDistances, distance)
end
local key, min = 1, doorDistances[1]
for k, v in ipairs(doorDistances) do
if doorDistances[k] < min then
key, min = k, v
end
end
TaskEnterVehicle(ped, vehicle, -1, getInDoors[key][2], 1.5, 1, 0)
end
running = false
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if IsControlPressed(0, 20) then
SetRadarZoomToDistance(200.0)
end
end
end)
-- CHAT COMMANDS
RegisterNetEvent("sendProximityMessage")
AddEventHandler("sendProximityMessage", function(sender, message, color, range)
local player = GetPlayerFromServerId(sender)
local ped = GetPlayerPed(player)
if player == -1 then return end
local sender_coords = GetEntityCoords(ped)
local local_ped = {}
local_ped.handle = PlayerPedId()
local_ped.position = GetEntityCoords(local_ped.handle)
local dist = #(local_ped.position - sender_coords)
if dist <= range then
TriggerEvent(
"chat:addMessage", {
args = {
message
},
color = color
}
)
end
end)
RegisterCommandSuggestion({ "bleet", "tweet", }, 'Post a message on Bleeter.', {
{ name = 'Message', help = 'The message you want to post' }
})
RegisterCommandSuggestion('me', 'Indicate that your character is doing something to nearby players.', {
{ name = 'Action', help = 'What your character is doing. Example: "/me reaches into their glovebox and retrieves a wallet."' }
})
RegisterCommandSuggestion('my', 'Indicate that something belonging to your character is doing something to nearby players.', {
{ name = 'Action', help = 'What your character\'s item is doing. Example: "/my car is on fire."' }
})
RegisterCommandSuggestion('do', 'Used to describe something or answer role-play questions for nearby players.', {
{ name = 'Description or Action', help = 'Giving a description or answering RP questions. Example: "/do The license plate 46EEK572 comes back stolen out of Rockford Hills."' }
})
RegisterCommandSuggestion('local', 'Send an out-of-character message to nearby players.', {
{ name = 'Message', help = 'The message you want to send' }
})
RegisterCommandSuggestion('gme', 'Indicate that your character is doing something to all players.', {
{ name = 'Action', help = 'What your character is doing. Example: "/gme asks for permission to see the security camera footage from the store across the street."' }
})
RegisterCommandSuggestion('gmy', 'Indicate that something belonging to your character is doing something to all players.', {
{ name = 'Action', help = 'What your character\'s item is doing. Example: "/my car is on fire."' }
})
RegisterCommandSuggestion('gdo', 'Used to describe something or answer role-play questions for all players.', {
{ name = 'Description or Action', help = 'Giving a description or answering RP questions. Example: "/gdo On the cameras, you would see a male in dark clothing fleeing on a blue motorcycle."' }
})
RegisterCommandSuggestion({ "ooc", "/", }, 'Send an out-of-character message to the entire server.', {
{ name = 'Message', help = 'The message you want to send' }
})
RegisterCommandSuggestion('img', 'Send an image in chat.', {
{ name = 'URL', help = 'URL to the image you wish to send.' }
})
--[[
RegisterCommandSuggestion('', '', {
{ name = '', help = '' }
})
]]
-- Functions
function WeaponStub()
return {
FiringMode = 1,
}
end
function GetWeapon(hash)
if not Weapons[hash] then
Weapons[hash] = WeaponStub()
end
return Weapons[hash]
end
function IsArmed()
return IsPedArmed(PlayerPedId(), 4)
end
function PlayClick(ped)
PlaySoundFromEntity(-1, 'Faster_Click', ped, 'RESPAWN_ONLINE_SOUNDSET', true)
end
function ShowInfo(text)
SetTextComponentFormat("STRING")
AddTextComponentString(text)
DisplayHelpTextFromStringLabel(0, 0, 0, -1)
end
function ShowNotification(text)
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(false, false)
end
function VehicleInFront(ped)
local pos = GetEntityCoords(ped)
local entityWorld = GetOffsetFromEntityInWorldCoords(ped, 0.0, 5.0, 0.0)
local rayHandle = CastRayPointToPoint(pos.x, pos.y, pos.z, entityWorld.x, entityWorld.y, entityWorld.z, 10, ped, 0)
local _, _, _, _, result = GetRaycastResult(rayHandle)
return result
end
RegisterNetEvent("missiontext")
AddEventHandler("missiontext", function(text, time)
ClearPrints()
SetTextEntry_2("STRING")
AddTextComponentString(text)
DrawSubtitleTimed(time, 1)
end)
-- Trigger Mission Text every ms: TriggerEvent("missiontext", "Here is some ~r~red~w~ text.", 500)
-- https://github.com/TFNRP/framework/blob/main/client.lua
function GetVehiclePedIsInOrNear(ped, lastVehicle)
local vehicle = GetVehiclePedIsIn(ped, lastVehicle)
if vehicle and vehicle > 1 then
return vehicle
else
local position = GetEntityCoords(ped)
local front = GetOffsetFromEntityInWorldCoords(ped, .0, 3.5, -.5)
local rayHandle = CastRayPointToPoint(position.x, position.y, position.z, front.x, front.y, front.z, 10, ped, 0)
local _, _, _, _, vehicle = GetRaycastResult(rayHandle)
if DoesEntityExist(vehicle) then
return vehicle
end
end
end