AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [L4D & L4D2] Survivor Starter Pack (v1.4, 08-30-2018) (https://forums.alliedmods.net/showthread.php?t=309990)

Psyk0tik 08-14-2018 21:26

[L4D & L4D2] Survivor Starter Pack (v1.4, 08-30-2018)
 
10 Attachment(s)
Donate to Motivate

Introduction

This is just a simple plugin I wrote because I was bored. Basically, server owners can set what loadouts each player starts with. Bots share the same loadout since their "ID" is just "BOT" so there's no point in even setting a loadout for each of them.

How It Works

When a player spawns as a survivor, the plugin looks for their Steam ID in the config file. If it's not listed, the player will be given the default pack. When a player goes AFK, the bot that replaces the player is given a new loadout. When a player replaces the bot, the player will get a new set of their own loadout.

Basically, like this:

Player spawns and is given a shotgun.
When player goes afk, bot gets an smg.
Player comes back and replaces bot, he/she gets a shotgun again.

When a bot spawns as a survivor, the plugin looks for the "bot" ID in the config file. If it's not listed, the bot will be given the default pack. When a player takes over the bot, the player will be given a new loadout.

Basically, like this:

Bot spawns and is given an smg.
When player takes over the bot, player gets a shotgun.
Player leaves and is replaced by a bot, the bot is given an smg.

Command

sm_starter <#userid|name> "item1,item2,item3,item4,item5"

Example: sm_starter @me "smg,pistol,pain_pills" (Character limit for loadout is 325 including commas.)

This command will save the specified starter pack for the player's Steam ID in the config. It will take effect the next time the player_spawn event is fired for that player. (i.e. Player goes afk or vice versa.)

KeyValues Settings

PHP Code:

"Survivor Starter Pack"
{
    
"General"
    
{
        
"Plugin Enabled"        "1" // 0: Plugin is off, 1: Plugin is on
        
"Default Pack"            "smg,pistol,pain_pills" // This loadout is used when the player's Steam ID isn't listed below...
    
}
    
// This is my Steam ID as an example...
    
"STEAM_1:1:48199803"
    
{
        
"Starter Pack"            "autoshotgun,knife,molotov,first_aid_kit,adrenaline"
    
}
    
// The "ID" used for bots...
    
"bot"
    
{
        
"Starter Pack"            "smg_mp5,pistol_magnum,first_aid_kit,pain_pills"
    
}


Bugs

I'm not sure. Let me know.

Notes

1. The config file will be generated in the default cfg/sourcemod folder.
2. Use the sm_starter command to add new Steam IDs to the config file. (You can still manually add Steam IDs yourself out of the game.)
3. The bots are given a specified loadout when a player goes AFK and vice-versa and when they spawn. This is done so that bots can have their own loadouts as well.

Requests

I don't know. Post one below and I'll look into it.

Requirement

SM 1.8+

Installation

1. Place survivor_starter_pack.smx inside plugins folder.

Changelog

Spoiler

Mi.Cura 08-15-2018 00:11

Re: [L4D & L4D2] Survivor Starter Pack
 
Very nice... Thanks Crasher :bacon!:

Sev 08-15-2018 10:49

Re: [L4D & L4D2] Survivor Starter Pack
 
Doesn't seem to be working. Nothing in the error logs either.

I simply have rifle_ak47 in my starter kit and I never load in with it or any other items.

Not sure what the deal is.

ricksfishin 08-15-2018 11:13

Re: [L4D & L4D2] Survivor Starter Pack
 
Same here when plugin reloaded or server restarted i still get default load pistol only.

Put this in and added my Steam ID still get same default load out, have sourcemod 1.9.

"Survivor Starter Pack"
{
"General"
{
"Plugin Enabled" "1" // 0: Plugin is off, 1: Plugin is on
"Default Pack" "smg,pistol,pain_pills" // This loadout is used when the player's Steam ID isn't listed below...
}
// This is my Steam ID as an example...
"STEAM_0:1:48199803"
{
"Starter Pack" "autoshotgun,knife,molotov,first_aid_kit,adre naline"
}
}

Thank you Crasher_3637

grimxxl 08-15-2018 11:36

Re: [L4D & L4D2] Survivor Starter Pack
 
Your plugin keeps overflowing the console with this message
Quote:

[SSP] Reloading config file (cfg/sourcemod/survivor_starter_pack.cfg)...
[SSP] Reloading config file (cfg/sourcemod/survivor_starter_pack.cfg)...
[SSP] Reloading config file (cfg/sourcemod/survivor_starter_pack.cfg)...
[SSP] Reloading config file (cfg/sourcemod/survivor_starter_pack.cfg)...
[SSP] Reloading config file (cfg/sourcemod/survivor_starter_pack.cfg)...
[SSP] Reloading config file (cfg/sourcemod/survivor_starter_pack.cfg)...
[SSP] Reloading config file (cfg/sourcemod/survivor_starter_pack.cfg)...
[SSP] Reloading config file (cfg/sourcemod/survivor_starter_pack.cfg)...
[SSP] Reloading config file (cfg/sourcemod/survivor_starter_pack.cfg)...
[SSP] Reloading config file (cfg/sourcemod/survivor_starter_pack.cfg)...
[SSP] Reloading config file (cfg/sourcemod/survivor_starter_pack.cfg)...
[SSP] Reloading config file (cfg/sourcemod/survivor_starter_pack.cfg)...
It just goes on and on like that.

Psyk0tik 08-15-2018 12:37

Re: [L4D & L4D2] Survivor Starter Pack
 
@Sev, I may need to hook some events. What gamemodes have you tried this on?

@rickfishin, I'll check it out.

@grimxxl, I'll work on a fix.

Sev 08-15-2018 12:55

Re: [L4D & L4D2] Survivor Starter Pack
 
Quote:

Originally Posted by Crasher_3637 (Post 2610327)
@Sev, I may need to hook some events. What gamemodes have you tried this on?

Coop

MasterMind420 08-15-2018 14:44

Re: [L4D & L4D2] Survivor Starter Pack
 
Crasher use something like this to fix your item giving...I used this method to fix starting backpack contents for my backpack plugin.

Code:

//THIS EVENT FIRES WHEN PLAYERS FIRST SPAWN ON THE SERVER AND WHEN A NEW CAMPAIGN STARTS
//YOU MUST FILTER OUT FAKECLIENTS(THEY FIRE THIS EVENT EVERY TIME A PLAYER GOES IDLE)
public void ePlayerFirstSpawn(Event event, const char[] name, bool dontBroadcast)
{
        int client = GetClientOfUserId(event.GetInt("userid"));

        if(IsValidClient(client) && !IsFakeClient(client) && GetClientTeam(client) == 2)
        {
                int userid = GetClientUserId(client);
                CreateTimer(1.0, GiveItems, userid, TIMER_FLAG_NO_MAPCHANGE);
        }
}

public Action GiveItems(Handle timer, any userid)
{
        int client = GetClientOfUserId(userid);

        //AS A PRECAUTION REMOVE ALL ITEMS FROM THE PLAYER
        //I DO THIS TO MAKE THE PROCESS CLEANER FOR MY BACKPACK

        int slot;

        slot = GetPlayerWeaponSlot(client, 2);

        if(slot > -1)
        {
                RemovePlayerItem(client, slot);
                AcceptEntityInput(slot, "kill");
        }

        slot = GetPlayerWeaponSlot(client, 3);

        if(slot > -1)
        {
                RemovePlayerItem(client, slot);
                AcceptEntityInput(slot, "kill");
        }

        slot = GetPlayerWeaponSlot(client, 4);

        if(slot > -1)
        {
                RemovePlayerItem(client, slot);
                AcceptEntityInput(slot, "kill");
        }

        //GIVE YOUR ITEMS BELOW THIS
}


Psyk0tik 08-15-2018 15:38

Re: [L4D & L4D2] Survivor Starter Pack
 
Quote:

Originally Posted by MasterMind420 (Post 2610355)
Crasher use something like this to fix your item giving...I used this method to fix starting backpack contents for my backpack plugin.

Code:

//THIS EVENT FIRES WHEN PLAYERS FIRST SPAWN ON THE SERVER AND WHEN A NEW CAMPAIGN STARTS
//YOU MUST FILTER OUT FAKECLIENTS(THEY FIRE THIS EVENT EVERY TIME A PLAYER GOES IDLE)
public void ePlayerFirstSpawn(Event event, const char[] name, bool dontBroadcast)
{
        int client = GetClientOfUserId(event.GetInt("userid"));

        if(IsValidClient(client) && !IsFakeClient(client) && GetClientTeam(client) == 2)
        {
                int userid = GetClientUserId(client);
                CreateTimer(1.0, GiveItems, userid, TIMER_FLAG_NO_MAPCHANGE);
        }
}

public Action GiveItems(Handle timer, any userid)
{
        int client = GetClientOfUserId(userid);

        //AS A PRECAUTION REMOVE ALL ITEMS FROM THE PLAYER
        //I DO THIS TO MAKE THE PROCESS CLEANER FOR MY BACKPACK

        int slot;

        slot = GetPlayerWeaponSlot(client, 2);

        if(slot > -1)
        {
                RemovePlayerItem(client, slot);
                AcceptEntityInput(slot, "kill");
        }

        slot = GetPlayerWeaponSlot(client, 3);

        if(slot > -1)
        {
                RemovePlayerItem(client, slot);
                AcceptEntityInput(slot, "kill");
        }

        slot = GetPlayerWeaponSlot(client, 4);

        if(slot > -1)
        {
                RemovePlayerItem(client, slot);
                AcceptEntityInput(slot, "kill");
        }

        //GIVE YOUR ITEMS BELOW THIS
}


Thank you! I will definitely implement this. :D

Psyk0tik 08-15-2018 21:33

Re: [L4D & L4D2] Survivor Starter Pack (v1.1, 08-15-2018)
 
Version 1.1 is out!

1. Fixed the config file being refreshed constantly while spamming the console. (Thanks grimxxl for the report!)
2. Fixed the plugin not working properly. (Thanks MasterMind420 for the new method and Sev for the report!)
3. Added event hooks to give players/bots the proper loadout between AFK transitions.


All times are GMT -4. The time now is 01:17.

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