Hello, I need help, to start I don't know anything about programming or anything about it, I'm just curious, anyway, what I want to achieve is: give a survivors starter pack, but only in the first round of any campaign.
It works (it gives the 4 survivors their packs), but it has the error that it generates 6 extra packs on the ground and as one progresses on the map, packs appear in the place where the survivors are, I suspect it is from HookEvent "player_first_spawn" and that packs are being generated by the appearance of Infected (bots)
PHP Code:
#include <sourcemod>
#include <sdktools>
public OnPluginStart()
{
HookEvent("player_first_spawn", EventGiveStartPack);
RegAdminCmd("sm_startpack", Command_GiveStartPack, ADMFLAG_KICK, "Gives start pack to survivors.");
}
public EventGiveStartPack(Handle:event, const String:name[], bool:dontBroadcast)
{
CreateTimer(10.0, GiveStartPackDelay);
}
public Action:GiveStartPackDelay(Handle:timer)
{
GiveStartPackAll()
}
public Action:Command_GiveStartPack(client, args)
{
GiveStartPackAll()
}
public GiveStartPackAll()
{
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 frying_pan");
if (IsClientInGame(i) && GetClientTeam(i)==2) FakeClientCommand(i, "give pipe_bomb");
if (IsClientInGame(i) && GetClientTeam(i)==2) FakeClientCommand(i, "give first_aid_kit");
if (IsClientInGame(i) && GetClientTeam(i)==2) FakeClientCommand(i, "give pain_pills");
}
SetCommandFlags("give", flags|FCVAR_CHEAT);
}