Skip to content

Commit 98e6a20

Browse files
committed
Update v2.4.11
1 parent efaf3c0 commit 98e6a20

File tree

5 files changed

+136
-13
lines changed

5 files changed

+136
-13
lines changed

client/functions/progressbar.lua

Lines changed: 127 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,156 @@
11
MSK.Progress = {}
22

3-
local isProgressOpen = false
3+
local isProgressActive, progressData = false, nil
44

5-
MSK.Progress.Start = function(time, text, color)
6-
if isProgressOpen then
7-
MSK.Progress.Stop()
5+
local Controls = {
6+
INPUT_LOOK_LR = 1,
7+
INPUT_LOOK_UD = 2,
8+
INPUT_SPRINT = 21,
9+
INPUT_AIM = 25,
10+
INPUT_MOVE_LR = 30,
11+
INPUT_MOVE_UD = 31,
12+
INPUT_DUCK = 36,
13+
INPUT_VEH_MOVE_LEFT_ONLY = 63,
14+
INPUT_VEH_MOVE_RIGHT_ONLY = 64,
15+
INPUT_VEH_ACCELERATE = 71,
16+
INPUT_VEH_BRAKE = 72,
17+
INPUT_VEH_EXIT = 75,
18+
INPUT_VEH_MOUSE_CONTROL_OVERRIDE = 106
19+
}
20+
21+
local interrupted = function(data)
22+
if not data.useWhileDead and IsEntityDead(MSK.Player.playerPed) then return true end
23+
if not data.allowRagdoll and IsPedRagdoll(MSK.Player.playerPed) then return true end
24+
if not data.allowCuffed and IsPedCuffed(MSK.Player.playerPed) then return true end
25+
if not data.allowFalling and IsPedFalling(MSK.Player.playerPed) then return true end
26+
if not data.allowSwimming and IsPedSwimming(MSK.Player.playerPed) then return true end
27+
end
28+
29+
local setProgressData = function(data)
30+
progressData = data
31+
local anim = data.animation
32+
33+
if anim then
34+
if anim.dict then
35+
MSK.Request.AnimDict(anim.dict)
36+
TaskPlayAnim(MSK.Player.playerPed, anim.dict, anim.anim, anim.blendIn or 3.0, anim.blendOut or 1.0, anim.duration or -1, anim.flag or 49, anim.playbackRate or 0, anim.lockX, anim.lockY, anim.lockZ)
37+
RemoveAnimDict(anim.dict)
38+
elseif anim.scenario then
39+
TaskStartScenarioInPlace(MSK.Player.playerPed, anim.scenario, 0, anim.playEnter ~= nil and anim.playEnter or true)
40+
end
41+
end
42+
43+
local disable = data.disable
44+
45+
while isProgressActive do
46+
if disable then
47+
if disable.mouse then
48+
DisableControlAction(0, Controls.INPUT_LOOK_LR, true)
49+
DisableControlAction(0, Controls.INPUT_LOOK_UD, true)
50+
DisableControlAction(0, Controls.INPUT_VEH_MOUSE_CONTROL_OVERRIDE, true)
51+
end
52+
53+
if disable.move then
54+
DisableControlAction(0, Controls.INPUT_SPRINT, true)
55+
DisableControlAction(0, Controls.INPUT_MOVE_LR, true)
56+
DisableControlAction(0, Controls.INPUT_MOVE_UD, true)
57+
DisableControlAction(0, Controls.INPUT_DUCK, true)
58+
end
59+
60+
if disable.sprint and not disable.move then
61+
DisableControlAction(0, Controls.INPUT_SPRINT, true)
62+
end
63+
64+
if disable.vehicle then
65+
DisableControlAction(0, Controls.INPUT_VEH_MOVE_LEFT_ONLY, true)
66+
DisableControlAction(0, Controls.INPUT_VEH_MOVE_RIGHT_ONLY, true)
67+
DisableControlAction(0, Controls.INPUT_VEH_ACCELERATE, true)
68+
DisableControlAction(0, Controls.INPUT_VEH_BRAKE, true)
69+
DisableControlAction(0, Controls.INPUT_VEH_EXIT, true)
70+
end
71+
72+
if disable.combat then
73+
DisableControlAction(0, Controls.INPUT_AIM, true)
74+
DisablePlayerFiring(MSK.Player.clientId, true)
75+
end
76+
end
77+
78+
if interrupted(data) then
79+
MSK.Progress.Stop()
80+
end
81+
82+
Wait(0)
883
end
9-
isProgressOpen = true
84+
85+
if anim then
86+
if anim.dict then
87+
StopAnimTask(MSK.Player.playerPed, anim.dict, anim.clip, 1.0)
88+
ClearPedTasks(MSK.Player.playerPed)
89+
else
90+
ClearPedTasks(MSK.Player.playerPed)
91+
end
92+
end
93+
end
94+
95+
MSK.Progress.Start = function(data, text, color)
96+
local duration, text, color = data, text, color
97+
local forceOverride = false
98+
99+
if type(data) == 'table' then
100+
duration = data.duration
101+
text = data.text
102+
color = data.color or Config.progressColor
103+
forceOverride = data.forceOverride or forceOverride
104+
end
105+
106+
if isProgressActive and not forceOverride then return end
107+
if isProgressActive then MSK.Progress.Stop() end
108+
isProgressActive = true
10109

