Difference between revisions of "Ru Button constants (AMX Mod X)"
(→Использование) |
(→Константы) |
||
| Line 17: | Line 17: | ||
Полный список всех констант вы можете найти здесь: | Полный список всех констант вы можете найти здесь: | ||
http://amxmodx.org/funcwiki.php?go=module&id=3#const_buttons | http://amxmodx.org/funcwiki.php?go=module&id=3#const_buttons | ||
| + | |||
| + | ==Как все это замутить?== | ||
| + | Вот, например, один из вариантов, как "поймать" момент, когда игрок атакует: | ||
| + | <pre> | ||
| + | #include <amxmodx> | ||
| + | #include <engine> | ||
| + | |||
| + | public plugin_init() | ||
| + | { | ||
| + | register_plugin("Attack Test","1.0","Hawk552"); | ||
| + | } | ||
| + | |||
| + | public client_PreThink(id) | ||
| + | { | ||
| + | if(entity_get_int(id,EV_INT_BUTTON) & IN_ATTACK) | ||
| + | { | ||
| + | // do something | ||
| + | } | ||
| + | } | ||
| + | </pre> | ||
| + | |||
| + | Обратите внимание, что используется оператор & , в отличии от оператора &&. Оператор & проверяет, содержится ли бит после оператора в бите до него, т.е. в данном случае проверяется, есть ли среди нажатых кнопок игрока кнопка IN_ATTACK | ||
| + | |||
| + | Чтобы заставить энтити эмулировать нажатие кнопки можно поступить следующим образом: | ||
| + | <pre> | ||
| + | #include <amxmodx> | ||
| + | #include <engine> | ||
| + | |||
| + | public plugin_init() | ||
| + | { | ||
| + | register_plugin("Attack Test","1.0","Hawk552"); | ||
| + | } | ||
| + | |||
| + | public client_PreThink(id) | ||
| + | { | ||
| + | entity_set_int(id,EV_INT_button,IN_ATTACK); | ||
| + | } | ||
| + | </pre> | ||
| + | |||
| + | Этот пример будет ставить флаг кнопки атаки в положение "ВКЛ" каждый раз, когда рендерится кадр. | ||
| + | |||
| + | To get an entity's buttons, and then ommit a certain button, one would use the following: | ||
| + | <pre> | ||
| + | #include <amxmodx> | ||
| + | #include <engine> | ||
| + | |||
| + | public plugin_init() | ||
| + | { | ||
| + | register_plugin("Attack Test","1.0","Hawk552"); | ||
| + | } | ||
| + | |||
| + | public client_PreThink(id) | ||
| + | { | ||
| + | entity_set_int(id,EV_INT_button,entity_get_int(id,EV_INT_button) & ~IN_ATTACK); | ||
| + | } | ||
| + | </pre> | ||
| + | |||
| + | Say, for example, during a certain time, the client is jumping and attacking at the same time. In this case, the entity_get_int(id,EV_INT_button) function would return IN_ATTACK and IN_JUMP. Using the ~ operator removes the certain bit value, making it into merely IN_JUMP. | ||
| + | |||
| + | There are many more ways to use button constants, and not all must be used on players. They are simply more commonly implemented when dealing with players. | ||
| + | |||
| + | [[Category:Scripting (AMX Mod X)]] | ||
Revision as of 12:13, 8 December 2006
| Warning: This template (and by extension, language format) should not be used, any pages using it should be switched to Template:Languages | |
|
View this page in: English Russian 简体中文(Simplified Chinese) | |
Использование
Кнопочные константы обычно используются для того, чтобы "поймать" момент, когда entity совершает какое либо действие, такое как прыжки, передвижение или атака. Метод используется из-за того, что жвижок ХЛ не может "поймать" +/- команды
Например, Это будет работать:
register_concmd("+explode","explode");
А это - нет:
register_concmd("+attack","hook_attack");
Константы
Полный список всех констант вы можете найти здесь: http://amxmodx.org/funcwiki.php?go=module&id=3#const_buttons
Как все это замутить?
Вот, например, один из вариантов, как "поймать" момент, когда игрок атакует:
#include <amxmodx>
#include <engine>
public plugin_init()
{
register_plugin("Attack Test","1.0","Hawk552");
}
public client_PreThink(id)
{
if(entity_get_int(id,EV_INT_BUTTON) & IN_ATTACK)
{
// do something
}
}
Обратите внимание, что используется оператор & , в отличии от оператора &&. Оператор & проверяет, содержится ли бит после оператора в бите до него, т.е. в данном случае проверяется, есть ли среди нажатых кнопок игрока кнопка IN_ATTACK
Чтобы заставить энтити эмулировать нажатие кнопки можно поступить следующим образом:
#include <amxmodx>
#include <engine>
public plugin_init()
{
register_plugin("Attack Test","1.0","Hawk552");
}
public client_PreThink(id)
{
entity_set_int(id,EV_INT_button,IN_ATTACK);
}
Этот пример будет ставить флаг кнопки атаки в положение "ВКЛ" каждый раз, когда рендерится кадр.
To get an entity's buttons, and then ommit a certain button, one would use the following:
#include <amxmodx>
#include <engine>
public plugin_init()
{
register_plugin("Attack Test","1.0","Hawk552");
}
public client_PreThink(id)
{
entity_set_int(id,EV_INT_button,entity_get_int(id,EV_INT_button) & ~IN_ATTACK);
}
Say, for example, during a certain time, the client is jumping and attacking at the same time. In this case, the entity_get_int(id,EV_INT_button) function would return IN_ATTACK and IN_JUMP. Using the ~ operator removes the certain bit value, making it into merely IN_JUMP.
There are many more ways to use button constants, and not all must be used on players. They are simply more commonly implemented when dealing with players.