Skip to content

Commit 4b7716b

Browse files
committed
feat(scoreboard): add new status indicator features
1 parent 1b5c34c commit 4b7716b

File tree

8 files changed

+151
-59
lines changed

8 files changed

+151
-59
lines changed

bun.lockb

0 Bytes
Binary file not shown.

index.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@import 'tailwindcss';
22

33
/* hide dummy lines used to force TypeScript Type highlighting */
4-
code.nextra-code span[data-highlighted-line-id="hideDummyLine"] {
4+
code.nextra-code span[data-highlighted-line-id='hideDummyLine'] {
55
display: none;
66
}
77

pages/scoreboard/config.mdx

+10-2
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ type DUMMY =
180180
{
181181
label: string; // Name of the group row shown in scoreboard
182182
groups: string[]; // Array of groups to include in this row's total count
183+
includeOffDuty?: boolean; // Include off-duty players in total count (overrides the global setting)
183184
}
184185
```
185186
@@ -188,7 +189,8 @@ type DUMMY =
188189
## statusIndicators
189190
Individual status indicators shown in the section.
190191
For more information on how to use custom icons, see the guide [here](./issues#status-indicator-icon-is-not-showing).
191-
To learn how to change the state of these indicators, see the guide [here](./guides/status-indicators).
192+
To learn how to change the state of these indicators manually, see the guide [here](./guides/status-indicators/manual).
193+
More information about automatically enabling indicators using groups can be found [here](./guides/status-indicators/group-trigger).
192194
193195
**Accepted values**
194196
`table[]` with the following structure:
@@ -200,4 +202,10 @@ type DUMMY =
200202
label: string; // Label visible in the hover tooltip
201203
icon: string; // Icon of the indicator, must be a valid Iconify name
202204
defaultState?: boolean; // Default state of the indicator; true = on, false = off
203-
}
205+
groupTrigger?: { // Automatically enable the indicator when the requirements below are met
206+
groups: string[]; // Array of groups required to enable the indicator
207+
minimumCount: number; // Minimum count of players with the groups above to enable the indicator
208+
includeOffDuty?: boolean; // Whether to include off-duty players in the `minimumCount`
209+
};
210+
}
211+
```
+8-55
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,11 @@
1-
import { Steps } from 'nextra/components'
1+
import Link from 'next/link';
22

3-
# Change states of status indicators
3+
# Status indicators
44

5-
You can change the states of individual status indicators.
6-
This is useful if you want to indicate certain YES or NO states for players.
5+
You can either manually change the state of a status indicator, or use the integrated minimum group trigger.
6+
Both methods are explained in their respective sections.
77

8-
This guide will show you how to change the state of `house_robbery` status indicator, but it works the same for all indicators.
9-
10-
11-
12-
## Requirements
13-
- ability to write your own custom logic for controlling the states
14-
15-
16-
17-
## Configuration
18-
You need to find the status indicator ID. This can be found in the `config.lua` file.
19-
Each status indicator needs to have a unique ID so you can identify it.
20-
21-
```lua filename="config.lua" {2} /'house_robbery'/
22-
statusIndicators = {
23-
{ id = 'house_robbery', label = 'House robbery', icon = 'mdi:house', defaultState = true },
24-
{ id = 'store_robbery', label = 'Store robbery', icon = 'mdi:store', defaultState = false },
25-
{ id = 'bank_robbery', label = 'Bank robbery', icon = 'mdi:bank' },
26-
},
27-
```
28-
29-
30-
31-
## Steps
32-
33-
<Steps>
34-
35-
### Create a custom server resource
36-
The state can be only changed from server-side resources.
37-
Create a new resource (or use an existing one) and add the following custom logic to it's server-side file.
38-
39-
### Use the `setIndicatorState` export
40-
```lua filename="server.lua" /'house_robbery'/ /true/
41-
exports.ac_scoreboard:setIndicatorState('house_robbery', true)
42-
```
43-
44-
The first argument is the indicator ID from `config.lua`.
45-
The second argument is a boolean value that sets the corresponding state.
46-
47-
You can also use non-networked `ac_scoreboard:setIndicatorState` server event, which works the same way.
48-
```lua filename="server.lua" /'house_robbery'/ /true/
49-
TriggerEvent('ac_scoreboard:setIndicatorState', 'house_robbery', true)
50-
```
51-
52-
### Test it
53-
Run your custom logic and see how the indicator state changes.
54-
All indicator changes take effect immediately after reopening the scoreboard.
55-
56-
**In case it's not working, read this whole page again from the beginning and check if you missed something.**
57-
58-
</Steps>
8+
<div className="flex gap-2 mt-4">
9+
<Link href="./status-indicators/group-trigger" className="bg-gray-700 p-2 rounded-md w-fit text-white font-medium hover:bg-gray-600 transition-colors">Group trigger</Link>
10+
<Link href="./status-indicators/manual" className="bg-gray-700 p-2 rounded-md w-fit text-white font-medium hover:bg-gray-600 transition-colors">Manual</Link>
11+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
'group-trigger': 'Group trigger',
3+
manual: 'Manual',
4+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { Steps } from 'nextra/components'
2+
3+
# Group count based automation of states
4+
5+
You can use the integrated option to automatically change the states of status indicators based on the count of players in specified groups.
6+
7+
This guide will show you how to configure the `bank_robbery` status indicator, but it works the same for all indicators.
8+
9+
10+
11+
## Configuration
12+
You have to set the desired values in the `config.lua` file.
13+
The entire configuration is done using the `groupTrigger` field.
14+
15+
```lua filename="config.lua" {6-10} /'bank_robbery'/
16+
statusIndicators = {
17+
{
18+
id = 'bank_robbery',
19+
label = 'Bank robbery',
20+
icon = 'mdi:bank',
21+
groupTrigger = {
22+
groups = {'police', 'sheriff'},
23+
minimumCount = 12,
24+
includeOffDuty = true,
25+
},
26+
},
27+
},
28+
```
29+
30+
**`groups`**
31+
Array of group names whose total count will be compared to the `minimumCount` value.
32+
If the total count is greater or equal to the `minimumCount`, the indicator will be enabled.
33+
34+
**`minimumCount`**
35+
Minimum count of players in the specified groups to enable the indicator.
36+
37+
**`includeOffDuty`**
38+
Whether to include off-duty players in the total count.
39+
40+
41+
42+
## Overriding the current state
43+
You can still manually change the state of the indicator, even if it's set to be automatically controlled.
44+
However, this doing so will forcibly override the automated state until you remove the manual override.
45+
46+
You can do so using the `forceIndicatorState` export.
47+
The following example will force the `bank_robbery` indicator to be enabled no matter the group count.
48+
```lua copy filename="server.lua" /'bank_robbery'/ /true/
49+
exports.ac_scoreboard:forceIndicatorState('bank_robbery', true)
50+
51+
-- or use non-networked server event
52+
TriggerEvent('ac_scoreboard:forceIndicatorState', 'bank_robbery', true)
53+
```
54+
55+
The first argument is the indicator ID from `config.lua`.
56+
The second argument is a boolean value that forces the corresponding state.
57+
58+
If you want to remove the manual override, you can use the same export with the second argument set to `nil`.
59+
```lua copy filename="server.lua" /nil/
60+
exports.ac_scoreboard:forceIndicatorState('bank_robbery', nil)
61+
```
62+
63+
Keep in mind that you cannot use the `setIndicatorState` export to change the state of indicators that are set to be automatically controlled. You can only use this (`forceIndicatorState`) export to temporarily override the automated state.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { Steps } from 'nextra/components'
2+
3+
# Manually change states of status indicators
4+
5+
You can change the states of individual status indicators.
6+
This is useful if you want to indicate certain YES or NO states for players.
7+
8+
This guide will show you how to change the state of `house_robbery` status indicator, but it works the same for all indicators.
9+
10+
11+
12+
## Requirements
13+
- ability to write your own custom logic for controlling the states
14+
15+
16+
17+
## Configuration
18+
You need to find the status indicator ID. This can be found in the `config.lua` file.
19+
Each status indicator needs to have a unique ID so you can identify it.
20+
21+
```lua filename="config.lua" {3} /'house_robbery'/
22+
statusIndicators = {
23+
{
24+
id = 'house_robbery',
25+
label = 'House robbery',
26+
icon = 'mdi:house',
27+
defaultState = true,
28+
},
29+
},
30+
```
31+
32+
33+
34+
## Steps
35+
36+
<Steps>
37+
38+
### Create a custom server resource
39+
The state can be only changed from server-side resources.
40+
Create a new resource (or use an existing one) and add the following custom logic to it's server-side file.
41+
42+
### Use the `setIndicatorState` export
43+
```lua copy filename="server.lua" /'house_robbery'/ /true/
44+
exports.ac_scoreboard:setIndicatorState('house_robbery', true)
45+
46+
-- or use non-networked server event
47+
TriggerEvent('ac_scoreboard:setIndicatorState', 'house_robbery', true)
48+
```
49+
50+
The first argument is the indicator ID from `config.lua`.
51+
The second argument is a boolean value that sets the corresponding state.
52+
53+
### Test it
54+
Run your custom logic and see how the indicator state changes.
55+
All indicator changes take effect immediately after reopening the scoreboard.
56+
57+
**In case it's not working, read this whole page again from the beginning and check if you missed something.**
58+
59+
</Steps>

pages/scoreboard/issues.mdx

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ In case you don't know how to do this, just download the latest prebuilt version
1010
## Status indicator icon is not showing
1111
The icon must be a valid **Iconify** icon. You can find the list on [Icônes.js](https://icones.js.org/).
1212
Simply find your desired icon and copy it's name as shown in the example below.
13-
![Icon on Icones.js](/images/examples/ac_scoreboard/icones-icon.png)
13+
![Icon on Icones.js](/images/examples/ac_scoreboard/icones-icon.png)
14+
15+
## Status indicator is not changing while using `setIndicatorState` export
16+
For more information, see the [status indicators guide](./guides/status-indicators).
17+
- Make sure you're using the correct indicator ID.
18+
- This export can be only used to control indicators that don't have the `groupTrigger` field set in the `config.lua` file. If you want to temporarily override state of indicator with `groupTrigger`, use the `forceIndicatorState` export instead.

0 commit comments

Comments
 (0)