I'm trying to include this plugin on my l4d1 co-op server, but there is an issue with it: at round start of opening chapter it will give 1 set of pills to each survivor -as it should do. However on each subsequent chapter it gives 2 sets of pills to each survivor instead of the 1 that they should get.
Anyone know why this is happening? Below is the code from the script, perhaps some experienced coder here may see what is causing this issue. Any help on this would be most appreciated.
PHP Code:
/*
* 1.1.2
* - Update URL in plugin info.
* - Cleaned up some more code.
* 1.1.1
* - Cleaned up some code.
* 1.1
* - Added admin command sm_givepills.
* 1.0.1
* - Increased timer so plugin will work on 16 player servers.
* 1.0
* - Initial release.
*/
#include <sourcemod>
#include <sdktools>
public Plugin:myinfo =
{
name = "[L4D] Pills Here",
author = "Crimson_Fox",
description = "Gives pills to survivors at the start of each round.",
version = "1.1.2",
url = "http://forums.alliedmods.net/showthread.php?p=915033"
}
public OnPluginStart()
{
HookEvent("round_start", EventGivePills, EventHookMode_Post);
RegAdminCmd("sm_givepills", Command_GivePills, ADMFLAG_KICK, "Gives pills to survivors.");
}
public EventGivePills(Handle:event, const String:name[], bool:dontBroadcast)
{
CreateTimer(30.0, GivePillsDelay);
}
public Action:GivePillsDelay(Handle:timer)
{
GivePillsAll()
}
public Action:Command_GivePills(client, args)
{
GivePillsAll()
}
public GivePillsAll()
{
new flags = GetCommandFlags("give");
SetCommandFlags("give", flags & ~FCVAR_CHEAT);
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && GetClientTeam(i)==2) FakeClientCommand(i, "give pain_pills");
}
SetCommandFlags("give", flags|FCVAR_CHEAT);
}