Merge pull request #2 from LivingInPortal/master
Use SourceMod API to get entity objects.
This commit is contained in:
commit
6e0b40e1bc
@ -36,8 +36,6 @@
|
|||||||
* @brief Implement extension code here.
|
* @brief Implement extension code here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CGlobalVars *gpGlobals = NULL;
|
|
||||||
|
|
||||||
Outputinfo g_Outputinfo; /**< Global singleton for extension's main interface */
|
Outputinfo g_Outputinfo; /**< Global singleton for extension's main interface */
|
||||||
|
|
||||||
SMEXT_LINK(&g_Outputinfo);
|
SMEXT_LINK(&g_Outputinfo);
|
||||||
@ -108,47 +106,14 @@ private:
|
|||||||
CBaseEntityOutput( CBaseEntityOutput& ); // protect from accidental copying
|
CBaseEntityOutput( CBaseEntityOutput& ); // protect from accidental copying
|
||||||
};
|
};
|
||||||
|
|
||||||
BEGIN_SIMPLE_DATADESC( CEventAction )
|
|
||||||
DEFINE_FIELD( m_iTarget, FIELD_STRING ),
|
|
||||||
DEFINE_FIELD( m_iTargetInput, FIELD_STRING ),
|
|
||||||
DEFINE_FIELD( m_iParameter, FIELD_STRING ),
|
|
||||||
DEFINE_FIELD( m_flDelay, FIELD_FLOAT ),
|
|
||||||
DEFINE_FIELD( m_nTimesToFire, FIELD_INTEGER ),
|
|
||||||
DEFINE_FIELD( m_iIDStamp, FIELD_INTEGER ),
|
|
||||||
END_DATADESC()
|
|
||||||
|
|
||||||
BEGIN_SIMPLE_DATADESC( CBaseEntityOutput )
|
|
||||||
//DEFINE_CUSTOM_FIELD( m_Value, variantFuncs ),
|
|
||||||
END_DATADESC()
|
|
||||||
|
|
||||||
int CBaseEntityOutput::NumberOfElements(void)
|
int CBaseEntityOutput::NumberOfElements(void)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
if (m_ActionList == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (CEventAction *ev = m_ActionList; ev != NULL; ev = ev->m_pNext)
|
for (CEventAction *ev = m_ActionList; ev != NULL; ev = ev->m_pNext)
|
||||||
|
{
|
||||||
count++;
|
count++;
|
||||||
|
}
|
||||||
return (count);
|
return count;
|
||||||
}
|
|
||||||
|
|
||||||
inline CBaseEntity *GetCBaseEntity(int Num)
|
|
||||||
{
|
|
||||||
#if SOURCE_ENGINE >= SE_LEFT4DEAD
|
|
||||||
edict_t *pEdict = (edict_t *)(gpGlobals->pEdicts + Num);
|
|
||||||
#else
|
|
||||||
edict_t *pEdict = engine->PEntityOfEntIndex(Num);
|
|
||||||
#endif
|
|
||||||
if(!pEdict || pEdict->IsFree())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
IServerUnknown *pUnk;
|
|
||||||
if((pUnk = pEdict->GetUnknown()) == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return pUnk->GetBaseEntity();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int GetDataMapOffset(CBaseEntity *pEnt, const char *pName)
|
inline int GetDataMapOffset(CBaseEntity *pEnt, const char *pName)
|
||||||
@ -184,7 +149,7 @@ cell_t GetOutputCount(IPluginContext *pContext, const cell_t *params)
|
|||||||
char *pOutput;
|
char *pOutput;
|
||||||
pContext->LocalToString(params[2], &pOutput);
|
pContext->LocalToString(params[2], &pOutput);
|
||||||
|
|
||||||
CBaseEntity *pEntity = GetCBaseEntity(params[1]);
|
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(gamehelpers->IndexToReference(params[1]));
|
||||||
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
|
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
|
||||||
|
|
||||||
if(pEntityOutput == NULL)
|
if(pEntityOutput == NULL)
|
||||||
@ -198,7 +163,7 @@ cell_t GetOutputTarget(IPluginContext *pContext, const cell_t *params)
|
|||||||
char *pOutput;
|
char *pOutput;
|
||||||
pContext->LocalToString(params[2], &pOutput);
|
pContext->LocalToString(params[2], &pOutput);
|
||||||
|
|
||||||
CBaseEntity *pEntity = GetCBaseEntity(params[1]);
|
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(gamehelpers->IndexToReference(params[1]));
|
||||||
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
|
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
|
||||||
|
|
||||||
if(pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
|
if(pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
|
||||||
@ -225,7 +190,7 @@ cell_t GetOutputTargetInput(IPluginContext *pContext, const cell_t *params)
|
|||||||
char *pOutput;
|
char *pOutput;
|
||||||
pContext->LocalToString(params[2], &pOutput);
|
pContext->LocalToString(params[2], &pOutput);
|
||||||
|
|
||||||
CBaseEntity *pEntity = GetCBaseEntity(params[1]);
|
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(gamehelpers->IndexToReference(params[1]));
|
||||||
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
|
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
|
||||||
|
|
||||||
if (pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
|
if (pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
|
||||||
@ -252,7 +217,7 @@ cell_t GetOutputParameter(IPluginContext *pContext, const cell_t *params)
|
|||||||
char *pOutput;
|
char *pOutput;
|
||||||
pContext->LocalToString(params[2], &pOutput);
|
pContext->LocalToString(params[2], &pOutput);
|
||||||
|
|
||||||
CBaseEntity *pEntity = GetCBaseEntity(params[1]);
|
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(gamehelpers->IndexToReference(params[1]));
|
||||||
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
|
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
|
||||||
|
|
||||||
if (pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
|
if (pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
|
||||||
@ -279,7 +244,7 @@ cell_t GetOutputDelay(IPluginContext *pContext, const cell_t *params)
|
|||||||
char *pOutput;
|
char *pOutput;
|
||||||
pContext->LocalToString(params[2], &pOutput);
|
pContext->LocalToString(params[2], &pOutput);
|
||||||
|
|
||||||
CBaseEntity *pEntity = GetCBaseEntity(params[1]);
|
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(gamehelpers->IndexToReference(params[1]));
|
||||||
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
|
CBaseEntityOutput *pEntityOutput = GetOutput(pEntity, pOutput);
|
||||||
|
|
||||||
if (pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
|
if (pEntityOutput == NULL || pEntityOutput->m_ActionList == NULL)
|
||||||
@ -312,9 +277,3 @@ void Outputinfo::SDK_OnAllLoaded()
|
|||||||
{
|
{
|
||||||
sharesys->AddNatives(myself, MyNatives);
|
sharesys->AddNatives(myself, MyNatives);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Outputinfo::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
|
|
||||||
{
|
|
||||||
gpGlobals = ismm->GetCGlobals();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
@ -91,7 +91,7 @@ public:
|
|||||||
* @param late Whether or not Metamod considers this a late load.
|
* @param late Whether or not Metamod considers this a late load.
|
||||||
* @return True to succeed, false to fail.
|
* @return True to succeed, false to fail.
|
||||||
*/
|
*/
|
||||||
virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
|
//virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called when Metamod is detaching, after the extension version is called.
|
* @brief Called when Metamod is detaching, after the extension version is called.
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
#endif
|
#endif
|
||||||
#define _OutputInfo_Included
|
#define _OutputInfo_Included
|
||||||
|
|
||||||
native GetOutputCount(int Entity, const char[] sOutput);
|
native int GetOutputCount(int Entity, const char[] sOutput);
|
||||||
native GetOutputTarget(int Entity, const char[] sOutput, int Index, char[] sTarget);
|
native int GetOutputTarget(int Entity, const char[] sOutput, int Index, char[] sTarget);
|
||||||
native GetOutputTargetInput(int Entity, const char[] sOutput, int Index, char[] sTargetInput);
|
native int GetOutputTargetInput(int Entity, const char[] sOutput, int Index, char[] sTargetInput);
|
||||||
native GetOutputParameter(int Entity, const char[] sOutput, int Index, char[] sParameter);
|
native int GetOutputParameter(int Entity, const char[] sOutput, int Index, char[] sParameter);
|
||||||
native Float:GetOutputDelay(int Entity, const char[] sOutput, int Index);
|
native float GetOutputDelay(int Entity, const char[] sOutput, int Index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not edit below this line!
|
* Do not edit below this line!
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
* @brief Sets whether or not this plugin required Metamod.
|
* @brief Sets whether or not this plugin required Metamod.
|
||||||
* NOTE: Uncomment to enable, comment to disable.
|
* NOTE: Uncomment to enable, comment to disable.
|
||||||
*/
|
*/
|
||||||
#define SMEXT_CONF_METAMOD
|
//#define SMEXT_CONF_METAMOD
|
||||||
|
|
||||||
/** Enable interfaces you want to use here by uncommenting lines */
|
/** Enable interfaces you want to use here by uncommenting lines */
|
||||||
//#define SMEXT_ENABLE_FORWARDSYS
|
//#define SMEXT_ENABLE_FORWARDSYS
|
||||||
|
Loading…
Reference in New Issue
Block a user