Add OutputInfo to ExtraCommands sm_waila / sm_info and make it also work with targetnames

This commit is contained in:
BotoX 2019-08-20 22:34:14 +02:00
parent de29190f36
commit 9f6327e615
2 changed files with 104 additions and 43 deletions

View File

@ -4,6 +4,7 @@
#include <sdktools>
#include <sdkhooks>
#include <cstrike>
#include <outputinfo>
#pragma newdecls required
@ -56,8 +57,8 @@ public void OnPluginStart()
RegAdminCmd("sm_setmvp", Command_SetMvp, ADMFLAG_GENERIC, "sm_setmvp <#userid|name> <value>");
RegAdminCmd("sm_setteamscore", Command_SetTeamScore, ADMFLAG_GENERIC, "sm_setteamscore <team> <value>");
RegAdminCmd("sm_restartround", Command_RestartRound, ADMFLAG_GENERIC, "sm_restartround <delay>");
RegAdminCmd("sm_waila", Command_WAILA, ADMFLAG_GENERIC);
RegAdminCmd("sm_info", Command_WAILA, ADMFLAG_GENERIC);
RegAdminCmd("sm_waila", Command_WAILA, ADMFLAG_GENERIC, "sm_waila [target]");
RegAdminCmd("sm_info", Command_WAILA, ADMFLAG_GENERIC, "sm_info [target]");
RegAdminCmd("sm_fcvar", Command_ForceCVar, ADMFLAG_CHEATS, "sm_fcvar <#userid|name> <cvar> <value>");
RegAdminCmd("sm_setclantag", Command_SetClanTag, ADMFLAG_CHEATS, "sm_setclantag <#userid|name> [text]");
RegAdminCmd("sm_fakecommand", Command_FakeCommand, ADMFLAG_CHEATS, "sm_fakecommand <#userid|name> [command] [args]");
@ -701,6 +702,15 @@ public Action Command_Respawn(int client, int argc)
GetCmdArg(1, sArgs, sizeof(sArgs));
bool bForce = false;
if(argc >= 2)
{
char sArgs2[8];
GetCmdArg(2, sArgs2, sizeof(sArgs2));
if(StringToInt(sArgs2))
bForce = true;
}
if((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, COMMAND_FILTER_DEAD, sTargetName, sizeof(sTargetName), bIsML)) <= 0)
{
ReplyToTargetError(client, iTargetCount);
@ -709,7 +719,7 @@ public Action Command_Respawn(int client, int argc)
for(int i = 0; i < iTargetCount; i++)
{
if(GetClientTeam(iTargets[i]) == CS_TEAM_SPECTATOR || GetClientTeam(iTargets[i]) == CS_TEAM_NONE)
if(!bForce && (GetClientTeam(iTargets[i]) == CS_TEAM_SPECTATOR || GetClientTeam(iTargets[i]) == CS_TEAM_NONE))
continue;
bDidRespawn = true;
@ -1134,63 +1144,111 @@ public Action Command_RestartRound(int client, int argc)
return Plugin_Handled;
}
public Action Command_WAILA(int client, int argc)
stock void WAILA(int client, int iEntity)
{
if(!client)
char sModelPath[PLATFORM_MAX_PATH];
char sClsName[64];
char sNetClsName[64];
char sTargetname[64];
int iEntityModelIdx = -1;
int iHammerID = -1;
GetEntPropString(iEntity, Prop_Data, "m_ModelName", sModelPath, sizeof(sModelPath));
GetEntityClassname(iEntity, sClsName, sizeof(sClsName));
GetEntityNetClass(iEntity, sNetClsName, sizeof(sNetClsName));
GetEntPropString(iEntity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname));
if(HasEntProp(iEntity, Prop_Send, "m_nModelIndex"))
iEntityModelIdx = GetEntProp(iEntity, Prop_Send, "m_nModelIndex");
if(HasEntProp(iEntity, Prop_Data, "m_iHammerID"))
iHammerID = GetEntProp(iEntity, Prop_Data, "m_iHammerID");
PrintToConsole(client, "Entity Index: %i\nHammer ID: %d\nTarget name: %s\nModel Path: %s\nModel Index: %i\nClass Name: %s\nNet Class Name: %s", iEntity, iHammerID, sTargetname, sModelPath, iEntityModelIdx, sClsName, sNetClsName);
char sOutputName[128];
for(int index = 0; ; index++)
{
PrintToServer("[SM] Cannot use command from server console.");
return Plugin_Handled;
sOutputName[0] = 0;
int len = GetOutputNames(iEntity, index, sOutputName, sizeof(sOutputName));
if(len < 0)
break;
int count = GetOutputCount(iEntity, sOutputName);
for(int i = 0; i < count; i++)
{
char sFormatted[1024];
GetOutputFormatted(iEntity, sOutputName, i, sFormatted, sizeof(sFormatted));
PrintToConsole(client, "%s: %s", sOutputName, sFormatted);
}
}
float vecEyeAngles[3];
float vecEyeOrigin[3];
PrintToConsole(client, "-----");
}
GetClientEyeAngles(client, vecEyeAngles);
GetClientEyePosition(client, vecEyeOrigin);
Handle hTraceRay = TR_TraceRayFilterEx(vecEyeOrigin, vecEyeAngles, MASK_ALL, RayType_Infinite, TraceEntityFilter_FilterCaller, client);
if(TR_DidHit(hTraceRay))
public Action Command_WAILA(int client, int argc)
{
if(argc < 1)
{
float vecEndPos[3];
char sModelPath[PLATFORM_MAX_PATH];
char sClsName[64];
char sNetClsName[64];
char sTargetname[64];
int iEntity;
int iEntityModelIdx;
int iHammerID;
TR_GetEndPosition(vecEndPos, hTraceRay);
if((iEntity = TR_GetEntityIndex(hTraceRay)) <= 0)
if(!client)
{
PrintToChat(client, "[SM] Trace hit the world.");
delete hTraceRay;
PrintToServer("[SM] Cannot use command from server console.");
return Plugin_Handled;
}
GetEntPropString(iEntity, Prop_Data, "m_ModelName", sModelPath, sizeof(sModelPath));
GetEntityClassname(iEntity, sClsName, sizeof(sClsName));
GetEntityNetClass(iEntity, sNetClsName, sizeof(sNetClsName));
GetEntPropString(iEntity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname));
iEntityModelIdx = GetEntProp(iEntity, Prop_Send, "m_nModelIndex");
iHammerID = GetEntProp(iEntity, Prop_Data, "m_iHammerID");
float vecEyeAngles[3];
float vecEyeOrigin[3];
PrintToConsole(client, "Entity Index: %i\nHammer ID: %d\nTarget name: %s\nModel Path: %s\nModel Index: %i\nClass Name: %s\nNet Class Name: %s", iEntity, iHammerID, sTargetname, sModelPath, iEntityModelIdx, sClsName, sNetClsName);
GetClientEyeAngles(client, vecEyeAngles);
GetClientEyePosition(client, vecEyeOrigin);
PrintToChat(client, "[SM] Trace hit something, check your console for more information.");
Handle hTraceRay = TR_TraceRayFilterEx(vecEyeOrigin, vecEyeAngles, MASK_ALL, RayType_Infinite, TraceEntityFilter_FilterCaller, client);
delete hTraceRay;
if(TR_DidHit(hTraceRay))
{
int iEntity;
float vecEndPos[3];
TR_GetEndPosition(vecEndPos, hTraceRay);
return Plugin_Handled;
if((iEntity = TR_GetEntityIndex(hTraceRay)) <= 0)
{
PrintToChat(client, "[SM] Trace hit the world.");
delete hTraceRay;
return Plugin_Handled;
}
PrintToChat(client, "[SM] Trace hit something, check your console for more information.");
WAILA(client, iEntity);
delete hTraceRay;
}
else
{
PrintToChat(client, "[SM] Couldn't find anything under your crosshair.");
return Plugin_Handled;
}
}
else
{
char sArgument[256];
GetCmdArg(1, sArgument, sizeof(sArgument));
delete hTraceRay;
int Wildcard = FindCharInString(sArgument, '*');
PrintToChat(client, "[SM] Couldn't find anything under your crosshair.");
int entity = INVALID_ENT_REFERENCE;
while((entity = FindEntityByClassname(entity, "*")) != INVALID_ENT_REFERENCE)
{
char sClassname[64];
char sTargetname[64];
GetEntPropString(entity, Prop_Data, "m_iClassname", sClassname, sizeof(sClassname));
GetEntPropString(entity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname));
if(strncmp(sClassname, sArgument, Wildcard, false) == 0
|| strncmp(sTargetname, sArgument, Wildcard, false) == 0)
{
WAILA(client, entity);
}
}
}
return Plugin_Handled;
}

View File

@ -28,6 +28,8 @@ native int FindOutput(int Entity, const char[] sOutput, int StartIndex,
native int DeleteOutput(int Entity, const char[] sOutput, int Index);
native int DeleteAllOutputs(int Entity, const char[] sOutput);
native int GetOutputNames(int Entity, int Index, const char[] sOutput, int MaxLen);
/**
* Do not edit below this line!
*/
@ -59,5 +61,6 @@ public __ext_outputinfo_SetNTVOptional()
MarkNativeAsOptional("FindOutput");
MarkNativeAsOptional("DeleteOutput");
MarkNativeAsOptional("DeleteAllOutputs");
MarkNativeAsOptional("GetOutputNames");
}
#endif