added @aim target to sdktools
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401634
This commit is contained in:
parent
b4896ecada
commit
b1aa7a1ed2
@ -108,6 +108,8 @@ bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SDKTools::LevelInit, true);
|
SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SDKTools::LevelInit, true);
|
||||||
SH_ADD_HOOK_MEMFUNC(IServerGameDLL, ServerActivate, gamedll, this, &SDKTools::OnServerActivate, false);
|
SH_ADD_HOOK_MEMFUNC(IServerGameDLL, ServerActivate, gamedll, this, &SDKTools::OnServerActivate, false);
|
||||||
|
|
||||||
|
playerhelpers->RegisterCommandTargetProcessor(this);
|
||||||
|
|
||||||
MathLib_Init(2.2f, 2.2f, 0.0f, 2);
|
MathLib_Init(2.2f, 2.2f, 0.0f, 2);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -119,7 +121,9 @@ void SDKTools::OnHandleDestroy(HandleType_t type, void *object)
|
|||||||
{
|
{
|
||||||
ValveCall *v = (ValveCall *)object;
|
ValveCall *v = (ValveCall *)object;
|
||||||
delete v;
|
delete v;
|
||||||
} else if (type == g_TraceHandle) {
|
}
|
||||||
|
else if (type == g_TraceHandle)
|
||||||
|
{
|
||||||
trace_t *tr = (trace_t *)object;
|
trace_t *tr = (trace_t *)object;
|
||||||
delete tr;
|
delete tr;
|
||||||
}
|
}
|
||||||
@ -148,6 +152,7 @@ void SDKTools::SDK_OnUnload()
|
|||||||
|
|
||||||
gameconfs->CloseGameConfigFile(g_pGameConf);
|
gameconfs->CloseGameConfigFile(g_pGameConf);
|
||||||
playerhelpers->RemoveClientListener(&g_SdkTools);
|
playerhelpers->RemoveClientListener(&g_SdkTools);
|
||||||
|
playerhelpers->UnregisterCommandTargetProcessor(this);
|
||||||
|
|
||||||
SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SDKTools::LevelInit, true);
|
SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SDKTools::LevelInit, true);
|
||||||
SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, ServerActivate, gamedll, this, &SDKTools::OnServerActivate, false);
|
SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, ServerActivate, gamedll, this, &SDKTools::OnServerActivate, false);
|
||||||
@ -250,3 +255,30 @@ bool SDKTools::LevelInit(char const *pMapName, char const *pMapEntities, char co
|
|||||||
|
|
||||||
RETURN_META_VALUE(MRES_IGNORED, true);
|
RETURN_META_VALUE(MRES_IGNORED, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SDKTools::ProcessCommandTarget(cmd_target_info_t *info)
|
||||||
|
{
|
||||||
|
IGamePlayer *pAdmin = info->admin ? playerhelpers->GetGamePlayer(info->admin) : NULL;
|
||||||
|
|
||||||
|
/* The server can't aim, of course. */
|
||||||
|
if (pAdmin == NULL)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int player_index;
|
||||||
|
if ((player_index = GetClientAimTarget(pAdmin->GetEdict(), true)) < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
IGamePlayer *pTarget = playerhelpers->GetGamePlayer(info->admin);
|
||||||
|
|
||||||
|
info->targets[0] = player_index;
|
||||||
|
info->num_targets = 1;
|
||||||
|
info->reason = COMMAND_TARGET_VALID;
|
||||||
|
info->target_name_style = COMMAND_TARGETNAME_RAW;
|
||||||
|
snprintf(info->target_name, info->target_name_maxlength, "%s", pTarget->GetName());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -56,7 +56,8 @@ class SDKTools :
|
|||||||
public SDKExtension,
|
public SDKExtension,
|
||||||
public IHandleTypeDispatch,
|
public IHandleTypeDispatch,
|
||||||
public IConCommandBaseAccessor,
|
public IConCommandBaseAccessor,
|
||||||
public IClientListener
|
public IClientListener,
|
||||||
|
public ICommandTargetProcessor
|
||||||
{
|
{
|
||||||
public: //public IHandleTypeDispatch
|
public: //public IHandleTypeDispatch
|
||||||
void OnHandleDestroy(HandleType_t type, void *object);
|
void OnHandleDestroy(HandleType_t type, void *object);
|
||||||
@ -80,6 +81,8 @@ public: //IClientListner
|
|||||||
void OnClientDisconnecting(int client);
|
void OnClientDisconnecting(int client);
|
||||||
public: // IVoiceServer
|
public: // IVoiceServer
|
||||||
bool OnSetClientListening(int iReceiver, int iSender, bool bListen);
|
bool OnSetClientListening(int iReceiver, int iSender, bool bListen);
|
||||||
|
public: //ICommandTargetProcessor
|
||||||
|
bool ProcessCommandTarget(cmd_target_info_t *info);
|
||||||
public:
|
public:
|
||||||
bool LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background);
|
bool LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background);
|
||||||
void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
|
void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
|
||||||
|
@ -36,6 +36,24 @@ CallHelper s_Teleport;
|
|||||||
CallHelper s_GetVelocity;
|
CallHelper s_GetVelocity;
|
||||||
CallHelper s_EyeAngles;
|
CallHelper s_EyeAngles;
|
||||||
|
|
||||||
|
class CTraceFilterSimple : public CTraceFilterEntitiesOnly
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CTraceFilterSimple(const IHandleEntity *passentity): m_pPassEnt(passentity)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual bool ShouldHitEntity(IHandleEntity *pServerEntity, int contentsMask)
|
||||||
|
{
|
||||||
|
if (pServerEntity == m_pPassEnt)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
const IHandleEntity *m_pPassEnt;
|
||||||
|
};
|
||||||
|
|
||||||
bool SetupTeleport()
|
bool SetupTeleport()
|
||||||
{
|
{
|
||||||
if (s_Teleport.setup)
|
if (s_Teleport.setup)
|
||||||
@ -185,6 +203,65 @@ bool GetEyeAngles(CBaseEntity *pEntity, QAngle *pAngles)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GetClientAimTarget(edict_t *pEdict, bool only_players)
|
||||||
|
{
|
||||||
|
CBaseEntity *pEntity = pEdict->GetUnknown() ? pEdict->GetUnknown()->GetBaseEntity() : NULL;
|
||||||
|
|
||||||
|
if (pEntity == NULL)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector eye_position;
|
||||||
|
QAngle eye_angles;
|
||||||
|
|
||||||
|
/* Get the private information we need */
|
||||||
|
serverClients->ClientEarPosition(pEdict, &eye_position);
|
||||||
|
if (!GetEyeAngles(pEntity, &eye_angles))
|
||||||
|
{
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector aim_dir;
|
||||||
|
AngleVectors(eye_angles, &aim_dir);
|
||||||
|
VectorNormalize(aim_dir);
|
||||||
|
|
||||||
|
Vector vec_end = eye_position + aim_dir * 8000;
|
||||||
|
|
||||||
|
Ray_t ray;
|
||||||
|
ray.Init(eye_position, vec_end);
|
||||||
|
|
||||||
|
trace_t tr;
|
||||||
|
CTraceFilterSimple simple(pEdict->GetIServerEntity());
|
||||||
|
|
||||||
|
enginetrace->TraceRay(ray, MASK_SOLID|CONTENTS_DEBRIS|CONTENTS_HITBOX, &simple, &tr);
|
||||||
|
|
||||||
|
if (tr.fraction == 1.0f || tr.m_pEnt == NULL)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
edict_t *pTarget = gameents->BaseEntityToEdict(tr.m_pEnt);
|
||||||
|
if (pTarget == NULL)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ent_index = engine->IndexOfEdict(pTarget);
|
||||||
|
|
||||||
|
IGamePlayer *pTargetPlayer = playerhelpers->GetGamePlayer(ent_index);
|
||||||
|
if (pTargetPlayer != NULL && !pTargetPlayer->IsInGame())
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if (only_players && pTargetPlayer == NULL)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ent_index;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsEyeAnglesSupported()
|
bool IsEyeAnglesSupported()
|
||||||
{
|
{
|
||||||
return SetupGetEyeAngles();
|
return SetupGetEyeAngles();
|
||||||
|
@ -66,6 +66,8 @@ bool IsGetVelocitySupported();
|
|||||||
bool GetEyeAngles(CBaseEntity *pEntity, QAngle *pAngles);
|
bool GetEyeAngles(CBaseEntity *pEntity, QAngle *pAngles);
|
||||||
bool IsEyeAnglesSupported();
|
bool IsEyeAnglesSupported();
|
||||||
|
|
||||||
|
int GetClientAimTarget(edict_t *pEdict, bool only_players);
|
||||||
|
|
||||||
void ShutdownHelpers();
|
void ShutdownHelpers();
|
||||||
|
|
||||||
#endif //_INCLUDE_SDKTOOLS_VHELPERS_H_
|
#endif //_INCLUDE_SDKTOOLS_VHELPERS_H_
|
||||||
|
@ -113,24 +113,6 @@ bool CreateBaseCall(const char *name,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CTraceFilterSimple : public CTraceFilterEntitiesOnly
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CTraceFilterSimple(const IHandleEntity *passentity): m_pPassEnt(passentity)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
virtual bool ShouldHitEntity(IHandleEntity *pServerEntity, int contentsMask)
|
|
||||||
{
|
|
||||||
if (pServerEntity == m_pPassEnt)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
const IHandleEntity *m_pPassEnt;
|
|
||||||
};
|
|
||||||
|
|
||||||
static cell_t RemovePlayerItem(IPluginContext *pContext, const cell_t *params)
|
static cell_t RemovePlayerItem(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
static ValveCall *pCall = NULL;
|
static ValveCall *pCall = NULL;
|
||||||
@ -803,7 +785,7 @@ static cell_t DispatchKeyValueVector(IPluginContext *pContext, const cell_t *par
|
|||||||
return (ret) ? 1 : 0;
|
return (ret) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell_t GetClientAimTarget(IPluginContext *pContext, const cell_t *params)
|
static cell_t sm_GetClientAimTarget(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
int client = params[1];
|
int client = params[1];
|
||||||
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
|
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
|
||||||
@ -817,62 +799,7 @@ static cell_t GetClientAimTarget(IPluginContext *pContext, const cell_t *params)
|
|||||||
return pContext->ThrowNativeError("Client %d is not in game", client);
|
return pContext->ThrowNativeError("Client %d is not in game", client);
|
||||||
}
|
}
|
||||||
|
|
||||||
edict_t *pEdict = pPlayer->GetEdict();
|
return GetClientAimTarget(pPlayer->GetEdict(), params[2] ? true : false);
|
||||||
CBaseEntity *pEntity = pEdict->GetUnknown() ? pEdict->GetUnknown()->GetBaseEntity() : NULL;
|
|
||||||
|
|
||||||
if (pEntity == NULL)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector eye_position;
|
|
||||||
QAngle eye_angles;
|
|
||||||
|
|
||||||
/* Get the private information we need */
|
|
||||||
serverClients->ClientEarPosition(pEdict, &eye_position);
|
|
||||||
if (!GetEyeAngles(pEntity, &eye_angles))
|
|
||||||
{
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector aim_dir;
|
|
||||||
AngleVectors(eye_angles, &aim_dir);
|
|
||||||
VectorNormalize(aim_dir);
|
|
||||||
|
|
||||||
Vector vec_end = eye_position + aim_dir * 8000;
|
|
||||||
|
|
||||||
Ray_t ray;
|
|
||||||
ray.Init(eye_position, vec_end);
|
|
||||||
|
|
||||||
trace_t tr;
|
|
||||||
CTraceFilterSimple simple(pEdict->GetIServerEntity());
|
|
||||||
|
|
||||||
enginetrace->TraceRay(ray, MASK_SOLID|CONTENTS_DEBRIS|CONTENTS_HITBOX, &simple, &tr);
|
|
||||||
|
|
||||||
if (tr.fraction == 1.0f || tr.m_pEnt == NULL)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
edict_t *pTarget = gameents->BaseEntityToEdict(tr.m_pEnt);
|
|
||||||
if (pTarget == NULL)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ent_index = engine->IndexOfEdict(pTarget);
|
|
||||||
|
|
||||||
IGamePlayer *pTargetPlayer = playerhelpers->GetGamePlayer(ent_index);
|
|
||||||
if (pTargetPlayer != NULL && !pTargetPlayer->IsInGame())
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (params[2] && pTargetPlayer == NULL)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ent_index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sp_nativeinfo_t g_Natives[] =
|
sp_nativeinfo_t g_Natives[] =
|
||||||
@ -898,6 +825,6 @@ sp_nativeinfo_t g_Natives[] =
|
|||||||
{"DispatchKeyValue", DispatchKeyValue},
|
{"DispatchKeyValue", DispatchKeyValue},
|
||||||
{"DispatchKeyValueFloat", DispatchKeyValueFloat},
|
{"DispatchKeyValueFloat", DispatchKeyValueFloat},
|
||||||
{"DispatchKeyValueVector", DispatchKeyValueVector},
|
{"DispatchKeyValueVector", DispatchKeyValueVector},
|
||||||
{"GetClientAimTarget", GetClientAimTarget},
|
{"GetClientAimTarget", sm_GetClientAimTarget},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
@ -1,59 +1,5 @@
|
|||||||
"Phrases"
|
"Phrases"
|
||||||
{
|
{
|
||||||
"Already Muted"
|
|
||||||
{
|
|
||||||
"en" "Target player is already muted."
|
|
||||||
}
|
|
||||||
|
|
||||||
"Player Muted"
|
|
||||||
{
|
|
||||||
"#format" "{1:s}"
|
|
||||||
"en" "{1} has been muted."
|
|
||||||
}
|
|
||||||
|
|
||||||
"Player Not Muted"
|
|
||||||
{
|
|
||||||
"en" "Target player is not muted."
|
|
||||||
}
|
|
||||||
|
|
||||||
"Player Unmuted"
|
|
||||||
{
|
|
||||||
"#format" "{1:s}"
|
|
||||||
"en" "{1} has been unmuted."
|
|
||||||
}
|
|
||||||
|
|
||||||
"Already Gagged"
|
|
||||||
{
|
|
||||||
"en" "Target player is already gagged."
|
|
||||||
}
|
|
||||||
|
|
||||||
"Player Gagged"
|
|
||||||
{
|
|
||||||
"#format" "{1:s}"
|
|
||||||
"en" "{1} has been gagged."
|
|
||||||
}
|
|
||||||
|
|
||||||
"Player Not Gagged"
|
|
||||||
{
|
|
||||||
"en" "Target player is not gagged."
|
|
||||||
}
|
|
||||||
|
|
||||||
"Player Ungagged"
|
|
||||||
{
|
|
||||||
"#format" "{1:s}"
|
|
||||||
"en" "{1} has been ungagged."
|
|
||||||
}
|
|
||||||
|
|
||||||
"Already Silenced"
|
|
||||||
{
|
|
||||||
"en" "Target player is already silenced."
|
|
||||||
}
|
|
||||||
|
|
||||||
"Player Not Silenced"
|
|
||||||
{
|
|
||||||
"en" "Target player is not silenced."
|
|
||||||
}
|
|
||||||
|
|
||||||
"Gag/Mute player"
|
"Gag/Mute player"
|
||||||
{
|
{
|
||||||
"en" "Gag/Mute player"
|
"en" "Gag/Mute player"
|
||||||
@ -63,4 +9,40 @@
|
|||||||
{
|
{
|
||||||
"en" "Choose Type"
|
"en" "Choose Type"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
"Gagged target"
|
||||||
|
{
|
||||||
|
"#format" "{1:t}"
|
||||||
|
"en" "Gagged {1}."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Ungagged target"
|
||||||
|
{
|
||||||
|
"#format" "{1:t}"
|
||||||
|
"en" "Ungagged {1}."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Muted target"
|
||||||
|
{
|
||||||
|
"#format" "{1:t}"
|
||||||
|
"en" "Muted {1}."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Unmuted target"
|
||||||
|
{
|
||||||
|
"#format" "{1:t}"
|
||||||
|
"en" "Unmuted {1}."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Silenced target"
|
||||||
|
{
|
||||||
|
"#format" "{1:t}"
|
||||||
|
"en" "Silenced {1}."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Unsilenced target"
|
||||||
|
{
|
||||||
|
"#format" "{1:t}"
|
||||||
|
"en" "Unsilenced {1}."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user