extensions/sdktools/vnatives.cpp
changeset 1219 6f440a361fa7
parent 1171 b63f3c050744
child 1233 e9cfc03b9bb8
     1.1 --- a/extensions/sdktools/vnatives.cpp	Mon Jul 30 23:16:58 2007 +0000
     1.2 +++ b/extensions/sdktools/vnatives.cpp	Tue Jul 31 02:08:25 2007 +0000
     1.3 @@ -502,21 +502,76 @@
     1.4  	return 1;
     1.5  }
     1.6  
     1.7 +static cell_t GetClientEyePosition(IPluginContext *pContext, const cell_t *params)
     1.8 +{
     1.9 +	IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
    1.10 +	if (player == NULL)
    1.11 +	{
    1.12 +		return pContext->ThrowNativeError("Invalid client index %d", params[1]);
    1.13 +	}
    1.14 +	if (!player->IsInGame())
    1.15 +	{
    1.16 +		return pContext->ThrowNativeError("Client %d is not in game", params[1]);
    1.17 +	}
    1.18 +
    1.19 +	Vector pos;
    1.20 +	serverClients->ClientEarPosition(player->GetEdict(), &pos);
    1.21 +
    1.22 +	cell_t *addr;
    1.23 +	pContext->LocalToPhysAddr(params[2], &addr);
    1.24 +	addr[0] = sp_ftoc(pos.x);
    1.25 +	addr[1] = sp_ftoc(pos.y);
    1.26 +	addr[2] = sp_ftoc(pos.z);
    1.27 +
    1.28 +	return 1;
    1.29 +}
    1.30 +
    1.31 +static cell_t GetClientEyeAngles(IPluginContext *pContext, const cell_t *params)
    1.32 +{
    1.33 +	static ValveCall *pCall = NULL;
    1.34 +	if (!pCall)
    1.35 +	{
    1.36 +		ValvePassInfo retinfo[1];
    1.37 +		InitPass(retinfo[0], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
    1.38 +		if (!CreateBaseCall("EyeAngles", ValveCall_Player, retinfo, NULL, 0, &pCall))
    1.39 +		{
    1.40 +			return pContext->ThrowNativeError("\"EyeAngles\" not supported by this mod");
    1.41 +		} else if (!pCall) {
    1.42 +			return pContext->ThrowNativeError("\"EyeAngles\" wrapper failed to initialized");
    1.43 +		}
    1.44 +	}
    1.45 +
    1.46 +	QAngle *ang;
    1.47 +	START_CALL();
    1.48 +	DECODE_VALVE_PARAM(1, thisinfo, 0);
    1.49 +	FINISH_CALL_SIMPLE(&ang);
    1.50 +	
    1.51 +	cell_t *addr;
    1.52 +	pContext->LocalToPhysAddr(params[2], &addr);
    1.53 +	addr[0] = sp_ftoc(ang->x);
    1.54 +	addr[1] = sp_ftoc(ang->y);
    1.55 +	addr[2] = sp_ftoc(ang->z);
    1.56 +
    1.57 +	return 1;
    1.58 +}
    1.59 +
    1.60  sp_nativeinfo_t g_Natives[] = 
    1.61  {
    1.62 -	{"ExtinguishPlayer",	ExtinguishPlayer},
    1.63 -	{"ExtinguishEntity",	ExtinguishPlayer},
    1.64 -	{"ForcePlayerSuicide",	ForcePlayerSuicide},
    1.65 -	{"GivePlayerItem",		GiveNamedItem},
    1.66 -	{"GetPlayerWeaponSlot",	GetPlayerWeaponSlot},
    1.67 -	{"IgnitePlayer",		IgnitePlayer},
    1.68 -	{"IgniteEntity",		IgnitePlayer},
    1.69 -	{"RemovePlayerItem",	RemovePlayerItem},
    1.70 -	{"TeleportPlayer",		TeleportPlayer},
    1.71 -	{"TeleportEntity",		TeleportPlayer},
    1.72 -	{"SetClientViewEntity",	SetClientViewEntity},
    1.73 -	{"SetLightStyle",		SetLightStyle},
    1.74 -	{"SlapPlayer",			SlapPlayer},
    1.75 -	{NULL,					NULL},
    1.76 +	{"ExtinguishPlayer",		ExtinguishPlayer},
    1.77 +	{"ExtinguishEntity",		ExtinguishPlayer},
    1.78 +	{"ForcePlayerSuicide",		ForcePlayerSuicide},
    1.79 +	{"GivePlayerItem",			GiveNamedItem},
    1.80 +	{"GetPlayerWeaponSlot",		GetPlayerWeaponSlot},
    1.81 +	{"IgnitePlayer",			IgnitePlayer},
    1.82 +	{"IgniteEntity",			IgnitePlayer},
    1.83 +	{"RemovePlayerItem",		RemovePlayerItem},
    1.84 +	{"TeleportPlayer",			TeleportPlayer},
    1.85 +	{"TeleportEntity",			TeleportPlayer},
    1.86 +	{"SetClientViewEntity",		SetClientViewEntity},
    1.87 +	{"SetLightStyle",			SetLightStyle},
    1.88 +	{"SlapPlayer",				SlapPlayer},
    1.89 +	{"GetClientEyePosition",	GetClientEyePosition},
    1.90 +	{"GetClientEyeAngles",		GetClientEyeAngles},
    1.91 +	{NULL,						NULL},
    1.92  };
    1.93