added SprayManager (made by Obus)

added PlayerVisibility
StopSound: reload sounds are now muted and cleanup
SelfMute: cleanup
AdminCheats, WeaponCleaner: fixed error
This commit is contained in:
BotoX 2016-05-08 02:46:46 +02:00
parent 11aefe731b
commit a393310e29
6 changed files with 2559 additions and 202 deletions

View File

@ -74,6 +74,9 @@ public void UpdateClients()
public void OnClientPutInServer(int client)
{
if(IsFakeClient(client))
return;
SendConVarValue(client, g_CVar_sv_cheats, "0");
}

View File

@ -0,0 +1,149 @@
#pragma semicolon 1
#include <sourcemod>
#include <sdkhooks>
#include <zombiereloaded>
public Plugin myinfo =
{
name = "PlayerVisibility",
author = "BotoX",
description = "Fades players away when you get close to them.",
version = "1.0",
url = ""
};
int g_Client_Alpha[MAXPLAYERS + 1] = {255, ...};
public void OnPluginStart()
{
for(int client = 1; client <= MaxClients; client++)
{
if(IsClientInGame(client))
OnClientPutInServer(client);
}
}
public void OnPluginEnd()
{
for(int client = 1; client <= MaxClients; client++)
{
if(IsClientInGame(client))
{
if(g_Client_Alpha[client] != 255.0)
SetEntityRenderMode(client, RENDER_NORMAL);
OnClientDisconnect(client);
}
}
}
public void OnClientPutInServer(int client)
{
SDKHook(client, SDKHook_PostThink, OnPostThink);
}
public void OnClientDisconnect(int client)
{
SDKUnhook(client, SDKHook_PostThink, OnPostThink);
}
public void OnPostThink(client)
{
if(!IsPlayerAlive(client))
return;
if(!ZR_IsClientHuman(client))
{
if(g_Client_Alpha[client] != 255)
{
g_Client_Alpha[client] = 255;
if(GetEntityRenderMode(client) != RENDER_NONE)
ToolsSetEntityAlpha(client, 255);
}
return;
}
if(GetEntityRenderMode(client) == RENDER_NONE)
{
g_Client_Alpha[client] = 255;
return;
}
float fAlpha = 255.0;
for(int i = 1; i <= MaxClients; i++)
{
if(i == client || !IsClientInGame(i) || !IsPlayerAlive(i))
continue;
if(!ZR_IsClientHuman(i))
continue;
static float fVec1[3];
static float fVec2[3];
GetClientAbsOrigin(client, fVec1);
GetClientAbsOrigin(i, fVec2);
float fMaxDistance = 150.0;
float fDistance = GetVectorDistance(fVec1, fVec2, false);
if(fDistance <= fMaxDistance)
{
float fFactor = fDistance / fMaxDistance;
if(fFactor < 0.75)
fFactor = 0.75;
fAlpha *= fFactor;
}
}
if(fAlpha < 100.0)
fAlpha = 100.0;
int Alpha = RoundToNearest(fAlpha);
int LastAlpha = g_Client_Alpha[client];
g_Client_Alpha[client] = Alpha;
if(Alpha == LastAlpha)
return;
ToolsSetEntityAlpha(client, Alpha);
}
void ToolsSetEntityAlpha(int client, int Alpha)
{
if(Alpha == 255)
{
SetEntityRenderMode(client, RENDER_NORMAL);
return;
}
int aColor[4];
ToolsGetEntityColor(client, aColor);
SetEntityRenderMode(client, RENDER_TRANSCOLOR);
SetEntityRenderColor(client, aColor[0], aColor[1], aColor[2], g_Client_Alpha[client]);
}
stock ToolsGetEntityColor(int entity, int aColor[4])
{
static bool s_GotConfig = false;
static char s_sProp[32];
if(!s_GotConfig)
{
Handle GameConf = LoadGameConfigFile("core.games");
bool Exists = GameConfGetKeyValue(GameConf, "m_clrRender", s_sProp, sizeof(s_sProp));
CloseHandle(GameConf);
if(!Exists)
strcopy(s_sProp, sizeof(s_sProp), "m_clrRender");
s_GotConfig = true;
}
int Offset = GetEntSendPropOffs(entity, s_sProp);
for(int i = 0; i < 4; i++)
aColor[i] = GetEntData(entity, Offset + i, 1);
}