11110
SendNUIMessage({
12111
action = 'progressBarStart',
13-
time = time,
112+
time = duration,
14113
text = text or '',
15114
color = color or Config.progressColor,
16115
})
17116

18-
SetTimeout(time, function()
19-
isProgressOpen = false
20-
end)
117+
if type(data) == 'table' then
118+
return setProgressData(data)
119+
end
21120
end
22121
MSK.Progressbar = MSK.Progress.Start -- Support for old Scripts
23122
exports('Progressbar', MSK.Progress.Start)
24123
exports('ProgressbarStart', MSK.Progress.Start) -- Support for old Scripts
25124
RegisterNetEvent("msk_core:progressbar", MSK.Progress.Start)
26125

27126
MSK.Progress.Stop = function()
127+
if not isProgressActive then return end
128+
28129
SendNUIMessage({
29130
action = 'progressBarStop',
30131
})
31132

32-
isProgressOpen = false
133+
isProgressActive = false
134+
progressData = nil
33135
end
34136
MSK.ProgressStop = MSK.Progress.Stop -- Support for old Scripts
35137
exports('ProgressStop', MSK.Progress.Stop) -- Support for old Scripts
36138
RegisterNetEvent("msk_core:progressbarStop", MSK.Progress.Stop)
37139

38140
MSK.Progress.Active = function()
39-
return isProgressOpen
141+
return isProgressActive, isProgressActive and progressData
40142
end
41-
exports('ProgressActive', MSK.Progress.Active)
143+
exports('ProgressActive', MSK.Progress.Active)
144+
145+
RegisterNUICallback('progressEnd', function()
146+
isProgressActive = false
147+
progressData = nil
148+
end)
149+
150+
RegisterCommand('stopProgress', function()
151+
if isProgressActive and progressData and progressData.canCancel then
152+
MSK.Progress.Stop()
153+
end
154+
end)
155+
RegisterKeyMapping('stopProgress', 'Cancel Progressbar', 'keyboard', 'X')
156+
TriggerEvent('chat:removeSuggestion', '/stopProgress')

client/functions/vehicle.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ MSK.GetVehicleInDirection = function(distance)
4444

4545
return entity
4646
end
47+
MSK.GetVehicleInFront = MSK.GetVehicleInDirection
4748
exports('GetVehicleInDirection', MSK.GetVehicleInDirection)
4849

4950
MSK.GetPedVehicleSeat = function(playerPed, vehicle)

client/main.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,16 @@ end
104104
MSK.Player = {}
105105
MSK.Player.clientId = PlayerId()
106106
MSK.Player.playerId = GetPlayerServerId(MSK.Player.clientId)
107+
MSK.Player.serverId = MSK.Player.playerId
107108

108109
CreateThread(function()
109110
while true do
110111
local sleep = 100
112+
113+
MSK.Player.clientId = PlayerId()
114+
MSK.Player.playerId = GetPlayerServerId(MSK.Player.clientId)
115+
MSK.Player.serverId = MSK.Player.playerId
116+
111117
local playerPed = PlayerPedId()
112118
MSK.Player.playerPed = playerPed
113119

fxmanifest.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ games { 'gta5' }
44
author 'Musiker15 - MSK Scripts'
55
name 'msk_core'
66
description 'Functions for MSK Scripts'
7-
version '2.4.10'
7+
version '2.4.11'
88

99
lua54 'yes'
1010

html/script.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ progressBarStop = (id) => {
202202
}
203203

204204
progressId = progressId + 1
205+
$.post(`https://${GetParentResourceName()}/progressEnd`)
205206
}
206207

207208
/* ----------------

0 commit comments

Comments
 (0)