Raised This Month: $ Target: $400
 0% 

Reading string_t array variable?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 08-26-2012 , 13:10   Reading string_t array variable?
Reply With Quote #1

I need to use GetEntDataString() to read strings from a string_t array variable. The problem is it's not returning the string value. I'm assuming it's returning a pointer instead? Does anyone know how to help me with this?

Here is information on the entity I am working with (game_player_equip):
Code:
#define MAX_EQUIP		32

class CGamePlayerEquip : public CRulePointEntity
{
	DECLARE_DATADESC();

public:
	DECLARE_CLASS( CGamePlayerEquip, CRulePointEntity );

	bool		KeyValue( const char *szKeyName, const char *szValue );
	void		Touch( CBaseEntity *pOther );
	void		Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );

	inline bool	UseOnly( void ) { return (m_spawnflags & SF_PLAYEREQUIP_USEONLY) ? true : false; }

private:

	void		EquipPlayer( CBaseEntity *pPlayer );

	string_t	m_weaponNames[MAX_EQUIP];
	int			m_weaponCount[MAX_EQUIP];
};

LINK_ENTITY_TO_CLASS( game_player_equip, CGamePlayerEquip );

//---------------------------------------------------------
// Save/Restore
//---------------------------------------------------------
BEGIN_DATADESC( CGamePlayerEquip )
	DEFINE_AUTO_ARRAY( m_weaponNames,		FIELD_STRING ),
	DEFINE_AUTO_ARRAY( m_weaponCount,		FIELD_INTEGER ),
END_DATADESC()
Here is the datamap dump for the variable I'm working with:
Code:
- m_weaponNames (Save)(128 Bytes)
Here is the code I'm using to try and print all the strings from the m_weaponNames variable.
Code:
ReadGamePlayerEquip(iEnt)
{
	decl String:szBuffer[128];
	new iWeaponNamesOffset = FindDataMapOffs(iEnt, "m_weaponNames");
	
	for(new i=0; i<MAX_EQUIP; i++)
	{
		GetEntDataString(iEnt, iWeaponNamesOffset + (i * 4), szBuffer, sizeof(szBuffer));
		PrintToServer(szBuffer);
	}
}
hlstriker is offline
Prof. Orribilus
Member
Join Date: Jun 2013
Location: Italy
Old 08-28-2015 , 13:31   Re: Reading string_t array variable?
Reply With Quote #2

Have you figured out something in the while?
__________________

Prof. Orribilus is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 08-28-2015 , 14:10   Re: Reading string_t array variable?
Reply With Quote #3

Quote:
Originally Posted by Prof. Orribilus View Post
Have you figured out something in the while?
Current snapshots natively support reading string_t props (and in the 3 years since this thread was posted, GetEntPropString supports array props directly).
__________________
asherkin is offline
Prof. Orribilus
Member
Join Date: Jun 2013
Location: Italy
Old 08-28-2015 , 15:03   Re: Reading string_t array variable?
Reply With Quote #4

Thank you. You are always replying me
__________________

Prof. Orribilus 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:16.


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