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

Solved Printing the targetname doesn't work.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ethorbit
Member
Join Date: Sep 2016
Location: Oregon
Old 12-25-2017 , 23:37   Printing the targetname doesn't work.
Reply With Quote #1

After reading https://forums.alliedmods.net/showthread.php?t=77802&highlight=TARGETNAME?t =77802&highlight=TARGETNAME
I tried this:

PHP Code:
decl String:targetname[128];
GetEntPropString(entityProp_Data"m_iName"targetnamesizeof(targetname));
PrintToChatAll("%s"targetname);
if(
StrEqual(targetname,"ThisIsNew")){
PrintToChatAll("Works");

It doesn't print the targetname and it doesn't print "Works".

Last edited by Ethorbit; 12-26-2017 at 15:30.
Ethorbit is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 12-26-2017 , 01:19   Re: Printing the targetname doesn't work.
Reply With Quote #2

Classname and targetname are different.
Mitchell is offline
Ethorbit
Member
Join Date: Sep 2016
Location: Oregon
Old 12-26-2017 , 02:18   Re: Printing the targetname doesn't work.
Reply With Quote #3

Quote:
Originally Posted by Mitchell View Post
Classname and targetname are different.
Whoops that was my old version.
Updated.
Ethorbit is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 12-26-2017 , 02:47   Re: Printing the targetname doesn't work.
Reply With Quote #4

If it isnt printing the targetname then that means the target name isn't being set correctly on the entity.
Mitchell is offline
Ethorbit
Member
Join Date: Sep 2016
Location: Oregon
Old 12-26-2017 , 03:23   Re: Printing the targetname doesn't work.
Reply With Quote #5

Quote:
Originally Posted by Mitchell View Post
If it isnt printing the targetname then that means the target name isn't being set correctly on the entity.
I don't know what you mean.
This is what I did to change the targetname if that's what you mean:
PHP Code:
DispatchKeyValue(entity"m_iName""ThisIsNew"); 
Ethorbit is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-26-2017 , 03:36   Re: Printing the targetname doesn't work.
Reply With Quote #6

m_iName is the name of the netprop. I believe the keyvalue name is just "name"
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 12-26-2017 at 03:36.
Powerlord is offline
Ethorbit
Member
Join Date: Sep 2016
Location: Oregon
Old 12-26-2017 , 03:55   Re: Printing the targetname doesn't work.
Reply With Quote #7

Quote:
Originally Posted by Powerlord View Post
m_iName is the name of the netprop. I believe the keyvalue name is just "name"
I tried different things like:
PHP Code:
DispatchKeyValue(entity"Name""ThisIsNew"); 
PHP Code:
DispatchKeyValue(entity"m_Name""ThisIsNew"); 
PHP Code:
GetEntPropString(entityProp_Data"m_iName"targetnamesizeof(targetname)); 
PHP Code:
GetEntPropString(entityProp_Data"m_Name"targetnamesizeof(targetname)); 
PHP Code:
GetEntPropString(entityProp_Data"Name"targetnamesizeof(targetname)); 
Code:
[SM] Exception reported: Property "Name" not found
Code:
[SM] Exception reported: Property "m_Name" not found
If I try to set GetEntPropString with Name or m_Name I get an error, after all of this it still will not print the targetname.

Here is the script:
https://pastebin.com/BfqXCkfx
Maybe it works but the way I did it was wrong?

Last edited by Ethorbit; 12-26-2017 at 04:11.
Ethorbit is offline
Vit_amin
Senior Member
Join Date: Dec 2015
Location: Russian Federation
Old 12-26-2017 , 06:13   Re: Printing the targetname doesn't work.
Reply With Quote #8

Code:
DispatchKeyValue(iEntity, "targetname", "TargetName of Entity");
Vit_amin is offline
Ethorbit
Member
Join Date: Sep 2016
Location: Oregon
Old 12-26-2017 , 15:30   Re: Printing the targetname doesn't work.
Reply With Quote #9

Quote:
Originally Posted by Vit_amin View Post
Code:
DispatchKeyValue(iEntity, "targetname", "TargetName of Entity");
Thanks! Targetname prints now.
Ethorbit 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 07:36.


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