lenix 1.8.12 → 1.8.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/client/control.ts +103 -103
  2. package/package.json +1 -1
package/client/control.ts CHANGED
@@ -13,119 +13,121 @@ const EVENTS = {
13
13
  hold: IsControlPressed,
14
14
  release: IsControlJustReleased,
15
15
  released: IsControlReleased,
16
- disabled: IsDisabledControlJustPressed,
16
+
17
+ disabledPress: IsDisabledControlJustPressed,
18
+ disabledHold: IsDisabledControlPressed,
19
+ disabledRelease: IsDisabledControlJustReleased,
20
+ disabledReleased: IsDisabledControlReleased,
21
+
17
22
  disable: DisableControlAction,
18
23
  enable: EnableControlAction,
24
+ disableAll: DisableAllControlActions,
25
+ enableAll: EnableAllControlActions,
19
26
  }
20
27
  export const TYPES = {
21
28
  player: 0,
22
29
  camera: 1,
23
30
  frontend: 2,
24
31
  } as const
32
+ // TODO: add [PAUSE, END, SNAPSHOT, 0, i, j, o, LWIN, RWIN, NUMPAD[1-3], MULTIPLY, DECIMAL, DIVIDE, NUMPADEQUALS, NUMPADENTER, F[4, 13-24], NUMLOCK, SCROLL, RMENU, SEMICOLON, PLUS, SLASH, BACKSLASH, APOSTROPHE, , mouse axis, extra mouse bns, scrollwheels]
33
+ // NONE: [3, 5, 7, 28, 53, 65, 93, 94, 156, 193, 226, 227, 228, 230, 231, 239, 240, 247, 248, 258, 259, 260, 265, 292, 293, 294, 295]
25
34
  export const CONTROLS = {
26
- "V": [0, 236, 320, 325],
27
- "MOUSE RIGHT": [1, 6, 13, 66, 98, 220, 270, 271, 282, 283, 286, 287, 290, 333],
28
- "MOUSE DOWN": [2, 4, 12, 67, 95, 112, 198, 221, 273, 291, 293, 332],
29
- "S": [8, 33, 60, 72, 88, 126, 139, 149, 151, 196, 219, 233, 268, 269, 302],
30
- "D": [9, 30, 35, 59, 64, 90, 195, 218, 235, 267, 278, 279, 342],
31
- "PAGEUP": [10],
32
- "PAGEDOWN": [11],
33
- "SCROLLWHEEL DOWN": [14, 16, 50, 97, 180, 198, 242, 262, 334, 336],
34
- "SCROLLWHEEL UP": [17, 96, 99, 115, 181, 241, 261, 335],
35
- "ENTER": [18, 176, 191, 201, 215],
36
- "LEFT MOUSE BUTTON": [18, 24, 122, 135, 142, 144, 176, 223, 229, 237, 257, 329, 346],
37
- "SPACEBAR": [18, 22, 55, 76, 102, 143, 179, 203, 216, 255, 298, 321, 328, 353],
38
- "LEFT ALT": [19],
39
- "Z": [20, 48],
40
- "LEFT SHIFT": [21, 61, 131, 137, 155, 209, 254, 340, 352],
41
- "F": [23, 49, 56, 75, 144, 145, 251],
42
- "E": [23, 38, 46, 51, 54, 86, 103, 119, 184, 206, 350, 351, 355, 356],
43
- "RIGHT MOUSE BUTTON": [25, 68, 70, 91, 114, 177, 222, 225, 238, 330, 331, 347],
44
- "C": [26, 79, 253, 319, 324],
45
- "ARROW UP": [27, 172, 188, 300, 303],
46
- "B": [29, 170, 305],
47
- "W": [32, 61, 71, 77, 87, 111, 129, 136, 150, 232],
48
- "A": [34, 63, 89, 124, 133, 147, 234, 338],
49
- "LEFT CTRL": [36, 60, 62, 132, 210, 224, 280, 281, 326, 341, 343],
50
- "TAB": [37, 192, 204, 211, 349],
51
- "[": [39, 41, 43, 100, 116, 274, 275, 276, 277, 312],
52
- "]": [40, 42, 197, 313],
53
- "Q": [44, 52, 85, 138, 141, 152, 205, 264],
54
- "R": [45, 80, 140, 250, 263, 310],
55
- "G": [47, 58, 113, 183],
56
- "F9": [56],
57
- "F10": [57],
58
- "X": [73, 105, 120, 131, 154, 186, 203, 214, 224, 252, 256, 296, 323, 337, 345, 349, 354, 357],
59
- "H": [74, 101, 104, 304],
60
- ".": [81],
61
- ",": [82],
62
- "=": [83],
63
- "-": [84],
64
- "NUMPAD-": [96],
65
- "NUMPAD+": [97, 314],
66
- "NUMPAD 6": [107, 109, 123, 125],
67
- "NUMPAD 4": [108, 124],
68
- "NUMPAD 5": [110, 112, 126, 128],
69
- "NUMPAD 8": [111, 127],
70
- "NUMPAD 7": [117],
71
- "NUMPAD 9": [118],
72
- "INSERT": [121],
73
- "1": [157],
74
- "2": [158],
75
- "6": [159],
76
- "3": [160],
77
- "7": [161],
78
- "8": [162],
79
- "9": [163],
80
- "4": [164],
81
- "5": [165],
82
- "F5": [166, 318, 327],
83
- "F6": [167],
84
- "F7": [168],
85
- "F8": [169],
86
- "F3": [170],
87
- "CAPSLOCK": [137, 171, 217],
88
- "ARROW DOWN": [173, 187, 233, 299],
89
- "ARROW LEFT": [174, 189, 308],
90
- "ARROW RIGHT": [175, 190, 307],
91
- "BACKSPACE": [177, 194, 202],
92
- "DELETE": [178, 214, 256, 296],
93
- "Y": [178, 204, 246, 348],
94
- "ESC": [177, 200, 202, 322],
95
- "P": [199],
96
- "NUMPAD ENTER": [201],
97
- "PAGE DOWN": [207, 317],
98
- "PAGE UP": [208, 316],
99
- "HOME": [212, 213],
100
- "T": [245, 309],
101
- "M": [244, 301],
102
- "N": [249, 306],
103
- "~": [243],
104
- "`": [243],
105
- "K": [311],
106
- "U": [303],
107
- "F1": [288],
108
- "F2": [289],
109
- "F11": [344],
110
- "SCROLLWHEEL BUTTON (PRESS)": [27, 348]
35
+ MOUSE_LEFT: [18, 24, 69, 92, 106, 122, 135, 142, 144, 176, 223, 229, 237, 257, 329, 346],
36
+ D: [9, 20, 35, 59, 64, 90, 134, 146, 148, 195, 218, 235, 266, 267, 278, 279, 339, 342],
37
+ S: [8, 31, 33, 72, 78, 88, 130, 139, 149, 151, 196, 219, 233, 268, 269, 302],
38
+ SPACE: [18, 22, 55, 76, 102, 143, 179, 203, 216, 255, 298, 321, 328, 353],
39
+ MOUSE_RIGHT: [25, 68, 70, 91, 114, 177, 222, 225, 238, 330, 331, 347],
40
+ E: [38, 46, 51, 54, 86, 103, 119, 153, 184, 206, 350, 351, 355, 356],
41
+ LCONTROL: [36, 60, 62, 132, 210, 224, 280, 281, 326, 341, 343],
42
+ LBRACKET: [39, 41, 43, 100, 116, 274, 275, 276, 277, 312],
43
+ X: [73, 105, 120, 154, 186, 252, 323, 337, 345, 354, 357],
44
+ LSHIFT: [21, 61, 131, 155, 209, 254, 340, 352],
45
+ Q: [44, 52, 85, 138, 141, 152, 205, 264],
46
+ W: [32, 71, 77, 87, 129, 136, 150, 232],
47
+ A: [34, 63, 89, 133, 147, 234, 338],
48
+ F: [23, 49, 75, 144, 145, 185, 251],
49
+ DELETE: [178, 214, 256, 296, 297],
50
+ RETURN: [18, 176, 191, 201, 215],
51
+ R: [45, 80, 140, 250, 263, 310],
52
+ TAB: [37, 192, 204, 211, 349],
53
+ NUMPAD6: [107, 109, 123, 125],
54
+ NUMPAD5: [110, 112, 126, 128],
55
+ RBRACKET: [40, 42, 197, 313],
56
+ ESCAPE: [177, 200, 202, 322],
57
+ C: [26, 79, 253, 319, 324],
58
+ LEFT: [174, 189, 190, 308],
59
+ CAPITAL: [137, 171, 217],
60
+ PAGEDOWN: [11, 207, 317],
61
+ MOUSE_MIDDLE: [27, 348],
62
+ UP: [27, 172, 188, 300],
63
+ PAGEUP: [10, 208, 316],
64
+ V: [0, 236, 320, 325],
65
+ DOWN: [173, 187, 299],
66
+ G: [47, 183, 58, 113],
67
+ H: [74, 101, 104, 304],
68
+ BACK: [177, 194, 202],
69
+ RIGHT: [175, 307],
70
+ SUBTRACT: [96, 315],
71
+ NUMPAD4: [108, 124],
72
+ NUMPAD8: [111, 127],
73
+ HOME: [212, 213],
74
+ Z: [20, 48],
75
+ B: [19, 305],
76
+ M: [244, 301],
77
+ T: [245, 309],
78
+ N: [249, 306],
79
+ LMENU: [19],
80
+ PERIOD: [81],
81
+ COMMA: [82],
82
+ EQUALS: [83],
83
+ MINUS: [84],
84
+ ADD: [97, 314],
85
+ NUMPAD7: [117],
86
+ NUMPAD9: [118],
87
+ INSERT: [121],
88
+ NUMPADENTER: [201],
89
+ GRAVE: [243],
90
+ 1: [157],
91
+ 2: [158],
92
+ 6: [159],
93
+ 3: [160],
94
+ 7: [161],
95
+ 8: [162],
96
+ 9: [163],
97
+ 4: [164],
98
+ 5: [165],
99
+ L: [182],
100
+ P: [199],
101
+ Y: [246],
102
+ U: [303],
103
+ K: [311],
104
+ F1: [288],
105
+ F2: [289],
106
+ F3: [170],
107
+ F5: [166, 318, 327],
108
+ F6: [167],
109
+ F7: [168],
110
+ F8: [169],
111
+ F9: [56],
112
+ F10: [57],
113
+ F11: [344],
111
114
  } as const
