@@ -6,16 +6,174 @@ return {
6
6
--- Notice that an additional ~2 minutes will be waited due to limitations with how FiveM handles joining players.
7
7
joiningTimeoutSeconds = 0 ,
8
8
9
+ --- @class AdaptiveCardTextOptions
10
+ --- @field style ? ' default' | ' heading' | ' columnHeader'
11
+ --- @field fontType ? ' default' | ' monospace'
12
+ --- @field size ? ' small' | ' default' | ' medium' | ' large' | ' extralarge'
13
+ --- @field weight ? ' lighter' | ' default' | ' bolder'
14
+ --- @field color ? ' default' | ' dark' | ' light' | ' accent' | ' good' | ' warning' | ' attention'
15
+ --- @field isSubtle ? boolean
16
+
9
17
--- @class SubQueueConfig
10
18
--- @field name string
11
19
--- @field predicate ? fun ( source : Source ): boolean
20
+ --- @field cardOptions ? AdaptiveCardTextOptions Text options used in the adaptive card
12
21
13
22
--- Sub-queues from most to least prioritized.
14
23
--- The first sub-queue without a predicate function will be considered the default.
15
24
--- If a player doesn't pass any predicate and a sub-queue with no predicate does not exist they will not be let into the server unless a player slot is available.
16
25
--- @type SubQueueConfig[]
17
26
subQueues = {
18
- { name = ' Admin Queue' , predicate = function (source ) return HasPermission (source , ' admin' ) end },
27
+ { name = ' Admin Queue' , predicate = function (source ) return HasPermission (source , ' admin' ) end , cardOptions = { color = ' good ' } },
19
28
{ name = ' Regular Queue' },
20
29
},
30
+
31
+ --- Cosmetic emojis shown along with the elapsed queue time.
32
+ waitingEmojis = {
33
+ ' 🕛' ,
34
+ ' 🕒' ,
35
+ ' 🕕' ,
36
+ ' 🕘' ,
37
+ },
38
+
39
+ --- Use the adaptive card generator that is defined below.
40
+ useAdaptiveCard = true ,
41
+
42
+ --- @class GenerateCardParams
43
+ --- @field subQueue SubQueue
44
+ --- @field globalPos integer
45
+ --- @field totalQueueSize integer
46
+ --- @field displayTime string
47
+
48
+ --- Generator function for the adaptive card.
49
+ --- @param params GenerateCardParams
50
+ --- @return table
51
+ generateCard = function (params )
52
+ local subQueue = params .subQueue
53
+ local pos = params .globalPos
54
+ local size = params .totalQueueSize
55
+ local displayTime = params .displayTime
56
+
57
+ local serverName = GetConvar (' sv_projectName' , GetConvar (' sv_hostname' , ' Server' ))
58
+ local progressAmount = 7 -- amount of progress shown between the queue & server
59
+
60
+ local playerColumn = pos == 1 and progressAmount or (progressAmount - math.ceil (pos / (size / progressAmount )) + 1 )
61
+ local progressTextReplacements = {
62
+ [1 ] = {
63
+ text = ' Queue' ,
64
+ color = ' good' ,
65
+ },
66
+ [playerColumn + 1 ] = {
67
+ text = ' You' ,
68
+ color = ' good' ,
69
+ },
70
+ [progressAmount + 2 ] = {
71
+ text = ' Server' ,
72
+ color = ' good' ,
73
+ },
74
+ }
75
+
76
+ local progressColumns = {}
77
+ for i = 1 , progressAmount + 2 do
78
+ local textBlock = {
79
+ type = ' TextBlock' ,
80
+ text = ' •' ,
81
+ horizontalAlignment = ' center' ,
82
+ size = ' extralarge' ,
83
+ weight = ' lighter' ,
84
+ color = ' accent' ,
85
+ }
86
+
87
+ local replacements = progressTextReplacements [i ]
88
+ if replacements then
89
+ for k , v in pairs (replacements ) do
90
+ textBlock [k ] = v
91
+ end
92
+ end
93
+
94
+ local column = {
95
+ type = ' Column' ,
96
+ width = ' stretch' ,
97
+ verticalContentAlignment = ' center' ,
98
+ items = {
99
+ textBlock ,
100
+ }
101
+ }
102
+
103
+ progressColumns [i ] = column
104
+ end
105
+
106
+ return {
107
+ type = ' AdaptiveCard' ,
108
+ version = ' 1.6' ,
109
+ body = {
110
+ {
111
+ type = ' TextBlock' ,
112
+ text = ' In Line' ,
113
+ horizontalAlignment = ' center' ,
114
+ size = ' large' ,
115
+ weight = ' bolder' ,
116
+ },
117
+ {
118
+ type = ' TextBlock' ,
119
+ text = (' Joining %s' ):format (serverName ),
120
+ spacing = ' none' ,
121
+ horizontalAlignment = ' center' ,
122
+ size = ' medium' ,
123
+ weight = ' bolder' ,
124
+ },
125
+ {
126
+ type = ' ColumnSet' ,
127
+ spacing = ' large' ,
128
+ columns = progressColumns ,
129
+ },
130
+ {
131
+ type = ' ColumnSet' ,
132
+ spacing = ' large' ,
133
+ columns = {
134
+ {
135
+ type = ' Column' ,
136
+ width = ' stretch' ,
137
+ items = {
138
+ {
139
+ type = ' TextBlock' ,
140
+ text = subQueue .name ,
141
+ style = subQueue .cardOptions .style ,
142
+ fontType = subQueue .cardOptions .fontType ,
143
+ size = subQueue .cardOptions .size or ' medium' ,
144
+ color = subQueue .cardOptions .color ,
145
+ isSubtle = subQueue .cardOptions .isSubtle ,
146
+ }
147
+ },
148
+ },
149
+ {
150
+ type = ' Column' ,
151
+ width = ' stretch' ,
152
+ items = {
153
+ {
154
+ type = ' TextBlock' ,
155
+ text = (' %d/%d' ):format (pos , size ),
156
+ horizontalAlignment = ' center' ,
157
+ color = ' good' ,
158
+ size = ' medium' ,
159
+ }
160
+ },
161
+ },
162
+ {
163
+ type = ' Column' ,
164
+ width = ' stretch' ,
165
+ items = {
166
+ {
167
+ type = ' TextBlock' ,
168
+ text = displayTime ,
169
+ horizontalAlignment = ' right' ,
170
+ size = ' medium' ,
171
+ }
172
+ },
173
+ },
174
+ },
175
+ },
176
+ },
177
+ }
178
+ end ,
21
179
}
0 commit comments