ForceInputs: Added support for wildcards and refactor to new syntax
This commit is contained in:
parent
2dea599894
commit
199e46a937
@ -1,29 +1,32 @@
|
|||||||
//====================================================================================================
|
//====================================================================================================
|
||||||
//
|
//
|
||||||
// Name: ForceInput
|
// Name: ForceInput
|
||||||
// Author: zaCade
|
// Author: zaCade + BotoX
|
||||||
// Description: Allows admins to force inputs on entities. (ent_fire)
|
// Description: Allows admins to force inputs on entities. (ent_fire)
|
||||||
//
|
//
|
||||||
//====================================================================================================
|
//====================================================================================================
|
||||||
#include <sourcemod>
|
#include <sourcemod>
|
||||||
#include <sdktools>
|
#include <sdktools>
|
||||||
|
|
||||||
|
#pragma semicolon 1
|
||||||
|
#pragma newdecls required
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public Plugin:myinfo =
|
public Plugin myinfo =
|
||||||
{
|
{
|
||||||
name = "ForceInput",
|
name = "ForceInput",
|
||||||
author = "zaCade + BotoX",
|
author = "zaCade + BotoX",
|
||||||
description = "Allows admins to force inputs on entities. (ent_fire)",
|
description = "Allows admins to force inputs on entities. (ent_fire)",
|
||||||
version = "1.3",
|
version = "2.1",
|
||||||
url = ""
|
url = ""
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public OnPluginStart()
|
public void OnPluginStart()
|
||||||
{
|
{
|
||||||
LoadTranslations("common.phrases");
|
LoadTranslations("common.phrases");
|
||||||
|
|
||||||
@ -34,42 +37,44 @@ public OnPluginStart()
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public Action:Command_ForceInputPlayer(client, args)
|
public Action Command_ForceInputPlayer(int client, int args)
|
||||||
{
|
{
|
||||||
if (GetCmdArgs() < 2)
|
if(GetCmdArgs() < 2)
|
||||||
{
|
{
|
||||||
ReplyToCommand(client, "[SM] Usage: sm_forceinputplayer <target> <input> [parameter]");
|
ReplyToCommand(client, "[SM] Usage: sm_forceinputplayer <target> <input> [parameter]");
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
new String:sArguments[3][256];
|
char sArguments[3][256];
|
||||||
GetCmdArg(1, sArguments[0], sizeof(sArguments[]));
|
GetCmdArg(1, sArguments[0], sizeof(sArguments[]));
|
||||||
GetCmdArg(2, sArguments[1], sizeof(sArguments[]));
|
GetCmdArg(2, sArguments[1], sizeof(sArguments[]));
|
||||||
GetCmdArg(3, sArguments[2], sizeof(sArguments[]));
|
GetCmdArg(3, sArguments[2], sizeof(sArguments[]));
|
||||||
|
|
||||||
decl String:target_name[MAX_TARGET_LENGTH];
|
char sTargetName[MAX_TARGET_LENGTH];
|
||||||
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
|
int aTargetList[MAXPLAYERS];
|
||||||
|
int TargetCount;
|
||||||
|
bool TnIsMl;
|
||||||
|
|
||||||
if((target_count = ProcessTargetString(
|
if((TargetCount = ProcessTargetString(
|
||||||
sArguments[0],
|
sArguments[0],
|
||||||
client,
|
client,
|
||||||
target_list,
|
aTargetList,
|
||||||
MAXPLAYERS,
|
MAXPLAYERS,
|
||||||
0,
|
COMMAND_FILTER_CONNECTED|COMMAND_FILTER_NO_IMMUNITY,
|
||||||
target_name,
|
sTargetName,
|
||||||
sizeof(target_name),
|
sizeof(sTargetName),
|
||||||
tn_is_ml)) <= 0)
|
TnIsMl)) <= 0)
|
||||||
{
|
{
|
||||||
ReplyToTargetError(client, target_count);
|
ReplyToTargetError(client, TargetCount);
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(new i = 0; i < target_count; i++)
|
for(int i = 0; i < TargetCount; i++)
|
||||||
{
|
{
|
||||||
if (sArguments[2][0])
|
if (sArguments[2][0])
|
||||||
SetVariantString(sArguments[2]);
|
SetVariantString(sArguments[2]);
|
||||||
|
|
||||||
AcceptEntityInput(target_list[i], sArguments[1], target_list[i], target_list[i]);
|
AcceptEntityInput(aTargetList[i], sArguments[1], aTargetList[i], aTargetList[i]);
|
||||||
ReplyToCommand(client, "[SM] Input succesfull.");
|
ReplyToCommand(client, "[SM] Input succesfull.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,40 +84,64 @@ public Action:Command_ForceInputPlayer(client, args)
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public Action:Command_ForceInput(client, args)
|
public Action Command_ForceInput(int client, int args)
|
||||||
{
|
{
|
||||||
if (GetCmdArgs() < 2)
|
if(GetCmdArgs() < 2)
|
||||||
{
|
{
|
||||||
ReplyToCommand(client, "[SM] Usage: sm_forceinput <classname/targetname> <input> [parameter]");
|
ReplyToCommand(client, "[SM] Usage: sm_forceinput <classname/targetname> <input> [parameter]");
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
new String:sArguments[3][256];
|
char sArguments[3][256];
|
||||||
GetCmdArg(1, sArguments[0], sizeof(sArguments[]));
|
GetCmdArg(1, sArguments[0], sizeof(sArguments[]));
|
||||||
GetCmdArg(2, sArguments[1], sizeof(sArguments[]));
|
GetCmdArg(2, sArguments[1], sizeof(sArguments[]));
|
||||||
GetCmdArg(3, sArguments[2], sizeof(sArguments[]));
|
GetCmdArg(3, sArguments[2], sizeof(sArguments[]));
|
||||||
|
|
||||||
if (StrEqual(sArguments[0], "!self"))
|
if(StrEqual(sArguments[0], "!self"))
|
||||||
{
|
{
|
||||||
if (sArguments[2][0])
|
if(sArguments[2][0])
|
||||||
SetVariantString(sArguments[2]);
|
SetVariantString(sArguments[2]);
|
||||||
|
|
||||||
AcceptEntityInput(client, sArguments[1], client, client);
|
AcceptEntityInput(client, sArguments[1], client, client);
|
||||||
ReplyToCommand(client, "[SM] Input succesfull.");
|
ReplyToCommand(client, "[SM] Input succesfull.");
|
||||||
}
|
}
|
||||||
else if (StrEqual(sArguments[0], "!target"))
|
else if(StrEqual(sArguments[0], "!target"))
|
||||||
{
|
{
|
||||||
new entity = INVALID_ENT_REFERENCE;
|
float fPosition[3];
|
||||||
|
float fAngles[3];
|
||||||
new Float:fPosition[3], Float:fAngles[3];
|
|
||||||
GetClientEyePosition(client, fPosition);
|
GetClientEyePosition(client, fPosition);
|
||||||
GetClientEyeAngles(client, fAngles);
|
GetClientEyeAngles(client, fAngles);
|
||||||
|
|
||||||
new Handle:hTrace = TR_TraceRayFilterEx(fPosition, fAngles, MASK_SOLID, RayType_Infinite, TraceRayFilter, client);
|
Handle hTrace = TR_TraceRayFilterEx(fPosition, fAngles, MASK_SOLID, RayType_Infinite, TraceRayFilter, client);
|
||||||
|
|
||||||
if (TR_DidHit(hTrace) && ((entity = TR_GetEntityIndex(hTrace)) >= 1))
|
if(TR_DidHit(hTrace))
|
||||||
{
|
{
|
||||||
if (IsValidEntity(entity) || IsValidEdict(entity))
|
int entity = TR_GetEntityIndex(hTrace);
|
||||||
|
|
||||||
|
if(entity <= 1 || !IsValidEntity(entity))
|
||||||
|
return Plugin_Handled;
|
||||||
|
|
||||||
|
if(sArguments[2][0])
|
||||||
|
SetVariantString(sArguments[2]);
|
||||||
|
|
||||||
|
AcceptEntityInput(entity, sArguments[1], client, client);
|
||||||
|
ReplyToCommand(client, "[SM] Input succesfull.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int Wildcard = FindCharInString(sArguments[0], '*');
|
||||||
|
|
||||||
|
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, sArguments[0], Wildcard, false) == 0
|
||||||
|
|| strncmp(sTargetname, sArguments[0], Wildcard, false) == 0)
|
||||||
{
|
{
|
||||||
if (sArguments[2][0])
|
if (sArguments[2][0])
|
||||||
SetVariantString(sArguments[2]);
|
SetVariantString(sArguments[2]);
|
||||||
@ -122,38 +151,16 @@ public Action:Command_ForceInput(client, args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
new entity = INVALID_ENT_REFERENCE;
|
|
||||||
|
|
||||||
while ((entity = FindEntityByClassname(entity, "*")) != INVALID_ENT_REFERENCE)
|
|
||||||
{
|
|
||||||
if (IsValidEntity(entity) || IsValidEdict(entity))
|
|
||||||
{
|
|
||||||
new String:sClassname[64], String:sTargetname[64];
|
|
||||||
GetEntPropString(entity, Prop_Data, "m_iClassname", sClassname, sizeof(sClassname));
|
|
||||||
GetEntPropString(entity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname));
|
|
||||||
|
|
||||||
if (StrEqual(sClassname, sArguments[0], false) || StrEqual(sTargetname, sArguments[0], false))
|
|
||||||
{
|
|
||||||
if (sArguments[2][0])
|
|
||||||
SetVariantString(sArguments[2]);
|
|
||||||
|
|
||||||
AcceptEntityInput(entity, sArguments[1], client, client);
|
|
||||||
ReplyToCommand(client, "[SM] Input succesfull.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public bool:TraceRayFilter(entity, mask, any:client)
|
public bool TraceRayFilter(int entity, int mask, any client)
|
||||||
{
|
{
|
||||||
if (entity == client)
|
if(entity == client)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user