Just found a major error with L4D2 - will crash when the object to remove is a witch. Will need to debug.
Looks like it may be a conflict with another plugin - need more testing.
Rewrote logic to block attempt to remove witch.
Edit: I expect the following to be more succinct way of including the witch test but I could not write it compilably at 2AM. I will test this when I can and see.
Code:
#include <sourcemod>
#include <sdktools>
#define VERSION "1.0.2"
public Plugin:myinfo =
{
name = "Object Remover",
author = "Weld Inclusion",
description = "Removes an object where aimed.",
version = VERSION,
url = "http://forums.alliedmods.net/showthread.php?t=179911"
}
public OnPluginStart()
{
//Rewrite with CheckCommandAccess and CheckAccess to remove flag necessity
//Register the command for use
RegAdminCmd("sm_removeobject", Command_RemoveObject, ADMFLAG_ROOT, "Remove Object.");
}
public Action:Command_RemoveObject(client, args)
{
if(!client)
{
PrintToServer("Client is invalid");
return Plugin_Handled;
}
RemoveObject(client);
return Plugin_Handled;
}
public RemoveObject(client)
{
decl String:Target[128];
//Get the object where the client is looking
new object = GetClientAimTarget(client, false);
GetEdictClassname(object, Target, sizeof(Target));
if ((object == -1)||(!IsValidEntity(object))||(StrEqual(Target, "witch", false)))
{
ShowActivity2(client, "[SM] ", "%N tried to remove an invalid object.", client);
LogAction(client, -1, "%N tried to remove an invalid object.", client);
return;
}
else
{
//Check if the object is a client and show activity if so.
if (object > 0 && object <= GetMaxClients())
{
ShowActivity2(client, "[SM] ", "%N tried to remove %N", client, object);
LogAction(client, object, "%N tried to remove %N", client, object);
return;
}
ShowActivity2(client, "[SM] ", "%N removed %s", client, Target);
LogAction(client, object, "%N removed %s", client, Target);
AcceptEntityInput(object, "kill", -1, -1, -1);
}
}
I have been informed that the witch issue is likely not an issue with this plugin.
I have removed the witch check (back to 1.0.1).
__________________