extensions/sdktools/vnatives.cpp
changeset 1240 79eebacc9d02
parent 1239 eed86aca8fae
child 1244 989675c02a03
     1.1 --- a/extensions/sdktools/vnatives.cpp	Wed Aug 01 06:55:55 2007 +0000
     1.2 +++ b/extensions/sdktools/vnatives.cpp	Wed Aug 01 07:18:58 2007 +0000
     1.3 @@ -36,6 +36,7 @@
     1.4  #include "vcallbuilder.h"
     1.5  #include "vnatives.h"
     1.6  #include "vhelpers.h"
     1.7 +#include "vglobals.h"
     1.8  #include "CellRecipientFilter.h"
     1.9  
    1.10  List<ValveCall *> g_RegCalls;
    1.11 @@ -212,7 +213,7 @@
    1.12  	return engine->IndexOfEdict(pEdict);
    1.13  }
    1.14  
    1.15 -static cell_t IgnitePlayer(IPluginContext *pContext, const cell_t *params)
    1.16 +static cell_t IgniteEntity(IPluginContext *pContext, const cell_t *params)
    1.17  {
    1.18  	static ValveCall *pCall = NULL;
    1.19  	if (!pCall)
    1.20 @@ -241,7 +242,7 @@
    1.21  	return 1;
    1.22  }
    1.23  
    1.24 -static cell_t ExtinguishPlayer(IPluginContext *pContext, const cell_t *params)
    1.25 +static cell_t ExtinguishEntity(IPluginContext *pContext, const cell_t *params)
    1.26  {
    1.27  	static ValveCall *pCall = NULL;
    1.28  	if (!pCall)
    1.29 @@ -261,7 +262,7 @@
    1.30  	return 1;
    1.31  }
    1.32  
    1.33 -static cell_t TeleportPlayer(IPluginContext *pContext, const cell_t *params)
    1.34 +static cell_t TeleportEntity(IPluginContext *pContext, const cell_t *params)
    1.35  {
    1.36  	static ValveCall *pCall = NULL;
    1.37  	if (!pCall)
    1.38 @@ -564,6 +565,44 @@
    1.39  	return 1;
    1.40  }
    1.41  
    1.42 +static cell_t FindEntityByClassname(IPluginContext *pContext, const cell_t *params)
    1.43 +{
    1.44 +	static ValveCall *pCall = NULL;
    1.45 +	if (!pCall)
    1.46 +	{
    1.47 +		ValvePassInfo pass[3];
    1.48 +		InitPass(pass[0], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL, VDECODE_FLAG_ALLOWNULL|VDECODE_FLAG_ALLOWWORLD);
    1.49 +		InitPass(pass[1], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
    1.50 +		InitPass(pass[2], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
    1.51 +		if (!CreateBaseCall("FindEntityByClassname", ValveCall_EntityList, &pass[2], pass, 2, &pCall))
    1.52 +		{
    1.53 +			return pContext->ThrowNativeError("\"FindEntityByClassname\" not supported by this mod");
    1.54 +		} else if (!pCall) {
    1.55 +			return pContext->ThrowNativeError("\"FindEntityByClassname\" wrapper failed to initialized");
    1.56 +		}
    1.57 +	}
    1.58 +
    1.59 +	CBaseEntity *pEntity;
    1.60 +	START_CALL();
    1.61 +	*(void **)vptr = g_EntList; 
    1.62 +	DECODE_VALVE_PARAM(1, vparams, 0);
    1.63 +	DECODE_VALVE_PARAM(2, vparams, 1);
    1.64 +	FINISH_CALL_SIMPLE(&pEntity);
    1.65 +
    1.66 +	if (pEntity == NULL)
    1.67 +	{
    1.68 +		return -1;
    1.69 +	}
    1.70 +
    1.71 +	edict_t *pEdict = gameents->BaseEntityToEdict(pEntity);
    1.72 +	if (!pEdict)
    1.73 +	{
    1.74 +		return -1;
    1.75 +	}
    1.76 +
    1.77 +	return engine->IndexOfEdict(pEdict);
    1.78 +}
    1.79 +
    1.80  static cell_t IsPlayerAlive(IPluginContext *pContext, const cell_t *params)
    1.81  {
    1.82  	IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
    1.83 @@ -600,21 +639,22 @@
    1.84  
    1.85  sp_nativeinfo_t g_Natives[] = 
    1.86  {
    1.87 -	{"ExtinguishPlayer",		ExtinguishPlayer},
    1.88 -	{"ExtinguishEntity",		ExtinguishPlayer},
    1.89 +	{"ExtinguishPlayer",		ExtinguishEntity},
    1.90 +	{"ExtinguishEntity",		ExtinguishEntity},
    1.91  	{"ForcePlayerSuicide",		ForcePlayerSuicide},
    1.92  	{"GivePlayerItem",			GiveNamedItem},
    1.93  	{"GetPlayerWeaponSlot",		GetPlayerWeaponSlot},
    1.94 -	{"IgnitePlayer",			IgnitePlayer},
    1.95 -	{"IgniteEntity",			IgnitePlayer},
    1.96 +	{"IgnitePlayer",			IgniteEntity},
    1.97 +	{"IgniteEntity",			IgniteEntity},
    1.98  	{"RemovePlayerItem",		RemovePlayerItem},
    1.99 -	{"TeleportPlayer",			TeleportPlayer},
   1.100 -	{"TeleportEntity",			TeleportPlayer},
   1.101 +	{"TeleportPlayer",			TeleportEntity},
   1.102 +	{"TeleportEntity",			TeleportEntity},
   1.103  	{"SetClientViewEntity",		SetClientViewEntity},
   1.104  	{"SetLightStyle",			SetLightStyle},
   1.105  	{"SlapPlayer",				SlapPlayer},
   1.106  	{"GetClientEyePosition",	GetClientEyePosition},
   1.107  	{"GetClientEyeAngles",		GetClientEyeAngles},
   1.108 +	{"FindEntityByClassname",	FindEntityByClassname},
   1.109  	{"IsPlayerAlive",			IsPlayerAlive},
   1.110  	{NULL,						NULL},
   1.111  };