Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] %E Format specifier #2099

Open
xerox8521 opened this issue Dec 25, 2023 · 2 comments
Open

[Feature Request] %E Format specifier #2099

xerox8521 opened this issue Dec 25, 2023 · 2 comments

Comments

@xerox8521
Copy link
Contributor

I'm proposing a new specifier %E which takes an entity index which will insert the entity's classname. Similar how %N inserts the players name. If you have a better character suggestion I'm open to hear about it.

Which will make code like this

void Foo( int entity)
{
    char szClassName[32];
    GetEntityClassname(entity, szClassName, sizeof(szClassName));
    PrintToServer("ClassName: %s", szClassName);
}

be replaced with

void Foo( int entity)
{
    PrintToServer("ClassName: %E", entity);
}
@Mikusch
Copy link
Contributor

Mikusch commented Dec 27, 2023

I think having the entity name in there would be great, too. Similar format to ent_remove.
prop_dynamic(prop_resupply_red_2)
beam(beam)

@Localia-cn
Copy link

Localia-cn commented Dec 1, 2024

This is a more convenient way, but I think it should only be used for debugging because it's relatively less efficient.

char[] GetEntityClass( int entity)
{
    static char szClassName[32];
    GetEntityClassname(entity, szClassName, sizeof(szClassName));
    return szClassName;
}

public void OnPluginStart()
{
    PrintToServer("ClassName: %s", GetEntityClass(0));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants