forked from UNLOZE/sm-plugins
Added python scripts for easier compiling
Fixed bunch of includes and a warnings Added ip addresses for admins to status KnifeAlert prints to everyone now if someone gets infected due to a knifed zombie Fixed WeaponCleaner not registering weapons if somebody disconnects Refactored custom-chatcolors to new syntax, added autoreplace and some fixes Added GFLClan.ru support to immunityreservedslots added nominate_removemap to mapchooser_extended and fixed a bug for recently played maps
This commit is contained in:
@@ -10,12 +10,12 @@ Handle g_hTimer = INVALID_HANDLE;
|
||||
ConVar g_CVar_MaxWeapons;
|
||||
ConVar g_CVar_WeaponLifetime;
|
||||
|
||||
new g_RealRoundStartedTime;
|
||||
new g_MaxWeapons;
|
||||
new g_MaxWeaponLifetime;
|
||||
int g_RealRoundStartedTime;
|
||||
int g_MaxWeapons;
|
||||
int g_MaxWeaponLifetime;
|
||||
|
||||
#define MAX_WEAPONS MAXPLAYERS
|
||||
new G_WeaponArray[MAX_WEAPONS][2];
|
||||
int G_WeaponArray[MAX_WEAPONS][2];
|
||||
|
||||
|
||||
public Plugin myinfo =
|
||||
@@ -23,19 +23,17 @@ public Plugin myinfo =
|
||||
name = "WeaponCleaner",
|
||||
author = "BotoX",
|
||||
description = "Clean unneeded weapons",
|
||||
version = "2.0",
|
||||
version = "2.1",
|
||||
url = ""
|
||||
};
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
RegAdminCmd("sm_sweep", Command_CleanupWeapons, ADMFLAG_GENERIC, "Cleans up all the weapons on the map unless they have a HammerID attached to them.");
|
||||
|
||||
g_CVar_MaxWeapons = CreateConVar("sm_weaponcleaner_max", "5", "The maximum amount of weapons allowed in the game.", 0, true, 0.0, true, MAX_WEAPONS - 1.0);
|
||||
g_MaxWeapons = g_CVar_MaxWeapons.IntValue;
|
||||
g_CVar_MaxWeapons.AddChangeHook(OnConVarChanged);
|
||||
|
||||
g_CVar_WeaponLifetime = CreateConVar("sm_weaponcleaner_lifetime", "15", "The maximum amount of time in seconds a weapon is allowed in the game.", 0, true, 0.0);
|
||||
g_CVar_WeaponLifetime = CreateConVar("sm_weaponcleaner_lifetime", "15", "The maximum number of seconds a weapon is allowed in the game.", 0, true, 0.0);
|
||||
g_MaxWeaponLifetime = g_CVar_WeaponLifetime.IntValue;
|
||||
g_CVar_WeaponLifetime.AddChangeHook(OnConVarChanged);
|
||||
|
||||
@@ -51,10 +49,10 @@ public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] n
|
||||
if(StringToInt(newValue) < StringToInt(oldValue))
|
||||
{
|
||||
// Need to shrink list and kill items
|
||||
new d = StringToInt(oldValue) - StringToInt(newValue);
|
||||
int d = StringToInt(oldValue) - StringToInt(newValue);
|
||||
|
||||
// Kill items that don't have space anymore
|
||||
for(new i = 0; d && i < g_MaxWeapons; i++)
|
||||
for(int i = 0; d && i < g_MaxWeapons; i++)
|
||||
{
|
||||
if(!G_WeaponArray[i][0])
|
||||
continue;
|
||||
@@ -101,6 +99,14 @@ public void OnClientDisconnect(int client)
|
||||
{
|
||||
SDKUnhook(client, SDKHook_WeaponDropPost, OnWeaponDrop);
|
||||
SDKUnhook(client, SDKHook_WeaponEquipPost, OnWeaponEquip);
|
||||
|
||||
// Simulate dropping all equipped weapons
|
||||
for(int i = 0; i < 5; i++)
|
||||
{
|
||||
int weapon = GetPlayerWeaponSlot(client, i);
|
||||
if(weapon != -1)
|
||||
OnWeaponDrop(client, weapon);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnEntityCreated(int entity, const char[] classname)
|
||||
@@ -118,7 +124,7 @@ public void OnEntityDestroyed(int entity)
|
||||
|
||||
public void OnWeaponSpawned(int entity)
|
||||
{
|
||||
new HammerID = GetEntProp(entity, Prop_Data, "m_iHammerID");
|
||||
int HammerID = GetEntProp(entity, Prop_Data, "m_iHammerID");
|
||||
// Should not be cleaned since it's a map spawned weapon
|
||||
if(HammerID)
|
||||
return;
|
||||
@@ -133,7 +139,7 @@ public Action OnWeaponEquip(int client, int entity)
|
||||
if(!IsValidEntity(entity))
|
||||
return;
|
||||
|
||||
new HammerID = GetEntProp(entity, Prop_Data, "m_iHammerID");
|
||||
int HammerID = GetEntProp(entity, Prop_Data, "m_iHammerID");
|
||||
// Should not be cleaned since it's a map spawned weapon
|
||||
if(HammerID)
|
||||
return;
|
||||
@@ -147,7 +153,7 @@ public Action OnWeaponDrop(int client, int entity)
|
||||
if(!IsValidEntity(entity))
|
||||
return;
|
||||
|
||||
new HammerID = GetEntProp(entity, Prop_Data, "m_iHammerID");
|
||||
int HammerID = GetEntProp(entity, Prop_Data, "m_iHammerID");
|
||||
// Should not be cleaned since it's a map spawned weapon
|
||||
if(HammerID)
|
||||
return;
|
||||
@@ -167,7 +173,7 @@ public Action OnWeaponDrop(int client, int entity)
|
||||
bool InsertWeapon(int entity)
|
||||
{
|
||||
// Try to find a free slot
|
||||
for(new i = 0; i < g_MaxWeapons; i++)
|
||||
for(int i = 0; i < g_MaxWeapons; i++)
|
||||
{
|
||||
if(G_WeaponArray[i][0])
|
||||
continue;
|
||||
@@ -192,14 +198,14 @@ bool InsertWeapon(int entity)
|
||||
bool RemoveWeapon(int entity)
|
||||
{
|
||||
// Find the Weapon
|
||||
for(new i = 0; i < g_MaxWeapons; i++)
|
||||
for(int i = 0; i < g_MaxWeapons; i++)
|
||||
{
|
||||
if(G_WeaponArray[i][0] == entity)
|
||||
{
|
||||
G_WeaponArray[i][0] = 0; G_WeaponArray[i][1] = 0;
|
||||
|
||||
// Move list items in front of this index back by one
|
||||
for(new j = i + 1; j < g_MaxWeapons; j++)
|
||||
for(int j = i + 1; j < g_MaxWeapons; j++)
|
||||
{
|
||||
G_WeaponArray[j - 1][0] = G_WeaponArray[j][0];
|
||||
G_WeaponArray[j - 1][1] = G_WeaponArray[j][1];
|
||||
@@ -217,12 +223,12 @@ bool RemoveWeapon(int entity)
|
||||
|
||||
bool CheckWeapons()
|
||||
{
|
||||
for(new i = 0; i < g_MaxWeapons; i++)
|
||||
for(int i = 0; i < g_MaxWeapons; i++)
|
||||
{
|
||||
if(!G_WeaponArray[i][0])
|
||||
continue;
|
||||
|
||||
if(GetTime() - G_WeaponArray[i][1] >= g_MaxWeaponLifetime)
|
||||
if(g_MaxWeaponLifetime && GetTime() - G_WeaponArray[i][1] >= g_MaxWeaponLifetime)
|
||||
{
|
||||
// Kill it
|
||||
AcceptEntityInput(G_WeaponArray[i][0], "Kill");
|
||||
@@ -235,27 +241,12 @@ bool CheckWeapons()
|
||||
return true;
|
||||
}
|
||||
|
||||
void CleanupWeapons()
|
||||
{
|
||||
for(new i = 0; i < g_MaxWeapons; i++)
|
||||
{
|
||||
if(!G_WeaponArray[i][0])
|
||||
continue;
|
||||
|
||||
// Kill it
|
||||
AcceptEntityInput(G_WeaponArray[i][0], "Kill");
|
||||
// This implicitly calls OnEntityDestroyed() which calls RemoveWeapon()
|
||||
|
||||
// Move index backwards (since the list was modified by removing it)
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
public Action Event_RoundStart(Handle:event, const char[] name, bool:dontBroadcast)
|
||||
{
|
||||
for(new i = 0; i < MAX_WEAPONS; i++)
|
||||
{
|
||||
G_WeaponArray[i][0] = 0; G_WeaponArray[i][1] = 0;
|
||||
G_WeaponArray[i][0] = 0;
|
||||
G_WeaponArray[i][1] = 0;
|
||||
}
|
||||
g_RealRoundStartedTime = GetTime() + GetConVarInt(FindConVar("mp_freezetime"));
|
||||
}
|
||||
@@ -264,11 +255,3 @@ public Action Timer_CleanupWeapons(Handle:timer)
|
||||
{
|
||||
CheckWeapons();
|
||||
}
|
||||
|
||||
public Action Command_CleanupWeapons(client, args)
|
||||
{
|
||||
CleanupWeapons();
|
||||
|
||||
LogAction(client, -1, "%L performed a weapons cleanup", client);
|
||||
PrintToChat(client, "[SM] Weapons cleaned successfully!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user