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

[L4D1 & L4D2] Weapon Amount Modifier (v1.4)[31-May-2021]


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Earendil
Senior Member
Join Date: Jan 2020
Location: Spain
Plugin ID:
6887
Plugin Version:
1.4
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
    18 
    Plugin Description:
    Modify the number of times weapons and heal items can be picked before removing, or deletes them
    Old 01-08-2020 , 12:28   [L4D1 & L4D2] Weapon Amount Modifier (v1.4)[31-May-2021]
    Reply With Quote #1

    This is my first plugin, I did it because I needed that for my 12-survivor server, but I think anyone can benefit from this and help me improving this plugin.

    Description:
    All weapons and health items will have their max times they can be used by multiple players override by the desired amount, if the amount is set to 0 the weapon/item will be deleted from map.

    Usually, on servers with 5+ survivors the weapons in the saferoom or in the spawnzone are not enough for everybody, usually some players end without weapons, or forced to grab a weapon that they dont like because they have no other option. Also there are some servers with 1 weapon per spot, so the first grabs the weapon is the only who gets it, this plugin fits both situations. With this plugin there can be weapons and health items for everyone. Also weapon number can be decreased or removed to make game harder.

    Since v1.3 this plugin can modify weapons spawned in midgame, modifying medkits generated by director on Normal difficulty and any other weapon/item created by other plugins.

    Credits:
    - asherkin: basic guidance.
    - Shadowysn: for rewriting code with new syntax.
    - mi123645: I used code in https://forums.alliedmods.net/showthread.php?p=893938 to check when players leave saferoom.

    CVars:
    PHP Code:
    // Enable or disable plugin. Min: 0 Max: 1
    l4d_wam_enabled "1"

    //Modify only weapon amounts when round starts.
    //This prevents modifying weapon amount created by other plugins in midgame.
    l4d_wam_roundstart_only "1"
    // Amount of primary weapons per spot Min: 0 Max: 32
    l4d_wam_weapon_amount "9"

    // Amount of pistols per spot. Min: 0 Max: 32
    l4d_wam_pistol_amount "9"

    // Amount of first aid kits per spot. Min: 0 Max: 20
    l4d_wam_medkit_amount "2"

    // Amount of pain pills per spot. Min: 0 Max: 20
    l4d_wam_pain_pills_amount "2"

    // Amount of pipe bombs per spot. Min: 0 Max: 20
    l4d_wam_pipe_bomb_amount "1"

    // Amount of molotovs per spot. Min: 0 Max: 20
    l4d_wam_molotov_amount "1"

    //////////////////////////////////////////////
    // Next ConVars are Left 4 Dead 2 only //
    //////////////////////////////////////////////

    //Amount of magnum pistols per spot. Min: 0 Max: 32
    l4d_wam_pistol_magnum_amount "9"

    // Amount of vomit jars per spot. Min: 0 Max: 20
    l4d_wam_vomitjar_amount "1"

    // Amount of adrenaline shots per spot. Min: 0 Max: 20
    l4d_wam_adrenaline_amount "2"

    // Amount of defibrillators per spot. Min: 0 Max: 20
    l4d_wam_defibrillator_amount "1"

    // Amount of melee weapons per spot. Min: 0 Max: 20
    l4d_wam_melee_amount "1"

    // Amount of M60 rifles per spot. Min: 0 Max: 20
    l4d_wam_m60_amount "1"

    // Amount of grenade launchers per spot. Min: 0 Max: 20
    l4d_wam_grenade_launcher_amount "1"

    // Amount of incendiary ammo packs per spot. Min: 0 Max: 20
    l4d_wam_incendiary_ammo_amount "1"

    // Amount of explosive ammo packs per spot. Min: 0 Max: 20
    l4d_wam_explosive_ammo_amount "1" 
    Any plugin update from versions lower than 1.3 require to reload cfg file, delete "cfg/sourcemod/l4d_weapon_amount_modifier.cfg", or use https://forums.alliedmods.net/showthread.php?p=1739534

    Changelog:
    v1.0
    -First release.
    v1.0.1
    -Fixed plugin version CVar "l4d_wam_version"
    v1.1
    - Rebuilded code with new syntax, special thanks to Shadowysn for help and tips.
    - Pistols and magnum pistols can have their amount modified separately from all other weapons.
    - Throwables can be managed individually by their respective CVar instead of using a common CVar.
    - Added M60 and grenade launcher CVars to manage their amount
    - Added xplosive and incendiary ammo pack CVar to manage their amount.
    v1.2
    - Counter Strike weapons included.
    - Cleaned code.
    - Plugin now only hooks "round_start", event is unhooked when "l4d_wam_enabled" "0".
    v1.3
    - Fixed any potential fail modifying weapon amounts.
    - Plugin now can modify any weapon_spawn created anytime in the game (controlled by CVar).
    - New ConVar: l4d_wam_roundstart_only
    - Change of game tags in plugin title.
    Attached Files
    File Type: sp Get Plugin or Get Source (l4d_wam.sp - 892 views - 11.5 KB)

    Last edited by Earendil; 05-31-2021 at 16:48. Reason: Updated to v1.4
    Earendil is offline
    gamer_kanelita
    Senior Member
    Join Date: Jun 2019
    Location: Peru
    Old 01-09-2020 , 16:32   Re: [L4D1+2] Weapon Amount Modifier
    Reply With Quote #2

    Plugin failed to compile! Please try contacting the author.
    gamer_kanelita is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 01-09-2020 , 20:27   Re: [L4D1+2] Weapon Amount Modifier
    Reply With Quote #3

    A mix of old and new syntax.
    __________________
    Silvers is offline
    Earendil
    Senior Member
    Join Date: Jan 2020
    Location: Spain
    Old 01-10-2020 , 06:06   Re: [L4D1+2] Weapon Amount Modifier
    Reply With Quote #4

    Quote:
    Originally Posted by Silvers View Post
    A mix of old and new syntax.
    Sorry, for that, I learned how to write in sourcepawn basically from the Wiki, some questions answered on these forums (some of them really old probably) and looking inside some .sp plugins to see how the author did wrote that, so the syntax is a mix of everything I looked, where is a good post/page with how to write with modern syntax?

    Quote:
    Originally Posted by gamer_kanelita View Post
    Plugin failed to compile! Please try contacting the author.
    I uploaded the .smx file, you can download it now compiled.
    Earendil is offline
    Shadowysn
    Senior Member
    Join Date: Sep 2015
    Location: Location:
    Old 01-10-2020 , 09:12   Re: [L4D1+2] Weapon Amount Modifier
    Reply With Quote #5

    Converted to new syntax + edited some stuff.
    (Absolutely haven't tested this yet, something might've been screwed up, but its highly unlikely.)

    ALSO, go into the full-edit page of your main plugin post and check compiler version. If I'm correct, the compiler's been changed to 1.1, which is absolutely the wrong version, hence your plugin not compiling from the .sp file.
    Changing back to 1.10 will just have it revert to 1.1 again.
    Choose an older compiler version like 1.8, which I've tested and worked for my plugin.
    Attached Files
    File Type: sp Get Plugin or Get Source (l4d2_wam.sp - 550 views - 6.5 KB)
    __________________
    ragdoll spam, that is all

    Steam profile, where I game, obviously.
    Youtube channel, where I do Stick Death Maze animations and some other stuff.
    no plugin requests, sorry


    My Plugins:
    -search list-
    Modified Plugins:
    1 | 2 | 3 | 4

    Last edited by Shadowysn; 01-10-2020 at 09:49.
    Shadowysn is offline
    Earendil
    Senior Member
    Join Date: Jan 2020
    Location: Spain
    Old 01-10-2020 , 10:13   Re: [L4D1+2] Weapon Amount Modifier
    Reply With Quote #6

    Quote:
    Originally Posted by Shadowysn View Post
    Converted to new syntax + edited some stuff.
    (Absolutely haven't tested this yet, something might've been screwed up, but its highly unlikely.)

    ALSO, go into the full-edit page of your main plugin post and check compiler version. If I'm correct, the compiler's been changed to 1.1, which is absolutely the wrong version, hence your plugin not compiling from the .sp file.
    Changing back to 1.10 will just have it revert to 1.1 again.
    Choose an older compiler version like 1.8, which I've tested and worked for my plugin.
    Yeah, the compiler is now 1.8, it works fine. Everytime I press the preview post button, the compiler needed, description, ect are set to blank/defult. I will add the changes on next version (I'm looking how to manipulate that medkits placed around the map without modifying kits being carried by survivors, as long they are the same entity).

    Last edited by Earendil; 01-10-2020 at 10:14.
    Earendil is offline
    Shadowysn
    Senior Member
    Join Date: Sep 2015
    Location: Location:
    Old 01-10-2020 , 10:18   Re: [L4D1+2] Weapon Amount Modifier
    Reply With Quote #7

    Quote:
    Originally Posted by Earendil View Post
    Yeah, the compiler is now 1.8, it works fine. Everytime I press the preview post button, the compiler needed, description, ect are set to blank/defult. I will add the changes on next version (I'm looking how to manipulate that medkits placed around the map without modifying kits being carried by survivors, as long they are the same entity).
    Oh yeah, have you made sure the entity names of the medkits placed around the map are weapon_first_aid_kit?
    Look at them and type in ent_remove. This'll remove the entity and print out it's targetname as well as it's classname.
    It could potentially be weapon_item_spawn.
    __________________
    ragdoll spam, that is all

    Steam profile, where I game, obviously.
    Youtube channel, where I do Stick Death Maze animations and some other stuff.
    no plugin requests, sorry


    My Plugins:
    -search list-
    Modified Plugins:
    1 | 2 | 3 | 4

    Last edited by Shadowysn; 01-10-2020 at 10:20.
    Shadowysn is offline
    Earendil
    Senior Member
    Join Date: Jan 2020
    Location: Spain
    Old 01-10-2020 , 11:22   Re: [L4D1+2] Weapon Amount Modifier
    Reply With Quote #8

    Quote:
    Originally Posted by Shadowysn View Post
    Oh yeah, have you made sure the entity names of the medkits placed around the map are weapon_first_aid_kit?
    Look at them and type in ent_remove. This'll remove the entity and print out it's targetname as well as it's classname.
    It could potentially be weapon_item_spawn.
    Yeah, they are, in easy, normal, and hard difficulty director can convert some pills and adrenaline spawn into a first aid kit, but instead of making a weapon_first_aid_kit_spawn, is a weapon_first_aid_kit. You can notice that if at the beggining of the map using report_entities command in console, if you see "weapon_first_aid_kit" in the console log, and the total count is higher than the number of medkits carried by players, there is one medkit on the map, I noticed that random medkits are not affected by my plugin, so the only entity is not afected is that one. Usually you can have 1-2 medkits at the map, so the idea is to manipulate those kits, convert into weapon_first_aid_kit_spawn and then manipulate them like the medkits in the saferoom, or directly delete them.

    Last edited by Earendil; 01-10-2020 at 11:24.
    Earendil is offline
    Shadowysn
    Senior Member
    Join Date: Sep 2015
    Location: Location:
    Old 01-10-2020 , 11:41   Re: [L4D1+2] Weapon Amount Modifier
    Reply With Quote #9

    Quote:
    Originally Posted by Earendil View Post
    Yeah, they are, in easy, normal, and hard difficulty director can convert some pills and adrenaline spawn into a first aid kit, but instead of making a weapon_first_aid_kit_spawn, is a weapon_first_aid_kit. You can notice that if at the beggining of the map using report_entities command in console, if you see "weapon_first_aid_kit" in the console log, and the total count is higher than the number of medkits carried by players, there is one medkit on the map, I noticed that random medkits are not affected by my plugin, so the only entity is not afected is that one. Usually you can have 1-2 medkits at the map, so the idea is to manipulate those kits, convert into weapon_first_aid_kit_spawn and then manipulate them like the medkits in the saferoom, or directly delete them.
    Alright, then you can check the m_hOwnerEntity netprop of the medkit entity using GetEntPropEnt, and not do anything to the medkit if the netprop has a valid player.

    PHP Code:
    bool IsInPlayerInventory(int entity)
    {
        if (!
    IsValidEntity(entity)) return false;
        
    int owner GetEntPropEnt(entityProp_Send"m_hOwnerEntity");
        if (
    IsValidClient(owner)) return true;
        return 
    false;
    }

    bool IsValidClient(int clientbool replaycheck true// This is for convenience
    {
        if (!
    IsValidEntity(client)) return false;
        if (
    client <= || client MaxClients) return false;
        if (!
    IsClientInGame(client)) return false;
        if (
    replaycheck)
        {
            if (
    IsClientSourceTV(client) || IsClientReplay(client)) return false;
        }
        return 
    true;

    EDIT: Oh, also, if you're not using the event parameters, you can safely use EventHookMode_PostNoCopy. Kinda forgot to put them in the new-syntax version.
    PHP Code:
        HookEvent("round_end"Event_Round_EndEventHookMode_PostNoCopy);
        
    HookEvent("player_spawn"Event_Player_SpawnEventHookMode_PostNoCopy); 
    An example snippet from my FirstAid_Manager plugin that uses the event parameters:
    PHP Code:
    public void player_spawn(Handle event, const char[] namebool dontBroadcast)
    {
        
    //PrintToServer("%s plugin detected event: %s", PLUGIN_NAME_SHORT, name);
        
    if (!hasRoundEnded) return;
        
        
    int clientID GetEventInt(event"userid");
        
    int client GetClientOfUserId(clientID);
        if (!
    IsValidClient(client) || !IsSurvivor(client)) return;
        
        
    hasRoundEnded false;
        
        
    ManageFirstAidFunction();

    Here's a list of lists for games and their events:
    https://wiki.alliedmods.net/Game_Events_(Source)
    __________________
    ragdoll spam, that is all

    Steam profile, where I game, obviously.
    Youtube channel, where I do Stick Death Maze animations and some other stuff.
    no plugin requests, sorry


    My Plugins:
    -search list-
    Modified Plugins:
    1 | 2 | 3 | 4

    Last edited by Shadowysn; 01-11-2020 at 01:19.
    Shadowysn is offline
    Earendil
    Senior Member
    Join Date: Jan 2020
    Location: Spain
    Old 01-12-2020 , 13:15   Re: [L4D1+2] Weapon Amount Modifier
    Reply With Quote #10

    Lets just ignore that random medkits for now, it seems it only happens sometimes in L4D1 maps. L4D2 maps spawn randomly weapon_first_aid_kit_spawn instead. And now while im trying to check if the plugin gets the random medkits spawned around the map only finds player carrying medkits it seems there are no weapon_first_aid_kit at the beggining of the map and does not remove them fortunately.

    I though that random medkits were spawned at the beggining of the round, but maybe the director decides to change pain pills into medkits if survivors are finding hard to progress in normal/advanced difficulty. I will keep cheeking that.

    What I will try to do is to manage weapon spawns, getting separating them in weapon types, pistols, autoshotguns, smgs, rifles ect. Also Ill try to add to the list explosive and incendiary ammo (maybe people want to remove them from their server or allow to pick more than once).

    So for now I will not include the last code, but may be useful in further versions or with any other plugin, thanks for the help anyway Shadowysn. Also thanks for the fixed code with new syntax, I`m rewriting the plugin, I will have the new version soon.
    Earendil 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 20:08.


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