Thank you for the reply EasSidezz,
This is what I have:
Code:
new Handle:hEnableAutoRespawn;
new Handle:hAutoRespawnTime;
new Handle:hDisableManualRespawn;
bool:g_enableAttack[MAXPLAYERS+1] = false;
public OnPluginStart()
{
HookEvent("player_death", Event_PlayerDeath);
HookEvent("player_spawn", Event_PlayerSpawn);
}
public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
if(!GetConVarInt(hEnableAutoRespawn)){ return; }
new client_id = GetClientOfUserId(GetEventInt(event, "userid"));
CreateTimer(GetConVarFloat(hAutoRespawnTime), RespawnPlayer, client_id);
}
public Action:RespawnPlayer(Handle:timer, any:client)
{
if(!IsPlayerAlive(client)) { DispatchSpawn(client); }
}
public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon, &subtype, &cmdnum, &tickcount, &seed, mouse[2])
{
if(GetConVarInt(hDisableManualRespawn) == 1)
{
if(client > 0 && client <= MaxClients)
{
if(!g_enableAttack && buttons & IN_ATTACK)
{
buttons &= ~IN_ATTACK;
return Plugin_Handled;
}
}
//Fix spectate "free camera" functionality
if(!IsPlayerAlive(client) && GetClientTeam(client) != 1)
{
return Plugin_Handled;
}
}
return Plugin_Continue;
}
public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
if(!GetConVarInt(hEnableAutoRespawn)){ return; }
new client_id = GetClientOfUserId(GetEventInt(event, "userid"));
CreateTimer(5.0, timer_enableAttack, client_id);
}
public Action:timer_enableAttack(Handle:timer, any:client)
{
for(client = 1; client <= MaxClients; client++)
{
if(IsClientInGame(client) && IsPlayerAlive(client))
{
g_enableAttack[client] = true;
PrintToChat(client, "Attack timer: FIRED");
}
}
}
The timer is firing after 5 seconds, but it appears that it's still failing to negate IN_ATTACK.
From further testing, it appears that this glitch only happens when the player is holding attack1 while dead- and the player spawns while still holding attack1, which causes the dead client's input to become a live client's input- causing a random weapon to fire on the first frame of spawn? (I say first frame because the projectile hole is sometimes elevated and in a different direction then the direction the player spawns facing.)
Game is HL2DM if that helps