Raised This Month: $23 Target: $400
 5% 

[L4D1+2] Weapon Amount Modifier (v1.1)[13-Jan-2020]


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Earendil
Junior Member
Join Date: Jan 2020
Location: Spain
Plugin ID:
6887
Plugin Version:
1.1
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
    1 
    Plugin Description:
    Overwrites the number of times weapons and health items can be picked
    Old 01-08-2020 , 12:28   [L4D1+2] Weapon Amount Modifier (v1.1)[13-Jan-2020]
    Reply With Quote #1

    Description:
    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.
    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.

    This plugin don`t spawn any entity, only modifies pre-existing entities when the map starts, any weapon or health item spawned by another plugin after the beggining of the round will not be afected by this plugin, even a deleted weapon can be spawned by another plugin. Medkits swpaned around the map assigned by director are not affected, they will spawn random and with only 1 use, for now.

    Thanks to asherkin, for basic guidance, and thanks to Shadowysn for helping rewriting the code with new syntax.

    CVars:
    PHP Code:
    // Enable or disable plugin. Min: 0 Max: 1
    l4d_wam_enabled "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" 
    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.
    Attached Files
    File Type: sp Get Plugin or Get Source (l4d_wam.sp - 244 views - 5.9 KB)

    Last edited by Earendil; 01-13-2020 at 16:26. Reason: Updated to v1.1
    Earendil is offline
    gamer_kanelita
    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
    Marttt
    Senior Member
    Join Date: Jan 2019
    Old 01-09-2020 , 20:26   Re: [L4D1+2] Weapon Amount Modifier
    Reply With Quote #3

    Compile manually then it should work, I don't know why but since the forum compiler changed a lot of plugins are acting like that.

    Try to compile here:
    https://www.sourcemod.net/compiler.php
    __________________

    Last edited by Marttt; 01-09-2020 at 20:26.
    Marttt is offline
    Silvers
    AlliedModders Donor
    Join Date: Aug 2010
    Location: SpaceX
    Old 01-09-2020 , 20:27   Re: [L4D1+2] Weapon Amount Modifier
    Reply With Quote #4

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

    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 #6

    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 - 135 views - 6.5 KB)
    __________________

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

    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 #8

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

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

    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 #10

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

    Last edited by Shadowysn; 01-11-2020 at 01:19.
    Shadowysn 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 04:10.


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