Adding Action Menus
Learn how to use an Action Menu.
Actions menu's are a custom menu that makes various event calls either on server-side or client-side.

Benefits

  • Easily Customizable
  • Infinitely Scaleable
  • Used Server or Client Side
  • Can be Dynamically Created
  • 1 - 9 Hotkeys
  • Arrow Key Usage
  • Enter Keypress
  • Backspace Keypress

Usage

This is an example from the plugins folder. This is an over the top menu with multiple menu levels and pointless functionality.
1
import * as alt from 'alt-server';
2
import { playerFuncs } from '../../server/extensions/Player';
3
import ChatController from '../../server/systems/chat';
4
import { ANIMATION_FLAGS } from '../../shared/flags/animation';
5
import { PERMISSIONS } from '../../shared/flags/permissions';
6
import { Action } from '../../shared/interfaces/Actions';
7
import { Animation } from '../../shared/interfaces/Animation';
8
9
ChatController.addCommand('actionmenu', '/actionmenu - Opens test action menu', PERMISSIONS.ADMIN, handleCommand);
10
11
function handleCommand(player: alt.Player): void {
12
// Create an action called facePalm that uses the Animation Interface.
13
const facePalm: Action<Animation> = {
14
eventName: 'animation:Action:Server',
15
isServer: true,
16
data: {
17
dict: '[email protected]_player_intupperface_palm',
18
name: 'idle_a',
19
duration: 3000,
20
flags: ANIMATION_FLAGS.UPPERBODY_ONLY
21
}
22
};
23
24
// Create an action called gangSign that uses the Animation Interface.
25
const gangSign: Action<Animation> = {
26
eventName: 'animation:Action:Server',
27
isServer: true,
28
data: {
29
dict: 'mp_player_int_uppergang_sign_a',
30
name: 'mp_player_int_gang_sign_a',
31
duration: 3000,
32
flags: ANIMATION_FLAGS.UPPERBODY_ONLY
33
}
34
};
35
36
// Create the menu and send it to the player/
37
playerFuncs.set.actionMenu(
38
player,
39
// The Menu
40
{
41
// Option 1 in the menu is a single event.
42
'Option 1': {
43
eventName: 'hello:From:Client',
44
isServer: true
45
},
46
// Animations in the menu contains 2 more events. You can also add another menu.
47
Animations: {
48
'Face Palm': facePalm,
49
'Gang Sign': gangSign
50
// Creates a menu in the menu.
51
'More Animations': {
52
'Face Palm 2': facePalm, // Just using the same one for testing purposes
53
'Gang Sign 2': gangSign
54
// Creates a menu in the menu in the menu
55
'More More Animations': {
56
'Face Palm 3': facePalm, // Just using the same one for testing purposes
57
'Gang Sign 3': gangSign
58
// etc...
59
}
60
}
61
}
62
}
63
);
64
}
65
66
alt.onClient('hello:From:Client', (player) => {
67
playerFuncs.emit.message(player, `Got menu option from client.`);
68
});
69
70
alt.onClient('animation:Action:Server', (player, data: Animation) => {
71
if (!data) {
72
return;
73
}
74
75
playerFuncs.emit.animation(player, data.dict, data.name, data.flags, data.duration);
76
});
Copied!
Last modified 3mo ago
Copy link