复制程式
...
#include <fakemeta>
#include <hamsandwich>
...
public plugin_init()
{
...
register_forward(FM_PlayerPostThink, "fw_PlayerPostThink", 1)
...
}
...
public fw_PlayerPostThink(id)
{
new button, oldbutton
button = pev(id, pev_button)
oldbutton = pev(id, pev_oldbuttons)
if ((button & IN_USE) && (oldbutton & IN_USE))//这是E键,这两个一起用就是检测长按
{
//做某事//或者自爆什么的功能////写在这里
}
}
以下是按键常数
pev(entity, pev_button) or pev(entity, pev_oldbuttons) values
#
#define IN_ATTACK (1<<0)
#define IN_JUMP (1<<1)
#define IN_DUCK (1<<2)
#define IN_FORWARD (1<<3)
#define IN_BACK (1<<4)
#define IN_USE (1<<5)
#define IN_CANCEL (1<<6)
#define IN_LEFT (1<<7)
#define IN_RIGHT (1<<8)
#define IN_MOVELEFT (1<<9)
#define IN_MOVERIGHT (1<<10)
#define IN_ATTACK2 (1<<11)
#define IN_RUN (1<<12)
#define IN_RELOAD (1<<13)
#define IN_ALT1 (1<<14)
#define IN_SCORE (1<<15)
至于你那个G键,直接注册一个drop命令不就好了。