Raised This Month: $ Target: $400
 0% 

Finding entity names?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Stevenator1
Junior Member
Join Date: Apr 2010
Old 05-06-2010 , 15:12   Finding entity names?
Reply With Quote #1

Hello,

I'm working on an extension to my plugin that allows admins to teleport to any info_target, by way of "sm_teleloc adminRoom" if adminRoom was the name of the info_target.

I am rather new to sourcemod coding, and have gotten a knack for it so far. But I'm still clueless with entity controlling commands.

Code:
public Action:Command_GotoLoc(client, args)
{
    new index = -1;
    while ((index = FindEntityByClassname(index, "info_target")) != -1)
    {
    }
    return Plugin_Handled;
}
I get that the command in there will cycle through every info_target, i just need to have it check its name against the arg1 value, and if true, teleport (I know how to do the argument checking and teleporting, mainly i need the ability to find a name off of an entity index)

Thanks!
Stevenator1 is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 05-06-2010 , 15:33   Re: Finding entity names?
Reply With Quote #2

Try this inside your while loop:

Code:
decl String:strName[50];
GetEntPropString(index, Prop_Data, "m_iName", strName, sizeof(strName));

if(strcmp(strName, "adminRoom") == 0)
{
     // Do teleport code
     break;
}
__________________
pheadxdll is offline
Stevenator1
Junior Member
Join Date: Apr 2010
Old 05-06-2010 , 16:25   Re: Finding entity names?
Reply With Quote #3

Quote:
Originally Posted by pheadxdll View Post
Try this inside your while loop:

Code:
decl String:strName[50];
GetEntPropString(index, Prop_Data, "m_iName", strName, sizeof(strName));

if(strcmp(strName, "adminRoom") == 0)
{
     // Do teleport code
     break;
}
Thanks much. the m_iName was alluding me
Stevenator1 is offline
WhosAsking
Member
Join Date: May 2011
Old 08-31-2011 , 11:16   Re: Finding entity names?
Reply With Quote #4

I'm thinking of a similar situation, only I'm going through func_brushes so as to be able to enable and disable (show and hide) them. Only trouble is, every time I try, the first func_brush it finds, the call terminates abnormally, claiming the "m_iName" property doesn't exist. I suspect this is because not all the func_brushes on the map have names. Is there a way to run through such a list without an abnormal termination in the event you have nameless entities?
WhosAsking is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 09-01-2011 , 06:01   Re: Finding entity names?
Reply With Quote #5

Quote:
Originally Posted by xf117 View Post
Also you can use this:
PHP Code:
decl String:className[35];
GetEdictClassname(iEntityclassNamesizeof(className));
//GetEntityClassname with same syntax if the entity is not an edict. 
GetEdictClassname is a build-in function and considered safer than "GetEntPropString(index, Prop_Data, "m_iName", strName, sizeof(strName));"
xf117: classname != name
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
WhosAsking
Member
Join Date: May 2011
Old 09-01-2011 , 12:20   Re: Finding entity names?
Reply With Quote #6

Thanks for the tip (at the bottom). That actually worked.
WhosAsking 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 09:53.


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