Quote:
Originally Posted by Ravrob
Here's the bit I'm using
Code:
public void OnGameFrame() {
if(GetEntProp(i, Prop_Data, "m_afButtonReleased") & IN_RELOAD){
PrintToChat(i, "You pressed the reload key!");
}
|
I think you should be using "m_afButtonPressed" to see if a button is pressed.
As Silvers stated you should be using OnPlayerRunCmd.
I too had problems with buttons being pressed. I learned that it was best to use OnPlayerRunCmd to check for button presses. I also learned that a single button press will register LOTS of button presses. To fix that I ended up adding a timer to the button press to ensure that the action couldn't occur again for the duration of the timer.
In this example the action occurs once and is prevented from occurring again for 3 seconds:
PHP Code:
new bool:g_wait[MAXPLAYERS + 1];
public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
{
if(buttons & IN_RELOAD && g_wait[client] == false)
{
//insert your command(s) here...
g_wait[client] = true;
CreateTimer(3.0, Waiting, client);
}
}
public Action:Waiting(Handle:timer, any:client)
{
g_wait[client] = false;
}