Raised This Month: $ Target: $400
 0% 

Getting the targetname of a pistol just wont work.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kinsi
Senior Member
Join Date: Apr 2013
Old 04-02-2013 , 17:59   Getting the targetname of a pistol just wont work.
Reply With Quote #1

hello,

im currently trying to get the targetname, of a players pistol but it just wont work. i tried it this way:

Code:
new weapona = GetPlayerWeaponSlot(i, CS_SLOT_SECONDARY);
if(IsValidEntity(weapona))
{
decl String:weapname[64];
GetEntPropString(weapona, Prop_Data, "m_iName", weapname, sizeof(weapname));  
PrintToChatAll("\"%s\"", weapname);
but the string i get is just empty, the gun itself actually has a targetname, i checked it via hammer(decompiled) and via entspy.

anyone here that does know the problem?

thanks,

kinsi
Kinsi is offline
Marcus_Brown001
AlliedModders Donor
Join Date: Nov 2012
Location: Illinois, United States
Old 04-02-2013 , 18:18   Re: Getting the targetname of a pistol just wont work.
Reply With Quote #2

It looks right, however, the only thing that looks wrong is the 'CS_SLOT_SECONDARY'. Do you have that defined elsewhere inside the plugin?

If that continues to give you problems you can use SMLIB (http://www.sourcemodplugins.org/). It has a stock called: Client_GetWeaponBySlot(client, slot); and it returns the entity index of the weapon in that slot.
Marcus_Brown001 is offline
Kinsi
Senior Member
Join Date: Apr 2013
Old 04-02-2013 , 18:20   Re: Getting the targetname of a pistol just wont work.
Reply With Quote #3

thanks for responding, no i do not have declared it elsewhere(getting the classname does work actually, just the targetname gets me a nullstring). ill try that out tomorrow.
Kinsi is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 04-02-2013 , 18:23   Re: Getting the targetname of a pistol just wont work.
Reply With Quote #4

How did you check the targetname of an equipped weapon with Hammer?

Just because you picked up a dropped weapon entity that had a targetname does not mean that the equipped copy of it will have one.
__________________
asherkin is offline
Kinsi
Senior Member
Join Date: Apr 2013
Old 04-02-2013 , 18:32   Re: Getting the targetname of a pistol just wont work.
Reply With Quote #5

i didnt check the equipped weapon, i did check the weapon that was placed into the map. further on, i didnt see anything that did change the targetname of it also, so by my logic it shoud keep its targetname, doesnt it?
Kinsi is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 04-02-2013 , 18:34   Re: Getting the targetname of a pistol just wont work.
Reply With Quote #6

You could check m_iHammerID to see if it's the same entity. Then you could find the targetname of the entity on the ground and store it's m_iHammerID for later comparison, this'll only work if it's the same entity and only the targetname is being reset - my guess is that it's a completely different entity.
__________________
asherkin is offline
Kinsi
Senior Member
Join Date: Apr 2013
Old 04-02-2013 , 18:37   Re: Getting the targetname of a pistol just wont work.
Reply With Quote #7

thanks, ill try that out tomorrow. currently im not able to.
Kinsi is offline
Kinsi
Senior Member
Join Date: Apr 2013
Old 04-03-2013 , 05:38   Re: Getting the targetname of a pistol just wont work.
Reply With Quote #8

looks like it doesnt have a hammerid either

the map was released about 3 years ago.

i re-opened it in hammer, and the pistol does not have any inputs, so the targetname shoud stay.


i'll try to find it before pickup and edit the post if it worked or not.

edit:
looks like that does work:


plus i did checked for all the entities once before, and after pickup



and somehow the targetname gets reset.., the entity index stays the same though, so ill use that to identify the weapon

edit:
i just put in a hammerid using entspy, ill just use the edited version of the map on my server ^^ thanks everyone

Last edited by Kinsi; 04-03-2013 at 06:52.
Kinsi 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 16:56.


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