Quote:
Originally Posted by ShadowMarioBR
This timer should give +1 primary ammo every 1.5 seconds, but apparently it's not working correctly
|
Let's see. OnPlayerRunCmd is called every 1 / 100 seconds
You create a repetitive timer 100 times in a second.
The player will start getting 6000 ammo every 1.5 seconds after a minute.
After an hour, the player will get 21600000 ammo every 1.5 seconds.
Just do this:
[code]
#include <sourcemod>
new hTimerAmmo = INVALID_HANDLE;
public OnPluginStart()
{
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
}
public OnMapStart()
{
hTimerAmmo = INVALID_HANDLE;
}
public Event_RoundStart(Handle:hEvent, const String:Name[], bool:dontBroadcast)
{
if(hTimerAmmo != INVALID_HANDLE)
{
CloseHandle(hTimerAmmo);
hTimerAmmo = INVALID_HANDLE;
}
hTimerAmmo = CreateTimer(1.5, GiveAllAmmo, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
public Action:GiveAllAmmo(Handle:hTimer)
{
// Give ammo stuff here, will be executed every 1.5 seconds.
return Plugin_Continue;
}
__________________
I am available to make plugins for pay.
Discord: Eyal282#1334