-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcl.lua
More file actions
75 lines (69 loc) · 2.4 KB
/
cl.lua
File metadata and controls
75 lines (69 loc) · 2.4 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
local cfg <const> = {
dict = 'amb@world_human_bum_freeway@male@base',
anim = 'base',
begKey = 38,
begDistance = 3.0,
begDuration = math.random(5, 5), -- secs
begPolice = 2, -- The lower the less chances of alerting the police,
begStatus = false,
waitBetweenRob = true,
locales = {
recentlyRobbed = 'You have recently robbed someone!',
begMoney = 'Begging for money'
}
}
local CreateThread = CreateThread
local Wait = Wait
local function notify(message)
SetNotificationTextEntry('STRING')
AddTextComponentString(message)
DrawNotification(0, 1)
end
local function beg(targetPed)
if not cfg.begStatus then
cfg.begStatus = true
RequestAnimDict(cfg.dict)
while not HasAnimDictLoaded(cfg.dict) do
Wait(10)
end
TaskStandStill(targetPed, cfg.begDuration * 1000)
FreezeEntityPosition(targetPed, true)
TaskPlayAnim(PlayerPedId(), cfg.dict, cfg.anim, 1.5, 1.5, cfg.begDuration * 1000, 1, 0, 0, 0, 0)
RemoveAnimDict(cfg.dict)
Wait(cfg.begDuration * 1000)
local chances = math.random(1, 10)
if chances < cfg.begPolice then
-- Add your event or export for alerting the police.
else
TriggerServerEvent('beg:randomizer')
end
FreezeEntityPosition(targetPed, false)
ClearPedTasks(PlayerPedId())
SetTimeout(60000, function() cfg.begStatus = false end)
end
end
CreateThread(function()
while true do
local playerId = PlayerId()
if IsControlJustPressed(0, cfg.begKey) then
print('test')
if not cfg.begStatus then
local aiming, targetPed = GetEntityPlayerIsFreeAimingAt(playerId)
if aiming then
local ped = PlayerPedId()
local coords = GetEntityCoords(ped, true)
local targetCoords = GetEntityCoords(targetPed, true)
if DoesEntityExist(targetPed) and IsEntityAPed(targetPed) and not IsEntityDead(targetPed) then
if #(coords - targetCoords) < cfg.begDistance then
beg(targetPed)
notify(cfg.locales.begMoney)
end
end
end
else
notify(cfg.locales.recentlyRobbed)
end
end
Wait(5)
end
end)