Skip to content

Commit

Permalink
Add forward Store_OnCheerSound
Browse files Browse the repository at this point in the history
  • Loading branch information
Kxnrl committed Sep 11, 2020
1 parent 52b80eb commit a85a1bb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/store.inc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ forward void Store_OnPetsCreated(int client, int entity);
forward Action Store_OnSetPlayerSkinArms(int client, char[] arms, int len);
forward Action Store_OnClientComposing(int client, int &probability, int itemid, const char[] uid, const char[] itemName, const char[] itemParentName);
forward void Store_OnClientComposed(int client, bool success, int itemid, const char[] itemName, const char[] itemParentName);
forward Action Store_OnCheerSound(int client, char[] sound, int len);

// CP Support
forward Action CP_OnChatMessage(int& client, ArrayList recipients, char[] flagstring, char[] name, char[] message, bool& processcolors, bool& removecolors);
Expand Down
24 changes: 23 additions & 1 deletion store/sounds.sp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ static bool g_bClientDisable[MAXPLAYERS+1];
static any g_eSounds[STORE_MAX_ITEMS][Sound];

static Handle g_hCookieSounds;
static Handle g_hOnCheerSound;

public void Sounds_OnPluginStart()
{
Store_RegisterHandler("sound", Sound_OnMapStart, Sound_Reset, Sound_Config, Sound_Equip, Sound_Remove, true);

g_hOnCheerSound = CreateGlobalForward("Store_OnCheerSound", ET_Hook, Param_Cell, Param_String, Param_Cell);

RegConsoleCmd("cheer", Command_Cheer);
RegConsoleCmd("sm_cheer", Command_Cheer);
RegConsoleCmd("sm_crpb", Command_Silence);
Expand Down Expand Up @@ -170,6 +173,25 @@ public Action Command_Cheer(int client, int args)

void StartSoundToAll(int client)
{
char sound[256];
strcopy(sound, 256, g_eSounds[g_iSoundClient[client]][szSound]);

Action res = Plugin_Continue;
Call_StartForward(g_hOnCheerSound);
Call_PushCell(client);
Call_PushString(sound);
Call_PushCell(256);
Call_Finish(res);

if (res >= Plugin_Handled)
return;

if (res == Plugin_Continue)
{
// copy again
strcopy(sound, 256, g_eSounds[g_iSoundClient[client]][szSound]);
}

int[] targets = new int[MaxClients];
int total = 0;

Expand All @@ -187,7 +209,7 @@ void StartSoundToAll(int client)
fPos[2] -= 3.0;

char szPath[128];
Format(szPath, 128, "*%s", g_eSounds[g_iSoundClient[client]][szSound]);
Format(szPath, 128, "*%s", sound);
EmitSound(targets, total, szPath, client, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, g_eSounds[g_iSoundClient[client]][fVolume], SNDPITCH_NORMAL, client, fPos, fAgl, true);

tPrintToChatAll("%t", "sound to all", client, g_eSounds[g_iSoundClient[client]][szName]);
Expand Down

0 comments on commit a85a1bb

Please sign in to comment.