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

Problem with /clear entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DexonRL
Junior Member
Join Date: Jul 2020
Location: Israel
Old 07-22-2020 , 17:45   Problem with /clear entity
Reply With Quote #1

Hey, i made a simple entity deleter (/clear) plugin.
and i tried to get the number of the entities that gets deleted.

I tried GetEntityCount() but its not working. it prints me huge number over 300000.

The code:

Code:
public Action Command_ClearMap(int client, int args)
{
	int maxent = GetMaxEntities();
	char weapon[64];
	for (int i = MaxClients; i < maxent; i++)
	{
		if (IsValidEdict(i) && IsValidEntity(i))
		{
			GetEdictClassname(i, weapon, sizeof(weapon));
			if ((StrContains(weapon, "weapon_") != -1 || StrContains(weapon, "item_") != -1) && GetEntDataEnt2(i, g_WeaponParent) == -1)
				RemoveEdict(i);
		}
		PrintToChatAll("%s The map has been cleared, \x02%d\x01 Items deleted.", PREFIX, ...);
	}
	return Plugin_Continue;
}
Thanks (:

Last edited by DexonRL; 07-23-2020 at 21:36.
DexonRL is offline
SSheriFF
AlliedModders Donor
Join Date: May 2020
Location: Israel
Old 07-24-2020 , 19:57   Re: Problem with /clear entity
Reply With Quote #2

Quote:
Originally Posted by DexonRL View Post
Hey, i made a simple entity deleter (/clear) plugin.
and i tried to get the number of the entities that gets deleted.

I tried GetEntityCount() but its not working. it prints me huge number over 300000.

The code:

Code:
public Action Command_ClearMap(int client, int args)
{
	int maxent = GetMaxEntities();
	char weapon[64];
	for (int i = MaxClients; i < maxent; i++)
	{
		if (IsValidEdict(i) && IsValidEntity(i))
		{
			GetEdictClassname(i, weapon, sizeof(weapon));
			if ((StrContains(weapon, "weapon_") != -1 || StrContains(weapon, "item_") != -1) && GetEntDataEnt2(i, g_WeaponParent) == -1)
				RemoveEdict(i);
		}
		PrintToChatAll("%s The map has been cleared, \x02%d\x01 Items deleted.", PREFIX, ...);
	}
	return Plugin_Continue;
}
Thanks (:
Try this:
PHP Code:
public Action Command_ClearMap(int clientint args)
{
    
int maxent GetMaxEntities();
    
int counter 0;
    
char weapon[64];
    for (
int i MaxClientsmaxenti++)
    {
        if (
IsValidEdict(i) && IsValidEntity(i))
        {
            
GetEdictClassname(iweaponsizeof(weapon));
            if ((
StrContains(weapon"weapon_") != -|| StrContains(weapon"item_") != -1) && GetEntDataEnt2(ig_WeaponParent) == -1)
            {
                
RemoveEdict(i);
                
counter++;
            }
        }
        
PrintToChatAll("%s The map has been cleared, \x02%d\x01 Items deleted."PREFIXcounter);
    }
    return 
Plugin_Continue;

__________________
Taking small private requests (Free) and big private requests (Paid).
Contact me via Discord: WilDick#1524

My Plugins:
SSheriFF is offline
DexonRL
Junior Member
Join Date: Jul 2020
Location: Israel
Old 07-25-2020 , 16:54   Re: Problem with /clear entity
Reply With Quote #3

Quote:
Originally Posted by SSheriFF View Post
Try this:
PHP Code:
public Action Command_ClearMap(int clientint args)
{
    
int maxent GetMaxEntities();
    
int counter 0;
    
char weapon[64];
    for (
int i MaxClientsmaxenti++)
    {
        if (
IsValidEdict(i) && IsValidEntity(i))
        {
            
GetEdictClassname(iweaponsizeof(weapon));
            if ((
StrContains(weapon"weapon_") != -|| StrContains(weapon"item_") != -1) && GetEntDataEnt2(ig_WeaponParent) == -1)
            {
                
RemoveEdict(i);
                
counter++;
            }
        }
        
PrintToChatAll("%s The map has been cleared, \x02%d\x01 Items deleted."PREFIXcounter);
    }
    return 
Plugin_Continue;

Thanks it worked (:
תודה אחינו
DexonRL 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 21:25.


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