View Single Post
psychonic

BAFFLED
Join Date: May 2008
Old 06-21-2012 , 20:11   Re: SourceMod FindEntityByClassname / SetEntProp extension equivalents?
Reply With Quote #2

Quote:
Originally Posted by Powerlord View Post
Hi guys,

I was wondering if there was an easy way in a SourceMod extension to find an entity by its classname and adjust its properties. This would be quite easy to do in a plugin, but unfortunately, the rest of my logic is already in an extension.

Incidentally, the entity class is vote_controller, and the properties I want to adjust are:
Code:
 -Member: m_iActiveIssueIndex (offset 796) (type integer) (bits 32)
 -Member: m_iOnlyTeamToVote (offset 800) (type integer) (bits 32)
  Sub-Class Table (2 Deep): m_nVoteOptionCount
  -Member: 000 (offset 0) (type integer) (bits 8)
  -Member: 001 (offset 4) (type integer) (bits 8)
  -Member: 002 (offset 8) (type integer) (bits 8)
  -Member: 003 (offset 12) (type integer) (bits 8)
  -Member: 004 (offset 16) (type integer) (bits 8)
 -Member: m_nPotentialVotes (offset 824) (type integer) (bits 32)
 -Member: m_bIsYesNoVote (offset 828) (type integer) (bits 1)
(yes, all of them)
For FEBC, you can copy the native implementation using IServerTools right out of SDK Tools.
http://hg.alliedmods.net/sourcemod-c...tives.cpp#l638

For finding datadesc property offsets and values, use GetDataMap and FindInDataMap on IGameHelpers.
PHP Code:
datamap_t *pMap gamehelpers->GetDataMap(pEntity);
typedescription_t *td gamehelpers->FindInDataMap(pMap"m_nVoteOptionCount");
uint32 nVoteOptionCount = *(uint32 *)((intptr_t)pEntity GetTypeDescOffs(td)); 
psychonic is offline