Files
sm-plugins/Radio/scripting/Radio.sp
T
2026-10-22 16:17:56 +01:00

132 lines
3.4 KiB
SourcePawn

#pragma semicolon 1
#include <sourcemod>
#include <sdktools_sound>
#include <sdktools_stringtables>
#include <cstrike>
#include <clientprefs>
#undef REQUIRE_PLUGIN
#include <ccc>
#include <leader>
#include <zombiereloaded>
#define REQUIRE_PLUGIN
#pragma newdecls required
#define PLUGIN_VERSION "1.0"
ConVar g_cvEnabled;
ConVar g_cvCustom;
ConVar g_cvCooldown;
ConVar g_cvRoundLimit;
ConVar g_cvDead;
ConVar g_cvSound;
bool g_bCCC;
bool g_bLeader;
bool g_bZR;
float g_flNextRadio[MAXPLAYERS + 1];
int g_iRadioCount[MAXPLAYERS + 1];
public Plugin myinfo =
{
name = "Radio",
author = "marisakirisame.net",
description = "Stock CS:S radio reimplemented with custom-chatcolors styling",
version = PLUGIN_VERSION,
url = ""
};
public void OnPluginStart()
{
if (GetUserMessageType() == UM_Protobuf)
SetFailState("This plugin only supports bitbuffer usermessages (CS:S).");
if (GetUserMessageId("SendAudio") == INVALID_MESSAGE_ID || GetUserMessageId("SayText2") == INVALID_MESSAGE_ID)
SetFailState("SendAudio/SayText2 usermessages unavailable.");
g_cvEnabled = CreateConVar("sm_radio_enabled", "1", "Enable the custom radio handling (0 = fully stock behaviour)", _, true, 0.0, true, 1.0);
g_cvCustom = CreateConVar("sm_radio_custom", "1", "Enable the custom radio commands (thanks, cheer); 0 = stock radio set only", _, true, 0.0, true, 1.0);
g_cvCooldown = CreateConVar("sm_radio_cooldown", "1.5", "Seconds a player has to wait between radio messages", _, true, 0.0);
g_cvRoundLimit = CreateConVar("sm_radio_round_limit", "0", "Max radio messages per player per round (engine default = 60, 0 = unlimited)", _, true, 0.0);
g_cvDead = CreateConVar("sm_radio_dead", "0", "Allow dead players to use the radio", _, true, 0.0, true, 1.0);
g_cvSound = CreateConVar("sm_radio_sound", "1", "Play the radio voice line", _, true, 0.0, true, 1.0);
AutoExecConfig(true);
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
Commands_Init();
Grenade_Init();
Bans_Init();
Settings_Init();
}
bool Radio_IsLeader(int client)
{
// A zombified leader gets no [Leader] tag and no cooldown bypass.
if (g_bZR
&& GetFeatureStatus(FeatureType_Native, "ZR_IsClientZombie") == FeatureStatus_Available
&& ZR_IsClientZombie(client))
{
return false;
}
return g_bLeader
&& GetFeatureStatus(FeatureType_Native, "Leader_Is") == FeatureStatus_Available
&& Leader_Is(client);
}
public void OnAllPluginsLoaded()
{
g_bCCC = LibraryExists("ccc");
g_bLeader = LibraryExists("leader");
g_bZR = LibraryExists("zombiereloaded");
}
public void OnLibraryAdded(const char[] name)
{
if (StrEqual(name, "ccc"))
g_bCCC = true;
else if (StrEqual(name, "leader"))
g_bLeader = true;
else if (StrEqual(name, "zombiereloaded"))
g_bZR = true;
}
public void OnLibraryRemoved(const char[] name)
{
if (StrEqual(name, "ccc"))
g_bCCC = false;
else if (StrEqual(name, "leader"))
g_bLeader = false;
else if (StrEqual(name, "zombiereloaded"))
g_bZR = false;
}
public void OnMapStart()
{
Bans_Clear();
Commands_PrecacheSounds();
}
public void OnClientConnected(int client)
{
g_flNextRadio[client] = 0.0;
g_iRadioCount[client] = 0;
Settings_OnClientConnected(client);
}
public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
for (int i = 1; i <= MaxClients; i++)
g_iRadioCount[i] = 0;
}
#include "radio/commands.sp"
#include "radio/grenade.sp"
#include "radio/format.sp"
#include "radio/bans.sp"
#include "radio/settings.sp"