Hey guys Trippp again. Having some problem with my plugin again.
I made a plugin that for example plays a sound on bomb_explode.
You can disable/enable it by using cookies.
The only problem is that the code only executes for the player who planted the bomb?
I tried to resolve it by making a loop, but either that didn't work or I did it incorrect?
Code:
#include <sourcemod>
#include <sdktools>
#include <emitsoundany>
#include <colors>
#include <clientprefs>
new Handle:g_hDefuseSound;
new Handle:g_hHeadshotSound;
new Handle:g_hBombSound;
public OnMapStart()
{
AddFileToDownloadsTable("sound/plugin/krakaka.mp3");
AddFileToDownloadsTable("sound/plugin/zing.mp3");
AddFileToDownloadsTable("sound/plugin/taunt.mp3");
AddFileToDownloadsTable("sound/plugin/tirol.mp3");
PrecacheSoundAny("*/plugin/krakaka.mp3");
PrecacheSoundAny("*/plugin/zing.mp3");
PrecacheSoundAny("*/plugin/taunt.mp3");
PrecacheSoundAny("*/plugin/tirol.mp3");
}
public void OnPluginStart()
{
g_hDefuseSound = RegClientCookie("defusesound_cookie", "Defuse Sound ON/OFF", CookieAccess_Public);
g_hBombSound = RegClientCookie("bombsound_cookie", "Bomb Sound ON/OFF", CookieAccess_Public);
g_hHeadshotSound = RegClientCookie("headshotsound_cookie", "Headshot Sound ON/OFF", CookieAccess_Public);
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre);
HookEvent("bomb_exploded", Event_BombExploded);
HookEvent("bomb_defused", Event_BombDefused);
HookEvent("cs_win_panel_match", Event_MatchEnd);
SetCookiePrefabMenu(g_hBombSound, CookieMenu_OnOff_Int, "Bomb Sound ON/OFF");
SetCookiePrefabMenu(g_hDefuseSound, CookieMenu_OnOff_Int, "Defuse Sound ON/OFF");
SetCookiePrefabMenu(g_hHeadshotSound, CookieMenu_OnOff_Int, "Headshot Sound ON/OFF");
}
public Action Event_BombExploded(Handle:event, const String:name[], bool:dontBroadcast)
{
for(new i = 1; i <= MAXPLAYERS; i++)
{
int userid = GetEventInt(event, "userid");
int client = GetClientOfUserId(userid);
decl String:sBuffer[4];
GetClientCookie(client, g_hBombSound, sBuffer, sizeof(sBuffer));
if(StrEqual(sBuffer, "1") && IsValidClient(client))
EmitSoundToClientAny(client, "*/plugin/taunt.mp3");
return Plugin_Continue;
}
}