Repository navigation
Expand file tree
/
Copy pathclient.lua
More file actions
139 lines (106 loc) · 3.76 KB
/
Copy pathclient.lua
File metadata and controls
139 lines (106 loc) · 3.76 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
ESX = nil
CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
while not ESX.IsPlayerLoaded() do
Wait(500)
end
ESX.PlayerData = ESX.GetPlayerData()
PlayerLoaded = true
end)
local Config = {}
Config.AnimType = 49 -- 49: Can't move, 1: You can walk
Config.MoreIntensityKey = 54 -- E
Config.LessIntensityKey = 52 -- Q
Config.LeftKey = 174 -- LEFT ARROW
Config.RightKey = 175 -- RIGHT ARROW
Config.UpKey = 27 -- UP ARROW
Config.DownKey = 173 -- DOWN ARROW
Config.ChangeDance = 21 -- SHIFT
Config.CancelDance = 82 ---- ,
Config.ToggleMovement = 19
--################################################
--### VARIABLES ###
--################################################
local playerPed = PlayerPedId()
local dancing = false
local willDance = false
local intensityIndex=1
local horizontal,vertical
local variation = "a@"
local lastAnim = ""
local intensities = {"low","med","high"}
local typeOfDance
local type = 0
--################################################
--### EVENTS ###
--################################################
RegisterNetEvent("bc_dancing:startDancingAsMen")
AddEventHandler("bc_dancing:startDancingAsMen",function()
typeOfDance = "anim@amb@nightclub@mini@dance@dance_solo@male@var_"
print("men")
willDance = true
end)
RegisterNetEvent("bc_dancing:startDancingAsWoman")
AddEventHandler("bc_dancing:startDancingAsWoman",function()
typeOfDance = "anim@amb@nightclub@mini@dance@dance_solo@female@var_"
print("woman")
willDance = true
end)
--[[
RegisterNetEvent("bc_dancing:startDancingAsAMotherfucker")
AddEventHandler(function ()
willDance = true
end)]]
--################################################
--### FUNCTIONS ###
--################################################
function startAnim(playerPed,dir, anim, type)
ESX.Streaming.RequestAnimDict(dir, function()
ClearPedTasks(playerPed)
TaskPlayAnim(playerPed, dir, anim, 5.0, 5.0, -1,type, 1, false, false, false)
end)
end
CreateThread(function ()
while true do
Wait(1)
if willDance then
-- Handles Change of Variation
if IsControlJustPressed(1,Config.ChangeDance) then
if variation == "a@" then variation="b@" else variation="a@" end
end
-- Handles intensity
if IsControlJustPressed(1,Config.LessIntensityKey) then
if intensityIndex >1 then intensityIndex = intensityIndex - 1 end
elseif IsControlJustPressed(1,Config.MoreIntensityKey) then
if intensityIndex <3 then intensityIndex = intensityIndex + 1 end
end
-- Handles horizontal
if IsControlPressed(1,Config.RightKey) then horizontal = "right"
elseif IsControlPressed(1,Config.LeftKey) then horizontal = "left"
else if horizontal ~= "center" then horizontal = "center" end end
-- Handles vertical
if IsControlPressed(1,Config.UpKey) then vertical = "_up"
elseif IsControlPressed(1,Config.DownKey) then vertical = "_down"
else if vertical ~= "" then vertical = "" end end
if IsControlJustPressed(1,Config.ToggleMovement) then
if type==0 then type=49 else type=0 end
end
local animation = intensities[intensityIndex].."_".. horizontal..vertical
local dir = typeOfDance .. variation
local currentAnim = dir .. " " .. animation .. " " ..type
if lastAnim ~= currentAnim then
lastAnim = dir .. " " .. animation .. " " ..type
dancing = true
startAnim(playerPed,dir,animation,type)
end
if IsControlJustPressed(1,Config.CancelDance) and dancing then
dancing = false
lastAnim = false
willDance=false
end
end
end
end)