Implemented IsPlayerAlive native.
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401245
This commit is contained in:
parent
0f410208de
commit
c611ba9ea5
@ -52,6 +52,7 @@ IBinTools *g_pBinTools = NULL;
|
|||||||
IGameConfig *g_pGameConf = NULL;
|
IGameConfig *g_pGameConf = NULL;
|
||||||
IGameHelpers *g_pGameHelpers = NULL;
|
IGameHelpers *g_pGameHelpers = NULL;
|
||||||
IServerGameClients *serverClients = NULL;
|
IServerGameClients *serverClients = NULL;
|
||||||
|
IPlayerInfoManager *playerinfomngr = NULL;
|
||||||
HandleType_t g_CallHandle = 0;
|
HandleType_t g_CallHandle = 0;
|
||||||
HandleType_t g_TraceHandle = 0;
|
HandleType_t g_TraceHandle = 0;
|
||||||
IVoiceServer *voiceserver = NULL;
|
IVoiceServer *voiceserver = NULL;
|
||||||
@ -132,6 +133,7 @@ bool SDKTools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool
|
|||||||
GET_V_IFACE_ANY(engineFactory, pluginhelpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS);
|
GET_V_IFACE_ANY(engineFactory, pluginhelpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS);
|
||||||
GET_V_IFACE_ANY(serverFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
|
GET_V_IFACE_ANY(serverFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
|
||||||
GET_V_IFACE_ANY(engineFactory, voiceserver, IVoiceServer, INTERFACEVERSION_VOICESERVER);
|
GET_V_IFACE_ANY(engineFactory, voiceserver, IVoiceServer, INTERFACEVERSION_VOICESERVER);
|
||||||
|
GET_V_IFACE_ANY(serverFactory, playerinfomngr, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include <IEngineTrace.h>
|
#include <IEngineTrace.h>
|
||||||
#include <IEngineSound.h>
|
#include <IEngineSound.h>
|
||||||
#include <ivoiceserver.h>
|
#include <ivoiceserver.h>
|
||||||
|
#include <iplayerinfo.h>
|
||||||
#include <convar.h>
|
#include <convar.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,6 +91,7 @@ extern INetworkStringTableContainer *netstringtables;
|
|||||||
extern IServerPluginHelpers *pluginhelpers;
|
extern IServerPluginHelpers *pluginhelpers;
|
||||||
extern IServerGameClients *serverClients;
|
extern IServerGameClients *serverClients;
|
||||||
extern IVoiceServer *voiceserver;
|
extern IVoiceServer *voiceserver;
|
||||||
|
extern IPlayerInfoManager *playerinfomngr;
|
||||||
/* Interfaces from SourceMod */
|
/* Interfaces from SourceMod */
|
||||||
extern IBinTools *g_pBinTools;
|
extern IBinTools *g_pBinTools;
|
||||||
extern IGameConfig *g_pGameConf;
|
extern IGameConfig *g_pGameConf;
|
||||||
|
@ -564,6 +564,40 @@ static cell_t GetClientEyeAngles(IPluginContext *pContext, const cell_t *params)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t IsPlayerAlive(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
|
||||||
|
if (player == NULL)
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Invalid client index %d", params[1]);
|
||||||
|
} else if (!player->IsInGame())
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Client %d is not in game", params[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
edict_t *pEdict = player->GetEdict();
|
||||||
|
CBaseEntity *pEntity = pEdict->GetUnknown()->GetBaseEntity();
|
||||||
|
|
||||||
|
static int lifeState_off = 0;
|
||||||
|
static bool lifeState_setup = false;
|
||||||
|
|
||||||
|
if (!lifeState_setup)
|
||||||
|
{
|
||||||
|
lifeState_setup = true;
|
||||||
|
g_pGameConf->GetOffset("m_lifeState", &lifeState_off);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lifeState_off)
|
||||||
|
{
|
||||||
|
IPlayerInfo *info = playerinfomngr->GetPlayerInfo(pEdict);
|
||||||
|
if (info)
|
||||||
|
{
|
||||||
|
return info->IsDead() ? 0 : 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (*((uint8_t *)pEntity + lifeState_off) == LIFE_ALIVE) ? 1: 0;
|
||||||
|
}
|
||||||
|
|
||||||
sp_nativeinfo_t g_Natives[] =
|
sp_nativeinfo_t g_Natives[] =
|
||||||
{
|
{
|
||||||
{"ExtinguishPlayer", ExtinguishPlayer},
|
{"ExtinguishPlayer", ExtinguishPlayer},
|
||||||
@ -581,6 +615,6 @@ sp_nativeinfo_t g_Natives[] =
|
|||||||
{"SlapPlayer", SlapPlayer},
|
{"SlapPlayer", SlapPlayer},
|
||||||
{"GetClientEyePosition", GetClientEyePosition},
|
{"GetClientEyePosition", GetClientEyePosition},
|
||||||
{"GetClientEyeAngles", GetClientEyeAngles},
|
{"GetClientEyeAngles", GetClientEyeAngles},
|
||||||
|
{"IsPlayerAlive", IsPlayerAlive},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,6 +18,11 @@
|
|||||||
"class" "CBasePlayer"
|
"class" "CBasePlayer"
|
||||||
"prop" "m_iHealth"
|
"prop" "m_iHealth"
|
||||||
}
|
}
|
||||||
|
"m_lifeState"
|
||||||
|
{
|
||||||
|
"class" "CBasePlayer"
|
||||||
|
"prop" "m_lifeState"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,6 +114,15 @@ native SlapPlayer(client, health=5, bool:sound=true);
|
|||||||
*/
|
*/
|
||||||
native GetClientEyeAngles(client, Float:ang[3]);
|
native GetClientEyeAngles(client, Float:ang[3]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if the client is alive or dead.
|
||||||
|
*
|
||||||
|
* @param client Player's index.
|
||||||
|
* @return True if the client is dead, false otherwise.
|
||||||
|
* @error Invalid client index, client not in game, or no mod support.
|
||||||
|
*/
|
||||||
|
native bool:IsPlayerAlive(client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user