-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
241 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
amxmodx/scripting/EMS/DefaultObjects/Controllers/Default.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#if defined _ems_src__default_objects__controllers__default_included | ||
#endinput | ||
#endif | ||
#define _ems_src__default_objects__controllers__default_included | ||
|
||
#include <amxmodx> | ||
#include <ems> | ||
|
||
T_MenuController:DefaultObjects_DefaultController_Register() { | ||
new T_MenuController:handler = EMS_MenuController_Register(EMS_DEFAULT_CONTROLLER_KEY, "@DefaultObjects_DefaultController_Callback"); | ||
EMS_MenuController_AddParams(handler, | ||
"Items", EMS_MENU_ITEMS_PARAM_TYPE, true | ||
); | ||
|
||
return handler; | ||
} | ||
|
||
@DefaultObjects_DefaultController_Callback(const playerIndex, const menu, const Trie:params) { | ||
new Array:items = Invalid_Array; | ||
if (!TrieGetCell(params, "Items", items) || items == Invalid_Array) { | ||
abort(AMX_ERR_PARAMS, "Failed to get items array."); | ||
return; | ||
} | ||
|
||
for (new i = 0, ii = ArraySize(items); i < ii; ++i) { | ||
new menuItemData[S_Param_MenuItem]; | ||
ArrayGetArray(items, i, menuItemData); | ||
|
||
// TODO: юзать прослойку с эмитом ивентов | ||
menu_additem(menu, menuItemData[Param_MenuItem_Title], menuItemData[Param_MenuItem_Command]); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
amxmodx/scripting/EMS/DefaultObjects/Controllers/Players.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#if defined _ems_src__default_objects__controllers__players_included | ||
#endinput | ||
#endif | ||
#define _ems_src__default_objects__controllers__players_included | ||
|
||
#include <amxmodx> | ||
#include <ems> | ||
|
||
T_MenuController:DefaultObjects_PlayersController_Register() { | ||
new T_MenuController:handler = EMS_MenuController_Register(EMS_PLAYERS_CONTROLLER_KEY, "@DefaultObjects_PlayersController_Callback"); | ||
EMS_MenuController_AddParams(handler, | ||
// TODO: title template | ||
"Title", "String", false, | ||
"Command", "String", true, | ||
"ExcludeDead", "Boolean", false | ||
); | ||
|
||
return handler; | ||
} | ||
|
||
@DefaultObjects_PlayersController_Callback(const playerIndex, const menu, const Trie:params) { | ||
static titleTemplate[EMS_MENU_TITLE_MAX_LEN], title[EMS_MENU_TITLE_MAX_LEN]; | ||
TrieGetString(params, "Title", titleTemplate, charsmax(titleTemplate)); | ||
|
||
if (titleTemplate[0] == EOS) { | ||
copy(title, charsmax(title), "{i:playerName}"); | ||
} | ||
|
||
static commandTemplate[EMS_MENU_ITEM_COMMAND_MAX_LEN], command[EMS_MENU_ITEM_COMMAND_MAX_LEN]; | ||
TrieGetString(params, "Command", commandTemplate, charsmax(commandTemplate)); | ||
|
||
|
||
new bool:excludeDead = false; | ||
TrieGetCell(params, "ExcludeDead", excludeDead); | ||
|
||
for (new i = 1; i <= MAX_PLAYERS; ++i) { | ||
if (!is_user_connected(i)) { | ||
continue; | ||
} | ||
|
||
if (excludeDead && !is_user_alive(i)) { | ||
continue; | ||
} | ||
|
||
copy(title, charsmax(title), titleTemplate); | ||
copy(command, charsmax(command), commandTemplate); | ||
|
||
static name[32]; | ||
get_user_name(i, name, charsmax(name)); | ||
static index[11]; | ||
num_to_str(i, index, charsmax(index)); | ||
|
||
// TODO: мб сделать что-то типа компиляции шаблонов | ||
replace_all(title, charsmax(title), "{i:playerIndex}", index); | ||
replace_all(title, charsmax(title), "{i:playerName}", name); | ||
|
||
replace_all(command, charsmax(command), "{i:playerIndex}", index); | ||
replace_all(command, charsmax(command), "{i:playerName}", name); | ||
|
||
// TODO: юзать прослойку с эмитом ивентов | ||
menu_additem(menu, title, command); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#if defined _ems_src__default_objects__extensions__test_included | ||
#endinput | ||
#endif | ||
#define _ems_src__default_objects__extensions__test_included | ||
|
||
#include <amxmodx> | ||
#include <ems> | ||
#include <ParamsController> | ||
|
||
T_MenuExtension:DefaultObjects_TestExtension_Register() { | ||
new T_MenuExtension:handler = EMS_MenuExtension_Register("Test"); | ||
EMS_MenuExtension_AddParams(handler, | ||
"Prefix", "ShortString", false | ||
); | ||
EMS_MenuExtension_RegisterEventHandler(handler, MenuEvent_MakeTitle, "@DefaultObjects_TestExtension_MakeTitle"); | ||
EMS_MenuExtension_RegisterEventHandler(handler, MenuEvent_Create, "@DefaultObjects_TestExtension_Create"); | ||
EMS_MenuExtension_RegisterEventHandler(handler, MenuEvent_MakeItem, "@DefaultObjects_TestExtension_MakeItem"); | ||
|
||
return handler; | ||
} | ||
|
||
@DefaultObjects_TestExtension_MakeTitle(title[EMS_MENU_TITLE_MAX_LEN], const Trie:params) { | ||
new prefix[PARAM_SHORT_STRING_MAX_LEN]; | ||
TrieGetString(params, "Prefix", prefix, charsmax(prefix)); | ||
if (prefix[0] == EOS) { | ||
copy(prefix, charsmax(prefix), "Test"); | ||
} | ||
|
||
// Надо бы прокидывать длину буфера в колбек | ||
format(title, charsmax(title), "[%s] %s", prefix, title); | ||
} | ||
|
||
@DefaultObjects_TestExtension_Create(const menu, const Trie:params) { | ||
// Хз чё тут делать) | ||
// TODO: Придумать | ||
} | ||
|
||
@DefaultObjects_TestExtension_MakeItem(title[EMS_MENU_ITEM_TITLE_MAX_LEN], command[EMS_MENU_ITEM_COMMAND_MAX_LEN], const Trie:params) { | ||
new prefix[PARAM_SHORT_STRING_MAX_LEN]; | ||
TrieGetString(params, "Prefix", prefix, charsmax(prefix)); | ||
if (prefix[0] == EOS) { | ||
copy(prefix, charsmax(prefix), "Test"); | ||
} | ||
|
||
format(title, charsmax(title), "[%s] %s", prefix, title); | ||
format(command, charsmax(command), "say ^"%s^";%s", prefix, command); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.