friendly fire randomizer
This commit is contained in:
parent
25cf6715d2
commit
0db25c708e
|
@ -0,0 +1,102 @@
|
|||
#include <sourcemod>
|
||||
#include <tf2>
|
||||
|
||||
#define TOGGLE_TIME 250.0
|
||||
#define MIN_FF_DURATION 120
|
||||
#define MAX_FF_DURATION 270
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "Toggle Friendly Fire",
|
||||
author = "Retard",
|
||||
description = "Toggles Friendly Fire On/Off at random moments.",
|
||||
version = "1.0",
|
||||
url = "https://deadzone.lol"
|
||||
};
|
||||
|
||||
Handle timerToggle = null;
|
||||
bool g_bFriendlyFire = false;
|
||||
bool g_bPluginEnabled = true;
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
RegConsoleCmd("sm_friendlyfire", CmdToggleFriendlyFire, "Toggle the Friendly Fire script. Admins with 'z' flag only.");
|
||||
StartToggleTimer();
|
||||
}
|
||||
|
||||
public Action CmdToggleFriendlyFire(int client, int args)
|
||||
{
|
||||
if (CheckCommandAccess(client, "sm_friendlyfire", ADMFLAG_ROOT))
|
||||
{
|
||||
g_bPluginEnabled = !g_bPluginEnabled
|
||||
|
||||
if (g_bPluginEnabled)
|
||||
{
|
||||
PrintToChat(client, "Friendly Fire script has been enabled!");
|
||||
StartToggleTimer();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_bFriendlyFire)
|
||||
{
|
||||
Handle hCvar = FindConVar("mp_friendlyfire");
|
||||
if (hCvar != INVALID_HANDLE)
|
||||
{
|
||||
SetConVarInt(hCvar, 0);
|
||||
}
|
||||
g_bFriendlyFire = false;
|
||||
PrintToChatAll("[DEBUG] Friendly Fire is now OFF");
|
||||
}
|
||||
|
||||
PrintToChat(client, "Friendly Fire script has been disabled!");
|
||||
|
||||
if (timerToggle != null)
|
||||
{
|
||||
KillTimer(timerToggle);
|
||||
timerToggle = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintToChat(client, "You do not have permission to use this command.");
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
void StartToggleTimer()
|
||||
{
|
||||
if (!g_bPluginEnabled)
|
||||
return;
|
||||
|
||||
if (timerToggle != null)
|
||||
KillTimer(timerToggle);
|
||||
|
||||
timerToggle = CreateTimer(TOGGLE_TIME, ToggleFriendlyFire);
|
||||
}
|
||||
|
||||
public Action ToggleFriendlyFire(Handle timer, any data)
|
||||
{
|
||||
g_bFriendlyFire = !g_bFriendlyFire;
|
||||
|
||||
Handle hCvar = FindConVar("mp_friendlyfire");
|
||||
if(hCvar == INVALID_HANDLE)
|
||||
{
|
||||
SetFailState("Failed to find 'mp_friendlyfire' cvar!");
|
||||
}
|
||||
SetConVarInt(hCvar, g_bFriendlyFire ? 1 : 0);
|
||||
|
||||
PrintToChatAll("[DEBUG] Friendly Fire is now %s", g_bFriendlyFire ? "ON" : "OFF");
|
||||
|
||||
StartToggleTimer();
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public void OnPluginEnd()
|
||||
{
|
||||
if(timerToggle != null)
|
||||
{
|
||||
KillTimer(timerToggle);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue