Raised This Month: $51 Target: $400
 12% 

[TF2] Help with timer


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:09.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode