-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprogress_feedback_server.lua
More file actions
58 lines (43 loc) · 1.52 KB
/
progress_feedback_server.lua
File metadata and controls
58 lines (43 loc) · 1.52 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
-- Created by (c)The_GTA.
local currently_running_task = false;
local completion_percentage = 0;
local status_msg = "";
function spawnTask(routine, ...)
if (currently_running_task) then return false; end;
completion_percentage = 0;
status_msg = "";
local args = { ... };
triggerClientEvent("onServerProgressStart", root, status_msg);
currently_running_task = createThread(
function(thread)
routine(thread, unpack(args));
-- Tell the client that we finished.
triggerClientEvent("onServerProgressEnd", root);
-- We finished running.
currently_running_task = false;
end
);
currently_running_task.sustime(50);
return true;
end
function taskUpdate(percentage, message, fastUpdateClient)
if (currently_running_task) then
if (percentage) then
completion_percentage = percentage;
end
if (message) then
status_msg = message;
end
local doSendToClient = true;
if (fastUpdateClient == false) then
doSendToClient = currently_running_task.yield();
end
if (doSendToClient) then
-- Send an update to the client.
triggerClientEvent("onServerProgressUpdate", root, completion_percentage, status_msg);
end
if not (fastUpdateClient == false) then
currently_running_task.yield();
end
end
end