Raised This Month: $32 Target: $400
 8% 

[ANY] List all entity classnames in-game, and their count.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
StrikerMan780
AlliedModders Donor
Join Date: Jul 2009
Location: Canada
Old 07-01-2013 , 13:32   [ANY] List all entity classnames in-game, and their count.
Reply With Quote #1

I'm getting a lot of issues with running out of edicts, so I want to debug this.

Could someone make a plugin that, upon issuing a command, lists all of the current entities that exist in a map by classname, and the number defining the amount of said entity that exists?
StrikerMan780 is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 07-01-2013 , 17:06   Re: [ANY] List all entity classnames in-game, and their count.
Reply With Quote #2

Here you go.
http://forums.alliedmods.net/showthread.php?t=219682
__________________
Chaosxk is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 07-01-2013 , 17:07   Re: [ANY] List all entity classnames in-game, and their count.
Reply With Quote #3

If nobody else has gotten to this by the time I'm home, I'll do it - shouldn't take but a minute or two.
necavi is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 07-01-2013 , 19:05   Re: [ANY] List all entity classnames in-game, and their count.
Reply With Quote #4

I made a version based on (only in the roughest sense) chaosxk's plugin.
This one will be faster, provides a more detailed log (whereas the other version doesn't even tell you the count of each entity, which is what you originally wanted) and is generally cleaner.
Here it is:
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>

public Plugin:myinfo = {
    
name "Entity Logger",
    
description "Log all entities for debugging purposes.",
    
author "necavi",
    
version "1.0",
    
url "http://necavi.org/"
};

public 
OnPluginStart() 
{
    
RegServerCmd("sm_logentity"Command_LogEntities"Log all entities to a config file.");
}

public 
Action:Command_LogEntities(args
{
    
LogEntities();
    return 
Plugin_Handled;
}

LogEntities() {
    new 
ent = -1;
    new 
counter 0;
    new 
String:classname[128];
    new 
Handle:classnames CreateArray(128);
    new 
Handle:classnameCounts CreateArray();
    new 
index = -1;
    while((
ent FindEntityByClassname(ent"*")) != -1
    {
        if(
IsValidEntity(ent)) 
        {
            
index FindStringInArray(classnamesclassname);
            if(
index > -1)
            {
                
SetArrayCell(classnameCountsindexGetArrayCell(classnameCountsindex) + 1);
            }
            else
            {
                
PushArrayString(classnamesclassname);
                
PushArrayCell(classnameCounts1);
            }
            
counter++;
        }
    }
    
    new 
String:path[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMpathsizeof(path), "logs/entities.log");
    new 
Handle:file OpenFile(path"w");
    
WriteFileLine(file"==== Entity List ====");
    for(new 
0GetArraySize(classnames); i++)
    {
        
GetArrayString(classnamesiclassnamesizeof(classname));
        
WriteFileLine(file"[%d] Count: %d Classname: %s."1GetArrayCell(classnameCountsi), classname);
    }
    
CloseHandle(classnames);
    
CloseHandle(classnameCounts);
    
WriteFileLine(file"Total entities: %d."counter);
    
PrintToServer("%d entities have been logged to %s."counterpath);
    
FlushFile(file);
    
CloseHandle(file);


Last edited by necavi; 07-01-2013 at 20:07.
necavi is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 07-01-2013 , 21:39   Re: [ANY] List all entity classnames in-game, and their count.
Reply With Quote #5

Seems to be happening frequently as of late.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 07-01-2013 , 21:41   Re: [ANY] List all entity classnames in-game, and their count.
Reply With Quote #6

What does?
necavi is offline
foo bar
AlliedModders Donor
Join Date: Dec 2012
Location: Canada
Old 07-16-2013 , 13:34   Re: [ANY] List all entity classnames in-game, and their count.
Reply With Quote #7

I put together an entity logging and reporting script to track down edict exhaustion a while ago. The code is at https://github.com/foobarhl/sourcemo...g/srcdsdiag.sp

It will dump out the entities on a map when the entity count exceeds a certain threshold, and adds a "sm_entreport" command to display the current entity count to your chat during run time.

It's not great, or even good, but it was invaluable to helping hunt down edict exhaustion issues.
__________________
[foo] bar
foo-games.com Game Mods, Plugins and Tools for Game Masters | My Github
foo bar is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 07-16-2013 , 14:06   Re: [ANY] List all entity classnames in-game, and their count.
Reply With Quote #8

The script you posted generates 54 warnings, good job.

Yours sincerely
Impact
__________________
Impact123 is offline
foo bar
AlliedModders Donor
Join Date: Dec 2012
Location: Canada
Old 07-17-2013 , 02:04   Re: [ANY] List all entity classnames in-game, and their count.
Reply With Quote #9

Quote:
Originally Posted by Impact123 View Post
The script you posted generates 54 warnings, good job.

Yours sincerely
Impact
I'm working on improving my quantity of warnings. The current plugin I'm writing has 146 warnings. When I get it over 200 I'll send you a copy!
__________________
[foo] bar
foo-games.com Game Mods, Plugins and Tools for Game Masters | My Github
foo bar is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 07-17-2013 , 02:19   Re: [ANY] List all entity classnames in-game, and their count.
Reply With Quote #10

...are...what.
necavi 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:04.


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