Hello, I'm trying to make fakeclients crouch and shoot when I type .attack in chat, It only works randomly after I type the command a lot of times (at least >20). Anyone knows how to fix this?
PHP Code:
bool g_BotCrouching[MAXPLAYERS + 1];
//function called in .attack
stock bool ForceAttack(int client, int index = -1) {
int bot = GetClientBot(client, index);
if (bot > 0) {
g_BotCrouching[bot]=true;
return true;
}
return false;
}
public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3],
int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed,
int mouse[2]) {
if (client > 0 && IsClientInGame(client) && IsFakeClient(client)) {
if (g_BotCrouching[client]) {
buttons |= IN_DUCK; //this works
buttons |= IN_ATTACK;
CreateTimer(3.0, Timer_ShouldAttack, GetClientSerial(client));
return Plugin_Changed;
} else {
buttons &= ~IN_DUCK;
buttons &= ~IN_ATTACK;
}
}
return Plugin_Continue;
}
public Action Timer_ShouldAttack(Handle timer, int serial) {
int client = GetClientFromSerial(serial);
g_BotCrouching[client] = false;
return Plugin_Handled;
}
Im using
splewi's csgo practice mode fakeclients btw