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

Removing All Map Weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ShadowRanger
Junior Member
Join Date: Aug 2017
Old 10-28-2017 , 09:08   Removing All Map Weapons
Reply With Quote #1

So I'm trying to write a script that removes all map placed weapons, but am having trouble and my script isn't working.

Code:
public void RemoveMapWeapons()
{
	int maxEntities = GetMaxEntities();
	char weapon[64];

	for (int i = MaxClients; i < maxEntities; i++)
	{
		if (IsValidEntity(i) && IsValidEdict(i))
		{
			GetEdictClassname(i, weapon, sizeof(weapon));

			if ((StrContains(weapon, "weapon_") != -1 || StrContains(weapon, "item_") != -1) && GetEntDataEnt2(i, g_iWeaponParent) == -1)
			{
				AcceptEntityInput(i, "KillHierarchy");
			}
		}
	}
}
g_iWeaponParent is declared like this by the way:

Code:
g_iWeaponParent = FindSendPropOffs("CBaseCombatWeapon", "m_hOwnerEntity");
I'm really not sure what I'm doing wrong. I have tried using RemoveEdict but that just causes my game/server to crash. Any help would be much appreciated. Thanks in advance.
ShadowRanger is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 10-28-2017 , 09:34   Re: Removing All Map Weapons
Reply With Quote #2

what game?
if csgo you don't want map's weapon just use mp_weapons_allow_map_placed 0
__________________
8guawong is offline
ShadowRanger
Junior Member
Join Date: Aug 2017
Old 10-28-2017 , 10:00   Re: Removing All Map Weapons
Reply With Quote #3

Quote:
Originally Posted by 8guawong View Post
what game?
if csgo you don't want map's weapon just use mp_weapons_allow_map_placed 0
This is for CS:GO, and I want map placed weapons, I'm just working on a plugin that requires them to be removed on demand at the start of certain rounds.
ShadowRanger is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 10-28-2017 , 10:12   Re: Removing All Map Weapons
Reply With Quote #4

AcceptEntityInput(i, "KillHierarchy"); -> AcceptEntityInput(i, "Kill");

try this
__________________
8guawong is offline
Vaggelis
Senior Member
Join Date: May 2017
Old 10-28-2017 , 10:12   Re: Removing All Map Weapons
Reply With Quote #5

PHP Code:
RemoveDroppedWeapons()
{
    new 
max_ent GetMaxEntities()
    new 
String:weapon[64]
    
    for(new 
GetMaxClients(); max_enti++)
    {
        if(
IsValidEdict(i) && IsValidEntity(i))
        {
            
GetEdictClassname(iweaponsizeof(weapon))
            
            if((
StrContains(weapon"weapon_") != -1) && GetEntProp(iProp_Send"m_iState") == 0)
            {
                
RemoveEdict(i)
            }
        }
    }


Last edited by Vaggelis; 10-28-2017 at 10:13.
Vaggelis is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-28-2017 , 12:02   Re: Removing All Map Weapons
Reply With Quote #6

PHP Code:
#include <sdktools>

plaaa()
{
    
int ent = -1;
    
char clsname[30];

    while( (
ent FindEntityByClassname(ent"weapon_*")) != -)
    {
        
GetEntityClassname(entclsnamesizeof(clsname));
        
PrintToServer("%s %i"clsnameent);
        
AcceptEntityInput(ent"Kill"); // Safer than RemoveEdict()
    
}

__________________
Do not Private Message @me

Last edited by Bacardi; 10-28-2017 at 12:08.
Bacardi is offline
Zeisen
Member
Join Date: Nov 2016
Location: Republic of Korea
Old 10-28-2017 , 13:04   Re: Removing All Map Weapons
Reply With Quote #7

Quote:
Originally Posted by Bacardi View Post
PHP Code:
#include <sdktools>

plaaa()
{
    
int ent = -1;
    
char clsname[30];

    while( (
ent FindEntityByClassname(ent"weapon_*")) != -)
    {
        
GetEntityClassname(entclsnamesizeof(clsname));
        
PrintToServer("%s %i"clsnameent);
        
AcceptEntityInput(ent"Kill"); // Safer than RemoveEdict()
    
}

Wait, is weapon_* works?
Zeisen is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-28-2017 , 15:36   Re: Removing All Map Weapons
Reply With Quote #8

asterix* only work end of classname. not *before.

and "*" you can get all.
__________________
Do not Private Message @me
Bacardi is offline
ShadowRanger
Junior Member
Join Date: Aug 2017
Old 10-29-2017 , 23:51   Re: Removing All Map Weapons
Reply With Quote #9

Thanks for the help guys, appreciate it.
ShadowRanger 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 14:02.


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