View File

@ -19,7 +19,7 @@ bool g_Plugin_zombiereloaded = false;
bool g_Plugin_voiceannounce_ex = false;
bool g_Plugin_AdvancedTargeting = false;
#define PLUGIN_VERSION "2.0.1"
#define PLUGIN_VERSION "2.1"
public Plugin myinfo =
{
@ -78,10 +78,10 @@ public void OnPluginStart()
public void OnAllPluginsLoaded()
{
g_Plugin_ccc = LibraryExists("ccc");
g_Plugin_zombiereloaded = true;//LibraryExists("zombiereloaded");
g_Plugin_zombiereloaded = LibraryExists("zombiereloaded");
g_Plugin_voiceannounce_ex = LibraryExists("voiceannounce_ex");
g_Plugin_AdvancedTargeting = LibraryExists("AdvancedTargeting");
PrintToServer("CCC: %s\nZombieReloaded: %s\nVoiceAnnounce: %s\nAdvancedTargeting: %s",
LogMessage("CCC: %s\nZombieReloaded: %s\nVoiceAnnounce: %s\nAdvancedTargeting: %s",
(g_Plugin_ccc ? "loaded" : "not loaded"),
(g_Plugin_zombiereloaded ? "loaded" : "not loaded"),
(g_Plugin_voiceannounce_ex ? "loaded" : "not loaded"),
@ -805,94 +805,111 @@ void DisplayUnMuteMenu(int client)
/*
* HOOKS
*/
#define MAX_MESSAGES 8
int g_MsgDest[MAX_MESSAGES];
int g_MsgClient[MAX_MESSAGES] = {-1, ...};
char g_MsgName[MAX_MESSAGES][256];
char g_MsgParam1[MAX_MESSAGES][256];
char g_MsgParam2[MAX_MESSAGES][256];
char g_MsgParam3[MAX_MESSAGES][256];
char g_MsgParam4[MAX_MESSAGES][256];
int g_MsgPlayersNum[MAX_MESSAGES];
int g_MsgPlayers[MAX_MESSAGES][MAXPLAYERS + 1];
int g_NumMessages = 0;
int g_MsgDest;
int g_MsgClient;
char g_MsgName[256];
char g_MsgParam1[256];
char g_MsgParam2[256];
char g_MsgParam3[256];
char g_MsgParam4[256];
char g_MsgRadioSound[256];
int g_MsgPlayersNum;
int g_MsgPlayers[MAXPLAYERS + 1];
public Action Hook_UserMessageRadioText(UserMsg msg_id, Handle bf, const int[] players, int playersNum, bool reliable, bool init)
{
if(g_NumMessages >= MAX_MESSAGES)
return Plugin_Handled; // Silently drop
g_MsgDest = BfReadByte(bf);
g_MsgClient = BfReadByte(bf);
BfReadString(bf, g_MsgName, sizeof(g_MsgName), false);
BfReadString(bf, g_MsgParam1, sizeof(g_MsgParam1), false);
BfReadString(bf, g_MsgParam2, sizeof(g_MsgParam2), false);
BfReadString(bf, g_MsgParam3, sizeof(g_MsgParam3), false);
BfReadString(bf, g_MsgParam4, sizeof(g_MsgParam4), false);
g_MsgDest[g_NumMessages] = BfReadByte(bf);
g_MsgClient[g_NumMessages] = BfReadByte(bf);
BfReadString(bf, g_MsgName[g_NumMessages], sizeof(g_MsgName[]), false);
BfReadString(bf, g_MsgParam1[g_NumMessages], sizeof(g_MsgParam1[]), false);
BfReadString(bf, g_MsgParam2[g_NumMessages], sizeof(g_MsgParam2[]), false);
BfReadString(bf, g_MsgParam3[g_NumMessages], sizeof(g_MsgParam3[]), false);
BfReadString(bf, g_MsgParam4[g_NumMessages], sizeof(g_MsgParam4[]), false);
g_MsgPlayersNum[g_NumMessages] = playersNum;
// Check which clients need to be excluded.
g_MsgPlayersNum = 0;
for(int i = 0; i < playersNum; i++)
g_MsgPlayers[g_NumMessages][i] = players[i];
{
int client = players[i];
if(!GetIgnored(client, g_MsgClient))
g_MsgPlayers[g_MsgPlayersNum++] = client;
}
// No clients were excluded.
if(g_MsgPlayersNum == playersNum)
{
g_MsgClient = -1;
return Plugin_Continue;
}
else if(g_MsgPlayersNum == 0) // All clients were excluded and there is no need to broadcast.
{
g_MsgClient = -2;
return Plugin_Handled;
}
return Plugin_Handled;
}
char g_MsgRadioSound[MAX_MESSAGES][256];
public Action Hook_UserMessageSendAudio(UserMsg msg_id, Handle bf, const int[] players, int playersNum, bool reliable, bool init)
{
if(g_NumMessages >= MAX_MESSAGES)
return Plugin_Handled; // Silently drop
if(g_MsgClient == -1)
return Plugin_Continue;
else if(g_MsgClient == -2)
return Plugin_Handled;
BfReadString(bf, g_MsgRadioSound[g_NumMessages], sizeof(g_MsgRadioSound[]), false);
BfReadString(bf, g_MsgRadioSound, sizeof(g_MsgRadioSound), false);
if(!g_NumMessages)
CreateTimer(0.1, Timer_PlayerRadio);
DataPack pack = new DataPack();
pack.WriteCell(g_MsgDest);
pack.WriteCell(g_MsgClient);
pack.WriteString(g_MsgName);
pack.WriteString(g_MsgParam1);
pack.WriteString(g_MsgParam2);
pack.WriteString(g_MsgParam3);
pack.WriteString(g_MsgParam4);
pack.WriteString(g_MsgRadioSound);
pack.WriteCell(g_MsgPlayersNum);
g_NumMessages++;
ArrayList aPlayers = new ArrayList(g_MsgPlayersNum, 1);
aPlayers.SetArray(0, g_MsgPlayers, g_MsgPlayersNum);
pack.WriteCell(aPlayers);
RequestFrame(OnPlayerRadio, pack);
return Plugin_Handled;
}
public Action Timer_PlayerRadio(Handle timer)
public void OnPlayerRadio(DataPack pack)
{
for(int NumMsg = 0; NumMsg < g_NumMessages; NumMsg++)
{
if(g_MsgClient[NumMsg] == -1)
continue;
pack.Reset();
g_MsgDest = pack.ReadCell();
g_MsgClient = pack.ReadCell();
pack.ReadString(g_MsgName, sizeof(g_MsgName));
pack.ReadString(g_MsgParam1, sizeof(g_MsgParam1));
pack.ReadString(g_MsgParam2, sizeof(g_MsgParam2));
pack.ReadString(g_MsgParam3, sizeof(g_MsgParam3));
pack.ReadString(g_MsgParam4, sizeof(g_MsgParam4));
pack.ReadString(g_MsgRadioSound, sizeof(g_MsgRadioSound));
g_MsgPlayersNum = pack.ReadCell();
ArrayList aPlayers = pack.ReadCell();
CloseHandle(pack);
int[] players = new int[g_MsgPlayersNum[NumMsg] + 1];
int playersNum = 0;
aPlayers.GetArray(0, g_MsgPlayers, g_MsgPlayersNum);
delete aPlayers;
for(int i = 0; i < g_MsgPlayersNum[NumMsg]; i++)
{
int client = g_MsgPlayers[NumMsg][i];
if(IsClientInGame(client) && !GetIgnored(client, g_MsgClient[NumMsg]))
players[playersNum++] = client;
}
Handle RadioText = StartMessage("RadioText", g_MsgPlayers, g_MsgPlayersNum, USERMSG_RELIABLE | USERMSG_BLOCKHOOKS);
BfWriteByte(RadioText, g_MsgDest);
BfWriteByte(RadioText, g_MsgClient);
BfWriteString(RadioText, g_MsgName);
BfWriteString(RadioText, g_MsgParam1);
BfWriteString(RadioText, g_MsgParam2);
BfWriteString(RadioText, g_MsgParam3);
BfWriteString(RadioText, g_MsgParam4);
EndMessage();
Handle RadioText = StartMessage("RadioText", players, playersNum, USERMSG_RELIABLE | USERMSG_BLOCKHOOKS);
BfWriteByte(RadioText, g_MsgDest[NumMsg]);
BfWriteByte(RadioText, g_MsgClient[NumMsg]);
BfWriteString(RadioText, g_MsgName[NumMsg]);
BfWriteString(RadioText, g_MsgParam1[NumMsg]);
BfWriteString(RadioText, g_MsgParam2[NumMsg]);
BfWriteString(RadioText, g_MsgParam3[NumMsg]);
BfWriteString(RadioText, g_MsgParam4[NumMsg]);
EndMessage();
Handle SendAudio = StartMessage("SendAudio", players, playersNum, USERMSG_RELIABLE | USERMSG_BLOCKHOOKS);
BfWriteString(SendAudio, g_MsgRadioSound[NumMsg]);
EndMessage();
g_MsgClient[NumMsg] = -1;
}
g_NumMessages = 0;
return Plugin_Stop;
Handle SendAudio = StartMessage("SendAudio", g_MsgPlayers, g_MsgPlayersNum, USERMSG_RELIABLE | USERMSG_BLOCKHOOKS);
BfWriteString(SendAudio, g_MsgRadioSound);
EndMessage();
}
/*

File diff suppressed because it is too large Load Diff

View File

@ -2,40 +2,36 @@
#include <sourcemod>
#include <sdktools>
#include <morecolors>
#include "morecolors.inc"
#undef REQUIRE_PLUGIN
#define PLUGIN_NAME "Toggle Weapon Sounds"
#define PLUGIN_VERSION "1.2.0"
#pragma newdecls required
#define PLUGIN_VERSION "1.3.0"
#define UPDATE_URL "http://godtony.mooo.com/stopsound/stopsound.txt"
bool g_bStopSound[MAXPLAYERS+1];
bool g_bHooked;
static char g_sKVPATH[PLATFORM_MAX_PATH];
KeyValues g_hWepSounds;
new bool:g_bStopSound[MAXPLAYERS+1], bool:g_bHooked;
static String:g_sKVPATH[PLATFORM_MAX_PATH];
new Handle:g_hWepSounds;
public Plugin:myinfo =
public Plugin myinfo =
{
name = PLUGIN_NAME,
author = "GoD-Tony, edit by id/Obus",
name = "Toggle Weapon Sounds",
author = "GoD-Tony, edit by Obus + BotoX",
description = "Allows clients to stop hearing weapon sounds",
version = PLUGIN_VERSION,
url = "http://www.sourcemod.net/"
};
public OnPluginStart()
public void OnPluginStart()
{
// Detect game and hook appropriate tempent.
decl String:sGame[32];
static char sGame[32];
GetGameFolderName(sGame, sizeof(sGame));
if (StrEqual(sGame, "cstrike"))
{
if(StrEqual(sGame, "cstrike"))
AddTempEntHook("Shotgun Shot", CSS_Hook_ShotgunShot);
}
else if (StrEqual(sGame, "dod"))
{
else if(StrEqual(sGame, "dod"))
AddTempEntHook("FireBullets", DODS_Hook_FireBullets);
}
// TF2/HL2:DM and misc weapon sounds will be caught here.
AddNormalSoundHook(Hook_NormalSound);
@ -43,62 +39,81 @@ public OnPluginStart()
CreateConVar("sm_stopsound_version", PLUGIN_VERSION, "Toggle Weapon Sounds", FCVAR_NOTIFY|FCVAR_DONTRECORD|FCVAR_REPLICATED);
RegConsoleCmd("sm_stopsound", Command_StopSound, "Toggle hearing weapon sounds");
if (g_hWepSounds != INVALID_HANDLE)
{
CloseHandle(g_hWepSounds);
}
g_hWepSounds = CreateKeyValues("WeaponSounds");
g_hWepSounds = new KeyValues("WeaponSounds");
BuildPath(Path_SM, g_sKVPATH, sizeof(g_sKVPATH), "data/playerprefs.WepSounds.txt");
g_hWepSounds.ImportFromFile(g_sKVPATH);
FileToKeyValues(g_hWepSounds, g_sKVPATH);
// Suppress reload sound effects
UserMsg ReloadEffect = GetUserMessageId("ReloadEffect");
if(ReloadEffect != INVALID_MESSAGE_ID)
HookUserMessage(ReloadEffect, Hook_ReloadEffect, true);
// Updater.
//if (LibraryExists("updater"))
//{
// Updater_AddPlugin(UPDATE_URL);
//}
// Late load
for(int client = 1; client <= MaxClients; client++)
{
if(IsClientInGame(client) && IsClientAuthorized(client))
{
static char sAuth[32];
GetClientAuthId(client, AuthId_Steam2, sAuth, sizeof(sAuth));
OnClientAuthorized(client, sAuth);
}
}
}
/*public OnLibraryAdded(const String:name[])
public void OnPluginEnd()
{
if (StrEqual(name, "updater"))
for(int client = 1; client <= MaxClients; client++)
{
Updater_AddPlugin(UPDATE_URL);
if(IsClientInGame(client))
OnClientDisconnect_Post(client);
}
}*/
public Action:Command_StopSound(client, args)
// Detect game and unhook appropriate tempent.
static char sGame[32];
GetGameFolderName(sGame, sizeof(sGame));
if(StrEqual(sGame, "cstrike"))
RemoveTempEntHook("Shotgun Shot", CSS_Hook_ShotgunShot);
else if(StrEqual(sGame, "dod"))
RemoveTempEntHook("FireBullets", DODS_Hook_FireBullets);
// TF2/HL2:DM and misc weapon sounds were caught here.
RemoveNormalSoundHook(Hook_NormalSound);
UserMsg ReloadEffect = GetUserMessageId("ReloadEffect");
if(ReloadEffect != INVALID_MESSAGE_ID)
UnhookUserMessage(ReloadEffect, Hook_ReloadEffect, true);
}
public Action Command_StopSound(int client, int args)
{
if (client == 0)
if(client == 0)
{
PrintToServer("[SM] Cannot use command from server console.");
return Plugin_Handled;
}
if (args > 0)
if(args > 0)
{
decl String:Arguments[32];
static char Arguments[32];
GetCmdArg(1, Arguments, sizeof(Arguments));
if (StrEqual(Arguments, "save"))
static char SID[32];
GetClientAuthId(client, AuthId_Steam2, SID, sizeof(SID));
if(StrEqual(Arguments, "save"))
{
KvRewind(g_hWepSounds);
g_hWepSounds.Rewind();
decl String:SID[32];
GetClientAuthId(client, AuthId_Steam2, SID, sizeof(SID));
if (KvJumpToKey(g_hWepSounds, SID, true))
if(g_hWepSounds.JumpToKey(SID, true))
{
new disabled;
disabled = KvGetNum(g_hWepSounds, "disabled", 0);
if (!disabled)
int disabled = g_hWepSounds.GetNum("disabled", 0);
if(!disabled)
{
//CPrintToChat(client, "[StopSound] Saved entry for STEAMID({green}%s{default}) {green}successfully{default}.", SID);
KvSetNum(g_hWepSounds, "disabled", 1);
KvRewind(g_hWepSounds);
KeyValuesToFile(g_hWepSounds, g_sKVPATH);
g_hWepSounds.SetNum("disabled", 1);
g_hWepSounds.Rewind();
g_hWepSounds.ExportToFile(g_sKVPATH);
g_bStopSound[client] = true;
CReplyToCommand(client, "{green}[StopSound]{default} Weapon sounds {red}disabled{default} - {green}entry saved{default}.");
@ -109,9 +124,9 @@ public Action:Command_StopSound(client, args)
else
{
//CPrintToChat(client, "[StopSound] Entry for STEAMID({green}%s{default}) {green}successfully deleted{default}.", SID);
KvDeleteThis(g_hWepSounds);
KvRewind(g_hWepSounds);
KeyValuesToFile(g_hWepSounds, g_sKVPATH);
g_hWepSounds.DeleteThis();
g_hWepSounds.Rewind();
g_hWepSounds.ExportToFile(g_sKVPATH);
g_bStopSound[client] = false;
CReplyToCommand(client, "{green}[StopSound]{default} Weapon sounds {green}enabled{default} - {red}entry deleted{default}.");
@ -121,24 +136,21 @@ public Action:Command_StopSound(client, args)
}
}
KvRewind(g_hWepSounds);
g_hWepSounds.Rewind();
}
else if (StrEqual(Arguments, "delete"))
else if(StrEqual(Arguments, "delete"))
{
KvRewind(g_hWepSounds);
g_hWepSounds.Rewind();
decl String:SID[32];
GetClientAuthId(client, AuthId_Steam2, SID, sizeof(SID));
if (KvJumpToKey(g_hWepSounds, SID, false))
if(g_hWepSounds.JumpToKey(SID, false))
{
g_bStopSound[client] = false;
CReplyToCommand(client, "{green}[StopSound]{default} Weapon sounds {green}enabled{default} - {red}entry deleted{default}.");
CheckHooks();
KvDeleteThis(g_hWepSounds);
KvRewind(g_hWepSounds);
KeyValuesToFile(g_hWepSounds, g_sKVPATH);
g_hWepSounds.DeleteThis();
g_hWepSounds.Rewind();
g_hWepSounds.ExportToFile(g_sKVPATH);
return Plugin_Handled;
}
@ -162,41 +174,34 @@ public Action:Command_StopSound(client, args)
return Plugin_Handled;
}
public OnClientPutInServer(client)
public void OnClientAuthorized(int client, const char[] auth)
{
KvRewind(g_hWepSounds);
g_hWepSounds.Rewind();
decl String:SID[32];
GetClientAuthId(client, AuthId_Steam2, SID, sizeof(SID));
if (KvJumpToKey(g_hWepSounds, SID, false))
if(KvJumpToKey(g_hWepSounds, auth, false))
{
new disabled;
disabled = KvGetNum(g_hWepSounds, "disabled", 0);
if (disabled)
{
int disabled = g_hWepSounds.GetNum("disabled", 0);
if(disabled)
g_bStopSound[client] = true;
}
}
CheckHooks();
KvRewind(g_hWepSounds);
g_hWepSounds.Rewind();
}
public OnClientDisconnect_Post(client)
public void OnClientDisconnect_Post(int client)
{
g_bStopSound[client] = false;
CheckHooks();
}
CheckHooks()
void CheckHooks()
{
new bool:bShouldHook = false;
bool bShouldHook = false;
for (new i = 1; i <= MaxClients; i++)
for(int i = 1; i <= MaxClients; i++)
{
if (g_bStopSound[i])
if(g_bStopSound[i])
{
bShouldHook = true;
break;
@ -207,25 +212,22 @@ CheckHooks()
g_bHooked = bShouldHook;
}
public Action:Hook_NormalSound(clients[64], &numClients, String:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags)
public Action Hook_NormalSound(int clients[MAXPLAYERS], int &numClients, char sample[PLATFORM_MAX_PATH],
int &entity, int &channel, float &volume, int &level, int &pitch, int &flags,
char soundEntry[PLATFORM_MAX_PATH], int &seed)
{
// Ignore non-weapon sounds.
if (!g_bHooked || !(strncmp(sample, "weapons", 7) == 0 || strncmp(sample[1], "weapons", 7) == 0))
{
if(!g_bHooked || !(strncmp(sample, "weapons", 7) == 0 || strncmp(sample[1], "weapons", 7) == 0))
return Plugin_Continue;
}
decl i, j;
for (i = 0; i < numClients; i++)
for(int i = 0; i < numClients; i++)
{
if (g_bStopSound[clients[i]])
int client = clients[i];
if(g_bStopSound[client])
{
// Remove the client from the array.
for (j = i; j < numClients - 1; j++)
{
for(int j = i; j < numClients - 1; j++)
clients[j] = clients[j + 1];
}
numClients--;
i--;
@ -235,39 +237,30 @@ public Action:Hook_NormalSound(clients[64], &numClients, String:sample[PLATFORM_
return (numClients > 0) ? Plugin_Changed : Plugin_Stop;
}
public Action:CSS_Hook_ShotgunShot(const String:te_name[], const Players[], numClients, Float:delay)
public Action CSS_Hook_ShotgunShot(const char[] te_name, const int[] Players, int numClients, float delay)
{
if (!g_bHooked)
{
if(!g_bHooked)
return Plugin_Continue;
}
// Check which clients need to be excluded.
decl newClients[MaxClients], client, i;
new newTotal = 0;
int[] newClients = new int[numClients];
int newTotal = 0;
for (i = 0; i < numClients; i++)
for(int i = 0; i < numClients; i++)
{
client = Players[i];
if (!g_bStopSound[client])
{
int client = Players[i];
if(!g_bStopSound[client])
newClients[newTotal++] = client;
}
}
// No clients were excluded.
if (newTotal == numClients)
{
if(newTotal == numClients)
return Plugin_Continue;
}
else if (newTotal == 0) // All clients were excluded and there is no need to broadcast.
{
else if(newTotal == 0) // All clients were excluded and there is no need to broadcast.
return Plugin_Stop;
}
// Re-broadcast to clients that still need it.
decl Float:vTemp[3];
float vTemp[3];
TE_Start("Shotgun Shot");
TE_ReadVector("m_vecOrigin", vTemp);
TE_WriteVector("m_vecOrigin", vTemp);
@ -284,39 +277,30 @@ public Action:CSS_Hook_ShotgunShot(const String:te_name[], const Players[], numC
return Plugin_Stop;
}
public Action:DODS_Hook_FireBullets(const String:te_name[], const Players[], numClients, Float:delay)
public Action DODS_Hook_FireBullets(const char[] te_name, const int[] Players, int numClients, float delay)
{
if (!g_bHooked)
{
if(!g_bHooked)
return Plugin_Continue;
}
// Check which clients need to be excluded.
decl newClients[MaxClients], client, i;
new newTotal = 0;
int[] newClients = new int[numClients];
int newTotal = 0;
for (i = 0; i < numClients; i++)
for(int i = 0; i < numClients; i++)
{
client = Players[i];
if (!g_bStopSound[client])
{
int client = Players[i];
if(!g_bStopSound[client])
newClients[newTotal++] = client;
}
}
// No clients were excluded.
if (newTotal == numClients)
{
if(newTotal == numClients)
return Plugin_Continue;
}
else if (newTotal == 0)// All clients were excluded and there is no need to broadcast.
{
else if(newTotal == 0)// All clients were excluded and there is no need to broadcast.
return Plugin_Stop;
}
// Re-broadcast to clients that still need it.
decl Float:vTemp[3];
float vTemp[3];
TE_Start("FireBullets");
TE_ReadVector("m_vecOrigin", vTemp);
TE_WriteVector("m_vecOrigin", vTemp);
@ -330,4 +314,61 @@ public Action:DODS_Hook_FireBullets(const String:te_name[], const Players[], num
TE_Send(newClients, newTotal, delay);
return Plugin_Stop;
}
}
public Action Hook_ReloadEffect(UserMsg msg_id, BfRead msg, const int[] players, int playersNum, bool reliable, bool init)
{
if(!g_bHooked)
return Plugin_Continue;
int client = msg.ReadShort();
// Check which clients need to be excluded.
int[] newClients = new int[playersNum];
int newTotal = 0;
for(int i = 0; i < playersNum; i++)
{
int client_ = players[i];
if(IsClientInGame(client_) && !g_bStopSound[client_])
newClients[newTotal++] = client_;
}
// No clients were excluded.
if(newTotal == playersNum)
return Plugin_Continue;
else if(newTotal == 0) // All clients were excluded and there is no need to broadcast.
return Plugin_Handled;
DataPack pack = new DataPack();
pack.WriteCell(client);
pack.WriteCell(newTotal);
ArrayList aPlayers = new ArrayList(newTotal, 1);
aPlayers.SetArray(0, newClients, newTotal);
pack.WriteCell(aPlayers);
RequestFrame(OnReloadEffect, pack);
return Plugin_Handled;
}
public void OnReloadEffect(DataPack pack)
{
pack.Reset();
int client = pack.ReadCell();
int playersNum = pack.ReadCell();
ArrayList aPlayers = pack.ReadCell();
CloseHandle(pack);
int[] players = new int[playersNum];
aPlayers.GetArray(0, players, playersNum);
delete aPlayers;
Handle ReloadEffect = StartMessage("ReloadEffect", players, playersNum, USERMSG_RELIABLE | USERMSG_BLOCKHOOKS);
if(GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf)
PbSetInt(ReloadEffect, "entidx", client);
else
BfWriteShort(ReloadEffect, client);
EndMessage();
}

View File

@ -100,6 +100,9 @@ public void OnClientDisconnect(int client)
SDKUnhook(client, SDKHook_WeaponDropPost, OnWeaponDrop);
SDKUnhook(client, SDKHook_WeaponEquipPost, OnWeaponEquip);
if(!IsClientInGame(client))
return;
// Simulate dropping all equipped weapons
for(int i = 0; i < 5; i++)
{