Raised This Month: $2 Target: $400
 0% 

[L4D/L4D2]Weapon Cleaner (2.2)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
xZk
Senior Member
Join Date: Nov 2017
Location: cl
Plugin ID:
6479
Plugin Version:
2.2
Plugin Category:
General Purpose
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Clean drop weapons on the ground with delay timer or commands, like KF
    Old 03-19-2019 , 22:53   [L4D/L4D2]Weapon Cleaner (2.2)
    Reply With Quote #1

    Intro

    The idea of this plugin arises from the fact of avoiding the excess of weapons. This usually happens when players abuse weapons spawn. In addition to other plugins that generate weapons which several of these are abandoned.
    Since also the excess of these weapons on the map can cause the server to warp or even crash due to excess entities.

    This plugin consists of an independent timer countdown for each weapon, and this is activated when the weapon is left on the ground, similar to KF2.

    Feature list:
    • clear weapons manually by admin commands
    • cleaning weapons drop,by player dead,by player(bot) kicked
    • cleaning all weapons spawned in game (except map weapons)
    • filter the weapons for visibility
    • set effects on weapons with the timer (blink/glow)
    • choose class name weapons in the WhiteList weapon_cleaner_whitelist.cfg


    Cvars:
    PHP Code:
    // 0:Disable, 1:Enable Plugin
    // Default: "1"
    weapon_cleaner_enable "1"

    // 0: Clean all weapons not equipped in the game, 1: Clean only dropped weapons when taking another weapon
    // Default: "0"
    weapon_cleaner_drop "0"

    //"0:Detect all weapons when spawned, 1:Ignore weapons spawned by map, 2: Ignore weapons when the round starts (thirparty plugins)"
    // Default: "2"
    weapon_cleaner_spawn "2"

    // 1:Clean only Weapons that do not belong to the spawn class, 2:Clean only Weapons of the class with suffix: "_spawn", 3:All weapons with any class name("weapon_*")
    // Default: "1"
    // Minimum: "1.000000"
    // Maximum: "3.000000"
    weapon_cleaner_class "1"

    //"0:Ignore prop_physics weapons(no detect gascans), 1:Allow detect prop_physics (gnome, cola_bottles,...)"
    // Default: "0"
    weapon_cleaner_physics "0"

    //"0:Ignore ammo pile, 1:Allow detect ammo pile(weapon_ammo_spawn)"
    // Default: "0"
    weapon_cleaner_ammo "0" 

    // Set delay to clean each weapon in seconds
    // Default: "300"
    // Minimum: "1.000000"
    weapon_cleaner_delay "300"

    // 0:Disable, 1:Enable visibility filter on weapons
    // Default: "0"
    weapon_cleaner_visible "0"

    // 0:Pause timer if is visible weapon , 1:Pause timer if someone is aiming at the weapon, 2:Reset timer if is visible weapon, 3:Reset timer if someone is aiming at the weapon
    // Default: "0"
    // Minimum: "0.000000"
    // Maximum: "3.000000"
    weapon_cleaner_visible_mode "0"

    // 0:Disable effects on weapons in timer cleaning, 1:Set blink effect(RenderFx), 2:Set glow effect(L4D2), 3:All effects modes
    // Default: "1"
    weapon_cleaner_effect_mode "1"

    // Set percentage of delay time to activate effects on weapons, ex:("0.2")=>(0.2*delay=0.2*300s=60s) or Set time in seconds value if: (value >= 1), ex:("60")s
    // Default: "0.8"
    // Minimum: "0.010000"
    weapon_cleaner_effect_time "0.8"

    // Set glow color in RGB Format (L4D2)
    // Default: "128,128,128"
    weapon_cleaner_effect_glowcolor "128,128,128"

    // Set maximum range of glow (L4D2)
    // Default: "1000"
    weapon_cleaner_effect_glowrange "1000" 
    Admin Commands:
    PHP Code:
    "sm_wc_reload" //reload config data Whitelist

    "sm_wclean" //clean weapons no equipped by name or classname

    "sm_wcleanall" //clean all weapons no equipped

    "sm_wclear" //clear weapons all weapons by name or classname

    "sm_wclearall" //clear all weapons 
    Changelog




    Notes:
    -if you wish to compile a version yourself, l4dstocks is required.
    -for to use the WhiteList cfg, you must set the value to "1" for exclude your weapon
    -for now the cvar:weapon_cleaner_physics can't detect gascans, you can exclude in Whitelist


    credits
    zipcore
    Mr. Zero
    AtomicStryker
    berni
    Bacardi
    KissLick


    Special Thanks


    pd: sorry for my bad English :/
    Attached Files
    File Type: sp Get Plugin or Get Source (weapon_cleaner.sp - 105 views - 33.8 KB)
    File Type: smx weapon_cleaner.smx (20.8 KB, 110 views)

    Last edited by xZk; 06-24-2020 at 22:15. Reason: v2.2
    xZk is offline
    Dragokas
    Veteran Member
    Join Date: Nov 2017
    Location: Ukraine
    Old 03-20-2019 , 10:48   Re: [L4D/L4D2]Weapon Cleaner
    Reply With Quote #2

    Thanks. Nice idea.

    Quote:
    -if you wish to compile a version yourself, l4dstocks is required.
    Quote:
    There was an error getting resource 'downloads':

    401: Anonymous caller does not have storage.objects.get access to google-code-archive/v2/code.google.com/l4dstocks/downloads-page-1.json.
    __________________
    Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch)
    [My plugins] [My tools] [GitHub] [Articles]
    Dragokas is offline
    Lux
    Veteran Member
    Join Date: Jan 2015
    Location: Brexit
    Old 03-20-2019 , 11:04   Re: [L4D/L4D2]Weapon Cleaner
    Reply With Quote #3

    I uploaded the l4dstocks repo-archive in case others are having download problems.
    Attached Files
    File Type: zip l4dstocks-source-archive.zip (52.6 KB, 92 views)
    __________________
    Lux is offline
    Dragokas
    Veteran Member
    Join Date: Nov 2017
    Location: Ukraine
    Old 03-20-2019 , 12:09   Re: [L4D/L4D2]Weapon Cleaner
    Reply With Quote #4

    Lux, thanks.
    xZk, can I ask you something about your code.

    In OnEntityCreated you are using:
    PHP Code:
    SDKHook(entitySDKHook_ThinkPostOnThinkPost); 
    instead of SDKHook_OnSpawn to begin check for weapon and tracking.
    Is it roughly speaking almost identical events in time for _weapon class to safe check its props?

    PHP Code:
        HookEvent("round_start"Event_RoundReset);
        
    HookEvent("round_end"Event_RoundReset);
        
    HookEvent("round_freeze_end"Event_RoundFreezeEnd); 
    you are using "round_freeze_end" to begin tracking. This event is happen slightly later than "round_start".
    What kind of error that case prevents?

    And a recommendation:
    Use EntIndexToEntRef when you pass entity index to a timer function.
    Like:
    PHP Code:
    DelayClean[entity] = CreateTimer(1.0CleanWeaponEntIndexToEntRef(entity), TIMER_REPEAT);
    ...
    public 
    Action:CleanWeapon(Handle:timerany:entRef) { 
        
    int weapon EntRefToEntIndex(entRef);    
        if (
    weapon == || weapon == INVALID_ENT_REFERENCE || !IsValidEntity(weapon))
            return 
    Plugin_Stop
    Also, it looks like TIMER_FLAG_NO_MAPCHANGE flag is missing.

    PHP Code:
                    case 3: {  //Reset Timer on aiming
                        
    if (IsAimToPlayers(weapon)) {
                            
    _debug("Time: %d"ItemTime[weapon]);
                            return 
    Plugin_Continue;
                        }
                    } 
    you missed:
    PHP Code:
    ItemTime[weapon] = delayclear
    Quote:
    OnEntityCreated => tracking
    OnWeaponDrop => tracking
    Request.
    Maybe, add ConVar to track only the case when weapon dropped (do not track all spawned entities). To increase CPU performance.
    __________________
    Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch)
    [My plugins] [My tools] [GitHub] [Articles]

    Last edited by Dragokas; 03-20-2019 at 12:09.
    Dragokas is offline
    yagura40977
    Junior Member
    Join Date: Feb 2019
    Old 03-21-2019 , 06:12   Re: [L4D/L4D2]Weapon Cleaner
    Reply With Quote #5

    Gun does not work

    "weapon_rifle_ak47,rifle_ak47"
    yagura40977 is offline
    xZk
    Senior Member
    Join Date: Nov 2017
    Location: cl
    Old 03-21-2019 , 10:21   Re: [L4D/L4D2]Weapon Cleaner
    Reply With Quote #6

    Quote:
    Originally Posted by Dragokas View Post
    instead of SDKHook_OnSpawn to begin check for weapon and tracking.
    Is it roughly speaking almost identical events in time for _weapon class to safe check its props?
    At the beginning I used SDKHook_OnSpawn, but then i realized, I had to check the weapons that are left when a survivor (bot) is kicked, so that's why i only use event SDKHook_ThinkPost, since i also verified when the weapon on spawn. Although I was never suggesting how I should correctly verify those weapons, so i consider myself a newbie using SDKHooks

    Quote:
    Originally Posted by Dragokas View Post
    you are using "round_freeze_end" to begin tracking. This event is happen slightly later than "round_start".
    What kind of error that case prevents?
    is the simplest method I can think of, to exclude the weapons spawn on the map, example: weapon that are added using Stripper, weapons that do not belong to the class "weapon_spawn"

    Quote:
    Originally Posted by Dragokas View Post
    Also, it looks like TIMER_FLAG_NO_MAPCHANGE flag is missing.
    About this I am not sure it is necessary, since I use the round_end event to stop the timers, also according to this forum the TIMER_FLAG_NO_MAPCHANGE can cause logs error with the KillTimer () function.

    Quote:
    Originally Posted by Dragokas View Post
    you missed:
    thank you, fixed.

    In the next version i will try to add a cvar to optionally detect the weapon spawned(do not track all spawned entities), the time did not give me to add it in this version :/, thanks for the suggestions Dragokas ☺
    xZk is offline
    xZk
    Senior Member
    Join Date: Nov 2017
    Location: cl
    Old 03-21-2019 , 11:02   Re: [L4D/L4D2]Weapon Cleaner
    Reply With Quote #7

    Quote:
    Originally Posted by yagura40977 View Post
    Gun does not work
    "weapon_rifle_ak47,rifle_ak47"
    I think you mean to exclude the ak47, so that it is not cleaned ?, then you just have to assign the cvar:
    PHP Code:
    weapon_cleaner_exclude "rifle_ak47" 
    pd:the prefix "weapon_" is not necessary. you can also exclude several weapons assigned their names in the same cvar example:
    weapon_cleaner_exclude "shotgun_spas, sniper_military, rifle_ak47"

    Last edited by xZk; 03-21-2019 at 11:04.
    xZk is offline
    Dragokas
    Veteran Member
    Join Date: Nov 2017
    Location: Ukraine
    Old 03-21-2019 , 12:22   Re: [L4D/L4D2]Weapon Cleaner
    Reply With Quote #8

    xZk, thank you for explanation.

    Quote:
    About this I am not sure it is necessary, since I use the round_end event to stop the timers, also according to this forum the TIMER_FLAG_NO_MAPCHANGE can cause logs error with the KillTimer () function.
    So, in such case, you are right.
    __________________
    Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch)
    [My plugins] [My tools] [GitHub] [Articles]
    Dragokas is offline
    yagura40977
    Junior Member
    Join Date: Feb 2019
    Old 03-21-2019 , 12:56   Re: [L4D/L4D2]Weapon Cleaner
    Reply With Quote #9

    Sorry I misunderstood Features

    thank you for the explanation
    normal work



    [L4D2] Infected Loot Drops (2.3d)
    https://forums.alliedmods.net/showthread.php?p=1099583

    Generated item
    Must discard items in order to work
    yagura40977 is offline
    Lux
    Veteran Member
    Join Date: Jan 2015
    Location: Brexit
    Old 03-21-2019 , 13:49   Re: [L4D/L4D2]Weapon Cleaner
    Reply With Quote #10

    Quote:
    Originally Posted by yagura40977 View Post
    Sorry I misunderstood Features

    thank you for the explanation
    normal work



    [L4D2] Infected Loot Drops (2.3d)
    https://forums.alliedmods.net/showthread.php?p=1099583

    Generated item
    Must discard items in order to work
    I would recommend not using that plugin it leaks "weapon_spawn" entities because it does not remove them after spawning something from them.

    PHP Code:
    WeaponFactoryCreate(String:name[], bool:simFloat:location[3])
    {
        
    Log(sim"Weapon Factory Creating: %s"name);
        
        if (!
    sim)
        {
            new 
    entity SpawnItem(___"weapon_spawn"_true);
            
            
    // Mod location so it spawns around mid level of model.
            
    location[2] += 10.0;
            
            
    // Create random velocity
            
    new Float:vel[3];
            
    vel[0] = GetRandomFloat(-80.080.0);
            
    vel[1] = GetRandomFloat(-80.080.0);
            
    vel[2] = GetRandomFloat(40.080.0);
            
            
    DispatchKeyValueVector(entity"origin"location);
            
    DispatchKeyValue(entity"weapon_selection"name);
            
    DispatchKeyValue(entity"spawnflags""1");
            
    DispatchKeyValue(entity"solid""6");
            
    DispatchKeyValue(entity"count""1");
            
    DispatchKeyValue(entity"body""0");
            
    DispatchKeyValue(entity"spawn_without_director""1");
            
            
    SpawnItemFinish(entity__vel);
            
    AddThingCount(nameFACTORYNAME_WEAPON1);
        }
    }

    MeleeFactoryCreate(String:name[], bool:simFloat:location[3])
    {
        
    Log(sim"Melee Factory Creating: %s"name);
        
        if (!
    sim)
        {
            new 
    entity SpawnItem(___"weapon_melee_spawn"_true);
            
            
    // Mod location so it spawns around mid level of model.
            
    location[2] += 10.0;
            
            
    // Create random velocity
            
    new Float:vel[3];
            
    vel[0] = GetRandomFloat(-80.080.0);
            
    vel[1] = GetRandomFloat(-80.080.0);
            
    vel[2] = GetRandomFloat(40.080.0);
            
            
    DispatchKeyValueVector(entity"origin"location);
            
    DispatchKeyValue(entity"spawnflags""1");
            
    DispatchKeyValue(entity"solid""6");
            
    DispatchKeyValue(entity"count""1");
            
    DispatchKeyValue(entity"body""0");
            
    DispatchKeyValue(entity"melee_weapon"name);
            
            
    SpawnItemFinish(entity__vel);
            
    AddThingCount(nameFACTORYNAME_MELEE1);
        }

    If a person picks up the weapon the weapon_spawn entity still exists because of how the game works.
    __________________
    Lux 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 14:07.


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