add ButtonPresser
This commit is contained in:
parent
eff1e370e2
commit
70785fbd38
78
ButtonPresser/scripting/ButtonPresser.sp
Normal file
78
ButtonPresser/scripting/ButtonPresser.sp
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
#include <sourcemod>
|
||||||
|
#include <sdkhooks>
|
||||||
|
#include <sdktools>
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
public Plugin:myinfo =
|
||||||
|
{
|
||||||
|
name = "Button Presser",
|
||||||
|
description = "Notify admins when buttons are pressed",
|
||||||
|
author = "zaCade (lost the original source btw)",
|
||||||
|
version = "1.0",
|
||||||
|
url = ""
|
||||||
|
};
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
public void OnPluginStart()
|
||||||
|
{
|
||||||
|
int iEntity = INVALID_ENT_REFERENCE;
|
||||||
|
|
||||||
|
while ((iEntity = FindEntityByClassname(iEntity, "*")) != INVALID_ENT_REFERENCE)
|
||||||
|
{
|
||||||
|
OnEntityCreated(iEntity, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
public void OnEntityCreated(int iEntity, const char[] sClassname)
|
||||||
|
{
|
||||||
|
if (!IsValidEdict(iEntity))
|
||||||
|
return;
|
||||||
|
|
||||||
|
char sClassname2[64];
|
||||||
|
GetEdictClassname(iEntity, sClassname2, sizeof(sClassname2))
|
||||||
|
|
||||||
|
if (StrEqual(sClassname2, "func_button") || StrEqual(sClassname2, "func_rot_button"))
|
||||||
|
SDKHook(iEntity, SDKHook_Use, OnPressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
public Action OnPressed(int iEntity, int iActivator, int iCaller, UseType type, float fValue)
|
||||||
|
{
|
||||||
|
if (IsValidClient(iActivator))
|
||||||
|
{
|
||||||
|
char sSteamID[32];
|
||||||
|
if (!GetClientAuthId(iActivator, AuthId_Steam2, sSteamID, sizeof(sSteamID)))
|
||||||
|
{
|
||||||
|
sSteamID = "UNKNOWN";
|
||||||
|
}
|
||||||
|
char sTargetname[128];
|
||||||
|
GetEntPropString(iEntity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname));
|
||||||
|
|
||||||
|
for(int i = 1; i <= MaxClients; i++)
|
||||||
|
{
|
||||||
|
if(IsValidClient(i) && CheckCommandAccess(i, "", ADMFLAG_GENERIC))
|
||||||
|
PrintToConsole(i, "%N (%s) Pressed button: %s", iActivator, sSteamID, sTargetname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
stock int IsValidClient(int client, bool nobots = true)
|
||||||
|
{
|
||||||
|
if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return IsClientInGame(client);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user