AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [ANY] List all entity classnames in-game, and their count. (https://forums.alliedmods.net/showthread.php?t=219663)

StrikerMan780 07-01-2013 13:32

[ANY] List all entity classnames in-game, and their count.
 
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?

Chaosxk 07-01-2013 17:06

Re: [ANY] List all entity classnames in-game, and their count.
 
Here you go.
http://forums.alliedmods.net/showthread.php?t=219682

necavi 07-01-2013 17:07

Re: [ANY] List all entity classnames in-game, and their count.
 
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 07-01-2013 19:05

Re: [ANY] List all entity classnames in-game, and their count.
 
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);



friagram 07-01-2013 21:39

Re: [ANY] List all entity classnames in-game, and their count.
 
Seems to be happening frequently as of late.

necavi 07-01-2013 21:41

Re: [ANY] List all entity classnames in-game, and their count.
 
What does?

foo bar 07-16-2013 13:34

Re: [ANY] List all entity classnames in-game, and their count.
 
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.

Impact123 07-16-2013 14:06

Re: [ANY] List all entity classnames in-game, and their count.
 
The script you posted generates 54 warnings, good job.

Yours sincerely
Impact

foo bar 07-17-2013 02:04

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

Originally Posted by Impact123 (Post 1992282)
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!

necavi 07-17-2013 02:19

Re: [ANY] List all entity classnames in-game, and their count.
 
...are...what.


All times are GMT -4. The time now is 05:54.

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