View Single Post
FlavioCO92
New Member
Join Date: Jul 2020
Old 07-08-2020 , 05:54   Re: [L4D] Pills Here
Reply With Quote #29

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_GiveStartPackADMFLAG_KICK"Gives start pack to survivors.");
}

public 
EventGiveStartPack(Handle:event, const String:name[], bool:dontBroadcast)
{
    
CreateTimer(10.0GiveStartPackDelay);
}

public 
Action:GiveStartPackDelay(Handle:timer)
{
    
GiveStartPackAll()
}

public 
Action:Command_GiveStartPack(clientargs)
{
    
GiveStartPackAll()
}

public 
GiveStartPackAll()
{
    new 
flags GetCommandFlags("give");    
    
SetCommandFlags("give"flags & ~FCVAR_CHEAT);    
    for (new 
1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && GetClientTeam(i)==2FakeClientCommand(i"give frying_pan");
        if (
IsClientInGame(i) && GetClientTeam(i)==2FakeClientCommand(i"give pipe_bomb");
        if (
IsClientInGame(i) && GetClientTeam(i)==2FakeClientCommand(i"give first_aid_kit");
        if (
IsClientInGame(i) && GetClientTeam(i)==2FakeClientCommand(i"give pain_pills");
    }
    
SetCommandFlags("give"flags|FCVAR_CHEAT);

FlavioCO92 is offline