112
115
 
116
+
113
117
  const binds = new Set<Bind>()
114
118
 
115
119
  const on = ({
116
120
  event,
117
121
  key,
118
- onEvent: cb,
122
+ onEvent,
119
123
  type = 'player',
120
- }: Omit<Bind, 'event' | 'type'> & {
121
- type?: Bind['type']
122
- } & {
123
- event: Exclude<Bind['event'], 'disable' | 'enable'>
124
+ }: Bind & {
125
+ event: Extract<Bind['event'], 'press' | 'hold' | 'release' | 'released' | 'disabledPress' | 'disabledHold' | 'disabledRelease' | 'disabledReleased'>
124
126
  }) => {
125
127
  asserts(CONTROLS[key], `Could not find key<${key}>`)
126
128
 
127
129
  const bind = {
128
- event, key, onEvent: cb, type
130
+ event, key, onEvent, type
129
131
  }
130
132
  binds.add(bind)
131
133
 
@@ -134,35 +136,33 @@ const on = ({
134
136
  const disable = ({
135
137
  key,
136
138
  type = 'player',
137
- }: Pick<Bind, 'key'> & {
139
+ }: {
140
+ key: Bind['key'] | true
138
141
  type?: Bind['type']
139
142
  }) => {
140
- asserts(CONTROLS[key], `Could not find key<${key}>`)
141
-
142
143
  binds.add({
143
- event: 'disable', key, onEvent: () => {}, type
144
+ event: key === true ? 'disableAll' : 'disable', key: 'A' /* anything */, onEvent: () => {}, type
144
145
  })
145
146
  }
146
147
  const enable = ({
147
148
  key,
148
149
  type = 'player',
149
- }: Pick<Bind, 'key'> & {
150
+ }: {
151
+ key: Bind['key'] | true
150
152
  type?: Bind['type']
151
153
  }) => {
152
- asserts(CONTROLS[key], `Could not find key<${key}>`)
153
-
154
154
  binds.add({
155
- event: 'enable', key, onEvent: () => {}, type
155
+ event: key === true ? 'enableAll' : 'enable', key: 'A' /* anything */, onEvent: () => {}, type
156
156
  })
157
157
  }
158
158
 
159
- pool(() => binds.forEach(({ event, key, onEvent: cb, type }) => {
160
- for (const index of CONTROLS[key]) {
159
+ pool(() => {
160
+ for (const { event, key, onEvent: cb, type } of binds) for (const index of CONTROLS[key]) {
161
161
  if (!EVENTS[event](TYPES[type], index, true)) continue
162
162
  cb()
163
163
  break
164
164
  }
165
- }))
165
+ })
166
166
 
167
167
  /**
168
168
  * @beta This API is in beta. Use with caution.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lenix",
3
- "version": "1.8.12",
3
+ "version": "1.8.13",
4
4
  "description": "Typed FiveM utilities for client, server, shared, and NUI scripts",
5
5
  "author": "Lenix",
6
6
  "license": "MIT",