Raised This Month: $51 Target: $400
 12% 

[ L4D2 ] Weapon Cleaner


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
theproperson
Member
Join Date: Feb 2017
Old 07-17-2018 , 03:39   [ L4D2 ] Weapon Cleaner
Reply With Quote #1

There seems to be no working weapon cleaner that I can find for use on my left 4 dead 2 server. I have a major issue with server lag due to weapons constantly being spawned on player deaths, mainly in survival since I allow respawns , but one that cleaned up weapons for all modes would be what I'm going for. I've tried using the Advanced Weapon Cleaner plugin that says its for any source game but it will not work here. Spawning like 100 weapons and dropping them did not enable its cleaning effects nor did editing the cvars tend to do anything.

Last edited by theproperson; 07-17-2018 at 03:39.
theproperson is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 07-17-2018 , 03:43   Re: [ L4D2 ] Weapon Cleaner
Reply With Quote #2

You should report that to the plugin thread so the dev can fix it
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
theproperson
Member
Join Date: Feb 2017
Old 07-17-2018 , 03:46   Re: [ L4D2 ] Weapon Cleaner
Reply With Quote #3

Quote:
Originally Posted by Lux View Post
You should report that to the plugin thread so the dev can fix it
I was hoping to find a working and up to date one. That plugin is over a year old with the last update, theres no real reason to try getting support for it.
theproperson is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 07-17-2018 , 03:58   Re: [ L4D2 ] Weapon Cleaner
Reply With Quote #4

Dam that logic tho
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
LenHard
Senior Member
Join Date: Jan 2016
Old 07-17-2018 , 06:17   Re: [ L4D2 ] Weapon Cleaner
Reply With Quote #5

PHP Code:
#include <sourcemod>
#include <sdktools_functions>
#include <sdktools_entinput>

#pragma newdecls required
#pragma semicolon 1

public void OnPluginStart() {
    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Pre);
}

public 
void Event_PlayerDeath(Event hEvent, const char[] sEventNamebool bDontBroadcast)
{
    
int client GetClientOfUserId(hEvent.GetInt("userid"));
    
    if (
client <= MaxClients && IsClientInGame(client))
    {
        
int offset FindDataMapInfo(client"m_hMyWeapons") - 4;
        
        for (
int i 048i++) 
        {
            
offset += 4;
    
            
int iWeapon GetEntDataEnt2(clientoffset);
            
            if (
IsValidEdict(iWeapon)) 
            {
                
int iAmmo FindDataMapInfo(client"m_iAmmo") + (GetEntProp(iWeaponProp_Data"m_iPrimaryAmmoType") * 4);
                
SetEntData(clientiAmmo04true);
        
                
iAmmo FindDataMapInfo(client"m_iAmmo") + (GetEntProp(iWeaponProp_Data"m_iSecondaryAmmoType") * 4);
                
SetEntData(clientiAmmo04true);
        
                if (
RemovePlayerItem(clientiWeapon)) 
                    
AcceptEntityInput(iWeapon"Kill");
            }
        }
    }

This should prevent weapons from dropping when the player gets killed. [Untested]
__________________
LenHard is offline
theproperson
Member
Join Date: Feb 2017
Old 07-17-2018 , 07:01   Re: [ L4D2 ] Weapon Cleaner
Reply With Quote #6

Quote:
Originally Posted by LenHard View Post
PHP Code:
#include <sourcemod>
#include <sdktools_functions>
#include <sdktools_entinput>

#pragma newdecls required
#pragma semicolon 1

public void OnPluginStart() {
    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Pre);
}

public 
void Event_PlayerDeath(Event hEvent, const char[] sEventNamebool bDontBroadcast)
{
    
int client GetClientOfUserId(hEvent.GetInt("userid"));
    
    if (
client <= MaxClients && IsClientInGame(client))
    {
        
int offset FindDataMapInfo(client"m_hMyWeapons") - 4;
        
        for (
int i 048i++) 
        {
            
offset += 4;
    
            
int iWeapon GetEntDataEnt2(clientoffset);
            
            if (
IsValidEdict(iWeapon)) 
            {
                
int iAmmo FindDataMapInfo(client"m_iAmmo") + (GetEntProp(iWeaponProp_Data"m_iPrimaryAmmoType") * 4);
                
SetEntData(clientiAmmo04true);
        
                
iAmmo FindDataMapInfo(client"m_iAmmo") + (GetEntProp(iWeaponProp_Data"m_iSecondaryAmmoType") * 4);
                
SetEntData(clientiAmmo04true);
        
                if (
RemovePlayerItem(clientiWeapon)) 
                    
AcceptEntityInput(iWeapon"Kill");
            }
        }
    }

This should prevent weapons from dropping when the player gets killed. [Untested]

Thank you very much, really helped remove all the item spam.
theproperson is offline
Reply



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 12:51.


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