View Single Post
Author Message
ShadowMarioBR
Member
Join Date: Feb 2018
Old 06-24-2018 , 13:36   [TF2] Help with timer
Reply With Quote #1

This timer should give +1 primary ammo every 1.5 seconds, but apparently it's not working correctly

Quote:
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon)
{
!IsValidClient(client) || !IsPlayerAlive(client))
{
return Plugin_Continue;
}

if(medigunEquipped[client])
{
if (buttons & IN_ATTACK == IN_ATTACK || buttons & IN_ATTACK2 == IN_ATTACK2)
{
g_hAmmoTimer = CreateTimer(1.5, Timer_GiveAmmo, GetClientUserId(client), TIMER_REPEAT);
}
}

return Plugin_Continue;
}

public Action Timer_GiveAmmo(Handle timer, int client)
{
PrintToChatAll("Timer working");
if(IsValidClient(client) && IsPlayerAlive(client))
{
new primary = GetPlayerWeaponSlot(client, TFWeaponSlot_Primary);
new ammotype = GetEntProp(primary, Prop_Send, "m_iPrimaryAmmoType");
GivePlayerAmmo(client, 1, ammotype, true);
g_hAmmoTimer = INVALID_HANDLE;
}

if (g_hAmmoTimer != INVALID_HANDLE)
{
CloseHandle(g_hAmmoTimer);
g_hAmmoTimer = INVALID_HANDLE;
}

return Plugin_Handled;
}

Last edited by ShadowMarioBR; 06-24-2018 at 13:37. Reason: Accidentally pressed Enter before finishing the thread
ShadowMarioBR is offline