Raised This Month: $32 Target: $400
 8% 

[L4D & L4D2] Survivor Starter Pack (v1.4, 08-30-2018)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Plugin ID:
6229
Plugin Version:
1.4
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
    5 
    Plugin Description:
    Provides starter packs for survivors.
    Old 08-14-2018 , 21:26   [L4D & L4D2] Survivor Starter Pack (v1.4, 08-30-2018)
    Reply With Quote #1

    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
    Attached Files
    File Type: sp Get Plugin or Get Source (survivor_starter_pack.sp - 1534 views - 7.2 KB)
    __________________

    Last edited by Psyk0tik; 08-19-2021 at 09:17. Reason: Updated main post
    Psyk0tik is offline
    Mi.Cura
    Veteran Member
    Join Date: Dec 2016
    Location: Brazil
    Old 08-15-2018 , 00:11   Re: [L4D & L4D2] Survivor Starter Pack
    Reply With Quote #2

    Very nice... Thanks Crasher
    __________________
    Mi.Cura | Modded Servers | L4D2
    https://steamcommunity.com/groups/micuramodzombie
    Mi.Cura is offline
    Sev
    Veteran Member
    Join Date: May 2010
    Old 08-15-2018 , 10:49   Re: [L4D & L4D2] Survivor Starter Pack
    Reply With Quote #3

    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.
    Sev is offline
    ricksfishin
    Senior Member
    Join Date: Oct 2017
    Old 08-15-2018 , 11:13   Re: [L4D & L4D2] Survivor Starter Pack
    Reply With Quote #4

    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

    Last edited by ricksfishin; 08-15-2018 at 11:19.
    ricksfishin is offline
    grimxxl
    Member
    Join Date: Dec 2012
    Old 08-15-2018 , 11:36   Re: [L4D & L4D2] Survivor Starter Pack
    Reply With Quote #5

    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.
    grimxxl is offline
    Psyk0tik
    Veteran Member
    Join Date: May 2012
    Location: Homeless
    Old 08-15-2018 , 12:37   Re: [L4D & L4D2] Survivor Starter Pack
    Reply With Quote #6

    @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.
    __________________
    Psyk0tik is offline
    Sev
    Veteran Member
    Join Date: May 2010
    Old 08-15-2018 , 12:55   Re: [L4D & L4D2] Survivor Starter Pack
    Reply With Quote #7

    Quote:
    Originally Posted by Crasher_3637 View Post
    @Sev, I may need to hook some events. What gamemodes have you tried this on?
    Coop
    Sev is offline
    MasterMind420
    BANNED
    Join Date: Nov 2010
    Old 08-15-2018 , 14:44   Re: [L4D & L4D2] Survivor Starter Pack
    Reply With Quote #8

    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
    }

    Last edited by MasterMind420; 08-15-2018 at 14:50.
    MasterMind420 is offline
    Psyk0tik
    Veteran Member
    Join Date: May 2012
    Location: Homeless
    Old 08-15-2018 , 15:38   Re: [L4D & L4D2] Survivor Starter Pack
    Reply With Quote #9

    Quote:
    Originally Posted by MasterMind420 View Post
    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.
    __________________
    Psyk0tik is offline
    Psyk0tik
    Veteran Member
    Join Date: May 2012
    Location: Homeless
    Old 08-15-2018 , 21:33   Re: [L4D & L4D2] Survivor Starter Pack (v1.1, 08-15-2018)
    Reply With Quote #10

    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.
    __________________

    Last edited by Psyk0tik; 08-16-2018 at 03:45.
    Psyk0tik is offline
    Reply


    Thread Tools
    Display Modes

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 16:52.


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