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

Solved [CSGO] Entity name not pulling back


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FuZ!on
Senior Member
Join Date: Aug 2007
Old 03-18-2020 , 14:23   [CSGO] Entity name not pulling back
Reply With Quote #1

Hi,

I'm attempting to figure out what type of entities I should use in my map to have SourceMod react when a trigger is hit.

I have a trigger_multiple entity created in my map titled multiple1.

Here is my code:

PHP Code:
public OnEntityCreated(entity, const char[] classname)
{
    
char entity_name[50];
    
GetEntPropString(entityProp_Data"m_iName"entity_namesizeof(entity_name));
    
    
LogMessage("Entity %d has been created.  Name: %s  Classname: %s"entityentity_nameclassname);
    
    if (
StrContains(classname"trigger"))
    {
        
SDKHook(entitySDKHook_StartTouchOnEntityTouch);
    }

Here is the output from the LogMessage above:

Quote:
Mar 18 18:20:27: L 03/18/2020 - 18:20:27: [TriggerTouch2.smx] Entity 76 has been created. Name: Classname: trigger_multiple
You can see that the name is returning as blank. How can I fix this?

Last edited by FuZ!on; 03-22-2020 at 11:14.
FuZ!on is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 03-18-2020 , 14:47   Re: Entity name not pulling back
Reply With Quote #2

Try "m_ModelName".......
__________________
Waiting for HL3,Day of Defeat3 ,but will it ever come? So I'm gonna play COD WW2.>>>>SM_SKINCHOOSER<<<<
>>You need Models for DODS/CSS/CSGO , than click here!!!<<
andi67 is offline
FuZ!on
Senior Member
Join Date: Aug 2007
Old 03-18-2020 , 15:00   Re: Entity name not pulling back
Reply With Quote #3

Thanks for the reply. Using m_ModelName:

PHP Code:
GetEntPropString(entityProp_Data"m_ModelName"entity_namesizeof(entity_name)); 
provides the same result.
FuZ!on is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 03-18-2020 , 15:00   Re: Entity name not pulling back
Reply With Quote #4

Prop_Data and "m_iName" is correct to get the targetname. Are you sure it's set? Don't see why it wouldn't retrieve it. Which game?

I know this is just a test case, but instead of StrContains it's more efficient to use:
PHP Code:
if (strncmp(classname"trigger"7) ) 
to check the first 7 chars match "trigger" to detect all types of "trigger_*" ents.

Maybe use Stripper:Source to dump the maps properties and verify it's targetname in there. Doesn't make sense unless this is some uncommon game and "GetEntPropString" is broken on it but you would surely get errors saying so.
__________________

Last edited by Silvers; 03-18-2020 at 15:04.
Silvers is offline
FuZ!on
Senior Member
Join Date: Aug 2007
Old 03-18-2020 , 15:45   Re: Entity name not pulling back
Reply With Quote #5

Forgot to mention... this is CSGO. Also, thanks for the tip with strncmp.

In regards to if the entity name is set... I know it is because I created it in hammer:



I'm having an issue getting Stripper:Source running on my test server but I'll try and confirm when I can get it running.
FuZ!on is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 03-18-2020 , 15:57   Re: [CSGO] Entity name not pulling back
Reply With Quote #6

http://www.bailopan.net/stripper/snapshots/1.2/ grab the git129 version, I guess that should work.

I don't know if this is another issue with CSGO or what, sorry.
__________________

Last edited by Silvers; 03-18-2020 at 15:58.
Silvers is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 03-18-2020 , 16:55   Re: [CSGO] Entity name not pulling back
Reply With Quote #7

https://forums.alliedmods.net/showthread.php?p=1639789

Maybe this can help you...
__________________
Waiting for HL3,Day of Defeat3 ,but will it ever come? So I'm gonna play COD WW2.>>>>SM_SKINCHOOSER<<<<
>>You need Models for DODS/CSS/CSGO , than click here!!!<<
andi67 is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 03-20-2020 , 05:32   Re: [CSGO] Entity name not pulling back
Reply With Quote #8

Entity properties are not yet available in OnEntityCreated, you need to wait until the entity is spawned.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 03-22-2020 , 04:21   Re: [CSGO] Entity name not pulling back
Reply With Quote #9

Also,

Quote:
Originally Posted by FuZ!on View Post
Hi,
if (StrContains(classname, "trigger"))
should be:
Code:
if (-1 != StrContains(classname, "trigger"))
or better:

Code:
if (0 == strcmp(classname, "trigger_multiple"))
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 03-22-2020 , 04:59   Re: [CSGO] Entity name not pulling back
Reply With Quote #10

Quote:
Originally Posted by Dragokas View Post
or better:
or better:
PHP Code:
if (strncmp(classname"trigger"7) == 0
To match all "trigger" entities like OP was attempting. But since you know which trigger specifically I would match the whole classname in this case anyway.


Quote:
Originally Posted by DJ Tsunami View Post
Entity properties are not yet available in OnEntityCreated, you need to wait until the entity is spawned.
This was most likely the problem. When using OnEntityCreated you have to wait for the properties to be valid so hook the entity with SDKHook_SpawnPost and it should work. Some things require RequestFrame within SpawnPost to delay it even more before getting valid properties but I've only noticed this is required for getting the velocity of a projectile. See the [TUT] I wrote for more details.
__________________
Silvers is offline
Reply


Thread Tools
Display Modes

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 20:14.


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