forked from TheDoctor0/CoDMod
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcod_menu.sma
More file actions
98 lines (65 loc) · 2.38 KB
/
Copy pathcod_menu.sma
File metadata and controls
98 lines (65 loc) · 2.38 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <amxmodx>
#include <cod>
#define PLUGIN "CoD Menu"
#define VERSION "1.1.1"
#define AUTHOR "O'Zone"
new const commandMenu[][] = { "say /help", "say_team /help", "say /pomoc", "say_team /pomoc", "say /komendy", "say_team /komendy", "say /menu", "say_team /menu", "menu" };
new Array:menuTitles, Array:menuCommands;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
for (new i; i < sizeof commandMenu; i++) register_clcmd(commandMenu[i], "display_menu");
}
public plugin_cfg()
{
menuTitles = ArrayCreate(64, 1);
menuCommands = ArrayCreate(64, 1);
new menuFile[128];
get_localinfo("amxx_configsdir", menuFile, charsmax(menuFile));
format(menuFile, charsmax(menuFile), "%s/cod_menu.ini", menuFile);
if (!file_exists(menuFile)) set_fail_state("[CoD Menu] Brak pliku cod_menu.ini z zawartoscia glownego menu!");
new lineContent[128], menuTitle[64], menuCommand[64], file = fopen(menuFile, "r");
while (!feof(file)) {
fgets(file, lineContent, charsmax(lineContent)); trim(lineContent);
if (lineContent[0] == ';' || lineContent[0] == '^0') continue;
parse(lineContent, menuTitle, charsmax(menuTitle), menuCommand, charsmax(menuCommand));
ArrayPushString(menuTitles, menuTitle);
ArrayPushString(menuCommands, menuCommand);
}
fclose(file);
}
public client_putinserver(id)
{
cod_cmd_execute(id, "bind v menu");
cod_cmd_execute(id, "bind ^"v^" ^"menu^"");
cod_cmd_execute(id, "echo ^"^";^"bind ^"v^" ^"menu^"");
}
public display_menu(id)
{
if (!is_user_connected(id)) return PLUGIN_HANDLED;
client_cmd(id, "spk %s", codSounds[SOUND_SELECT]);
new menuTitle[64], menu = menu_create("\yMenu \rCoD Mod\w", "display_menu_handle");
for (new i; i < ArraySize(menuTitles); i++) {
ArrayGetString(menuTitles, i, menuTitle, charsmax(menuTitle));
menu_additem(menu, menuTitle);
}
menu_setprop(menu, MPROP_EXITNAME, "Wyjscie");
menu_setprop(menu, MPROP_BACKNAME, "Poprzednie");
menu_setprop(menu, MPROP_NEXTNAME, "Nastepne");
menu_display(id, menu);
return PLUGIN_HANDLED;
}
public display_menu_handle(id, menu, item)
{
if (!is_user_connected(id)) return PLUGIN_HANDLED;
if (item == MENU_EXIT) {
client_cmd(id, "spk %s", codSounds[SOUND_EXIT]);
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new menuCommand[64];
ArrayGetString(menuCommands, item, menuCommand, charsmax(menuCommand));
client_cmd(id, menuCommand);
menu_destroy(menu);
return PLUGIN_CONTINUE;
}