Compare commits
1
Commits
master
..
8a083acb32
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a083acb32 |
@@ -21,16 +21,9 @@ Menu g_NpcMenu = null;
|
|||||||
KeyValues g_Models;
|
KeyValues g_Models;
|
||||||
|
|
||||||
ConVar g_cvNotifyShot;
|
ConVar g_cvNotifyShot;
|
||||||
ConVar g_cvNotifyTimer;
|
|
||||||
|
|
||||||
ArrayList g_aSpawnedProps; // Tracks entity indices of props spawned by this plugin so we can unhook them
|
ArrayList g_aSpawnedProps; // Tracks entity indices of props spawned by this plugin so we can unhook them
|
||||||
ArrayList g_aNotifyList;
|
|
||||||
|
|
||||||
enum struct NotifyListData
|
|
||||||
{
|
|
||||||
int client;
|
|
||||||
Handle timer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnPluginStart()
|
public void OnPluginStart()
|
||||||
{
|
{
|
||||||
@@ -56,11 +49,9 @@ public void OnPluginStart()
|
|||||||
RegAdminCmd("sm_propspawner", Command_MainMenu, ADMFLAG_CHANGEMAP); //g
|
RegAdminCmd("sm_propspawner", Command_MainMenu, ADMFLAG_CHANGEMAP); //g
|
||||||
|
|
||||||
g_cvNotifyShot = CreateConVar("sm_propspawner_notify_shot", "0", "If set to 1, announces in chat when a plugin-spawned prop is shot.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
|
g_cvNotifyShot = CreateConVar("sm_propspawner_notify_shot", "0", "If set to 1, announces in chat when a plugin-spawned prop is shot.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
|
||||||
g_cvNotifyTimer = CreateConVar("sm_propspawner_notify_shot_timer", "0.5", "How long a player stays in the \"shooting couch\" list.");
|
|
||||||
AutoExecConfig(true, "PropSpawner");
|
AutoExecConfig(true, "PropSpawner");
|
||||||
|
|
||||||
g_aSpawnedProps = new ArrayList();
|
g_aSpawnedProps = new ArrayList();
|
||||||
g_aNotifyList = new ArrayList();
|
|
||||||
|
|
||||||
HookEvent("round_end", Event_RoundEnd);
|
HookEvent("round_end", Event_RoundEnd);
|
||||||
}
|
}
|
||||||
@@ -575,85 +566,14 @@ public Action OnPropTakeDamage(int victim, int &attacker, int &inflictor, float
|
|||||||
if (attacker < 1 || attacker > MaxClients || !IsClientInGame(attacker))
|
if (attacker < 1 || attacker > MaxClients || !IsClientInGame(attacker))
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
|
|
||||||
Handle timer = CreateTimer(g_cvNotifyTimer.FloatValue, OnNotifyTimer, attacker);
|
char sPropName[64];
|
||||||
int idx = FindInNotifyList(attacker);
|
GetEntPropString(victim, Prop_Data, "m_ModelName", sPropName, sizeof(sPropName));
|
||||||
if (idx == -1)
|
|
||||||
{
|
|
||||||
NotifyListData data;
|
|
||||||
data.client = attacker;
|
|
||||||
data.timer = timer;
|
|
||||||
g_aNotifyList.PushArray(data, sizeof(NotifyListData));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NotifyListData buf;
|
|
||||||
g_aNotifyList.GetArray(idx, buf, sizeof(NotifyListData));
|
|
||||||
if (buf.timer != INVALID_HANDLE)
|
|
||||||
KillTimer(buf.timer);
|
|
||||||
|
|
||||||
buf.timer = timer;
|
char sAttackerName[MAX_NAME_LENGTH];
|
||||||
g_aNotifyList.SetArray(idx, buf, sizeof(NotifyListData));
|
GetClientName(attacker, sAttackerName, sizeof(sAttackerName));
|
||||||
}
|
|
||||||
|
|
||||||
DisplayNotifyList();
|
PrintToChatAll("\x01[SM] \x04%s\x01 is shooting the couch.", sAttackerName);
|
||||||
|
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayNotifyList()
|
|
||||||
{
|
|
||||||
static int channel = -1;
|
|
||||||
char text[255];
|
|
||||||
strcopy(text, sizeof(text), "Shooting Couch:\n");
|
|
||||||
|
|
||||||
for (int i = g_aNotifyList.Length - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
NotifyListData buf;
|
|
||||||
g_aNotifyList.GetArray(i, buf, sizeof(NotifyListData));
|
|
||||||
|
|
||||||
if (!IsClientInGame(buf.client))
|
|
||||||
{
|
|
||||||
if (buf.timer != INVALID_HANDLE)
|
|
||||||
KillTimer(buf.timer);
|
|
||||||
|
|
||||||
g_aNotifyList.Erase(i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
char clientName[32];
|
|
||||||
GetClientName(buf.client, clientName, sizeof(clientName));
|
|
||||||
StrCat(text, sizeof(text), clientName);
|
|
||||||
StrCat(text, sizeof(text), "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
SetHudTextParams(0.8, -1.0, g_cvNotifyTimer.FloatValue, 255, 255, 255, 255, 0, 0.0, 0.0, 0.0);
|
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
|
||||||
{
|
|
||||||
if (IsClientInGame(i))
|
|
||||||
channel = ShowHudText(i, channel, text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnNotifyTimer(Handle timer, any data)
|
|
||||||
{
|
|
||||||
int client = view_as<int>(data);
|
|
||||||
int idx = FindInNotifyList(client);
|
|
||||||
if (idx != -1)
|
|
||||||
g_aNotifyList.Erase(idx);
|
|
||||||
|
|
||||||
if (g_aNotifyList.Length)
|
|
||||||
DisplayNotifyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
int FindInNotifyList(int client)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < g_aNotifyList.Length; i++)
|
|
||||||
{
|
|
||||||
NotifyListData buf;
|
|
||||||
g_aNotifyList.GetArray(i, buf, sizeof(NotifyListData));
|
|
||||||
if (buf.client == client)
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2310,16 +2310,6 @@ NominateResult InternalNominateMap(char[] map, int owner)
|
|||||||
return Nominate_Added;
|
return Nominate_Added;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetMapCategory(const char[] mapname, char[] output_category, int maxlen)
|
|
||||||
{
|
|
||||||
strcopy(output_category, maxlen, "Uncategorized");
|
|
||||||
if (g_Config && g_Config.JumpToKey(mapname))
|
|
||||||
{
|
|
||||||
g_Config.GetString("MapCategory", output_category, maxlen, "Uncategorized");
|
|
||||||
g_Config.Rewind();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add natives to allow nominate and initiate vote to be call */
|
/* Add natives to allow nominate and initiate vote to be call */
|
||||||
|
|
||||||
/* native bool NominateMap(const char[] map, bool force, &NominateError:error); */
|
/* native bool NominateMap(const char[] map, bool force, &NominateError:error); */
|
||||||
@@ -3064,17 +3054,7 @@ public int Native_SimulateMapEnd(Handle plugin, int numParams)
|
|||||||
|
|
||||||
stock void AddMapItem(const char[] map)
|
stock void AddMapItem(const char[] map)
|
||||||
{
|
{
|
||||||
char map_with_category[1024];
|
|
||||||
if (StrContains(map, "ze_") == 0)
|
|
||||||
{
|
|
||||||
GetMapCategory(map, map_with_category, sizeof(map_with_category));
|
|
||||||
Format(map_with_category, sizeof(map_with_category), "%s (%s)", map, map_with_category);
|
|
||||||
AddMenuItem(g_VoteMenu, map, map_with_category);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AddMenuItem(g_VoteMenu, map, map);
|
AddMenuItem(g_VoteMenu, map, map);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stock void GetMapItem(Handle menu, int position, char[] map, int mapLen)
|
stock void GetMapItem(Handle menu, int position, char[] map, int mapLen)
|
||||||
|
|||||||
Reference in New Issue
Block a user