-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcl_main.lua
69 lines (62 loc) · 2.15 KB
/
cl_main.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
RegisterNetEvent("shoestealing:takeShoes", function(ent)
SetPedComponentVariation(PlayerPedId(), 6, 34, 0, 0)
end)
function getClosestPlayer()
local ped = PlayerPedId()
if coords then
coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords
else
coords = GetEntityCoords(ped)
end
local closestPlayers = getPlyFromCoords(coords)
local closestDistance = -1
local closestPlayer = -1
for i = 1, #closestPlayers, 1 do
if closestPlayers[i] ~= PlayerId() and closestPlayers[i] ~= -1 then
local pos = GetEntityCoords(GetPlayerPed(closestPlayers[i]))
local distance = #(pos - coords)
if closestDistance == -1 or closestDistance > distance then
closestPlayer = closestPlayers[i]
closestDistance = distance
end
end
end
return closestPlayer, closestDistance
end
function getPlyFromCoords()
local players = GetActivePlayers()
local ped = PlayerPedId()
if coords then
coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords
else
coords = GetEntityCoords(ped)
end
local distance = distance or 5
local closePlayers = {}
for _, player in pairs(players) do
local target = GetPlayerPed(player)
local targetCoords = GetEntityCoords(target)
local targetdistance = #(targetCoords - coords)
if targetdistance <= distance then
closePlayers[#closePlayers + 1] = player
end
end
return closePlayers
end
function stealShoesEmote()
local Ped = PlayerPedId()
local dict = "random@domestic"
RequestAnimDict(dict)
while (not HasAnimDictLoaded(dict)) do Wait(0) end
TaskPlayAnim(Ped, dict, "pickup_low", 3.0, 3.0, 1200, 0, 0, false, false, false)
end
RegisterCommand("stealshoes", function()
local player = getClosestPlayer(GetEntityCoords(PlayerPedId()))
local id = GetPlayerServerId(player)
if player ~= -1 then
if GetPedDrawableVariation(player, 6) ~= config.shoes then
stealShoesEmote()
TriggerServerEvent("shoeting", id)
end
end
end, false)