-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathclient.lua
More file actions
117 lines (104 loc) · 3.79 KB
/
client.lua
File metadata and controls
117 lines (104 loc) · 3.79 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
local isDoingYoga = false
local animationDict = "missfam5_yoga"
local yogaPoses = {
"start_pose",
"start_to_a1",
"a1_pose",
"a1_to_a2",
"a2_pose",
"a2_to_a3",
"a3_pose",
"a3_to_b4",
"b4_pose",
"b4_to_start",
"start_to_c1",
"c1_pose",
"c1_to_c2",
"c2_pose",
"c2_to_c3",
"c3_pose",
"c3_to_c4",
"c4_pose",
"c4_to_c5",
"c5_pose",
"c5_to_c6",
"c6_pose",
"c6_to_c7",
"c7_pose",
"c7_to_c8",
"c8_pose",
"c8_to_start",
"f_yogapose_a",
"f_yogapose_b",
"f_yogapose_c",
}
local function LoadAnimDict(dict)
while not HasAnimDictLoaded(dict) do
RequestAnimDict(dict)
Wait(10)
end
end
-- Thread to control actively doing yoga on the mat and the different poses
local function startYogaMatInteraction(yogaMatEntity)
local ped = PlayerPedId()
ClearPedTasks(ped)
isDoingYoga = true
-- Put player in the center of the mat and facing the correct direction
local yogaMatCoords = GetEntityCoords(yogaMatEntity)
local yogaMatHeading = GetEntityHeading(yogaMatEntity)
SetEntityCoords(ped, yogaMatCoords)
SetEntityHeading(ped, yogaMatHeading - 90)
LoadAnimDict(animationDict)
-- Put the player in the starting yoga pose
TaskPlayAnim(ped, animationDict, yogaPoses[1], 8.0, -8.0, -1, 2, 0, false, false, false)
-- Start a thread that handles listening for keypresses while the player is actively using the yoga mat
-- Handles key presses for LEFT, RIGHT, UP arrows for cycling the emotes,
-- BACKSPACE or walking away from the yoga mat will cancel out of the thread
CreateThread(function()
local index = 2 -- Start at index 2 since player is already in the first pose
while isDoingYoga do
if IsControlJustPressed(0, 194) or (#(GetEntityCoords(ped) - yogaMatCoords) > 5) then -- BACKSPACE or walk away to cancel
isDoingYoga = false
ClearPedTasks(ped)
elseif IsControlJustPressed(0, 188) then -- UP arrow - begin yoga loop
ClearPedTasks(ped)
TaskStartScenarioInPlace(ped, "WORLD_HUMAN_YOGA", 0, true)
elseif IsControlJustPressed(0, 189) then -- LEFT arrow - cycle poses
if index <= 1 then
index = #yogaPoses
else
index = index - 1
end
TaskPlayAnim(ped, animationDict, yogaPoses[index], 8.0, -8.0, -1, 2, 0, false, false, false)
elseif IsControlJustPressed(0, 190) then -- RIGHT arrow - cycle poses
if index >= #yogaPoses then
index = 1
else
index = index + 1
end
TaskPlayAnim(ped, animationDict, yogaPoses[index], 8.0, -8.0, -1, 2, 0, false, false, false)
end
Wait(1)
end
end)
if Config.ShouldReduceStress or Config.ShouldIncreaseHealth then
-- Thread handles periodically applying the stress + health buffs
CreateThread(function()
while isDoingYoga do
Wait(Config.BuffInterval)
if Config.ShouldReduceStress then
SetPlayerStressMetaData(Config.ReduceStressAmount)
end
if Config.ShouldIncreaseHealth then
SetEntityHealth(ped, GetEntityHealth(ped) + Config.IncreaseHealthAmount)
end
end
end)
end
end
-- Start doing yoga
RegisterNetEvent("wp-yogamats:client:useYogaMat", function(data)
local yogaMatEntity = data.entity
Notify("Left/Right arrow keys to cycle poses. Up arrow to loop. Backspace to exit.", "primary", 7500)
startYogaMatInteraction(yogaMatEntity)
end)