Raised This Month: $ Target: $400
 0% 

need help fixing a round end sound plugin in CSGO


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JelloFacey
Junior Member
Join Date: Sep 2012
Old 12-13-2014 , 04:50   need help fixing a round end sound plugin in CSGO
Reply With Quote #1

hello, i was trying to fix this plugin
https://forums.alliedmods.net/showthread.php?t=194666

but if someone has music volume off, it doesnt play.
so i modified it to use

ClientCommand( 0, "play *RoundEnd/misc/ctwinner1.mp3" );

here is my modified code:
Code:
/* *
 * RoundSound BY TUMMIETUM (TUMTUM)
 * -------------------------
 * Changelog Original Roundsound++ by ANTiCHRiST
 * -------------------------
 * by TanaToS aka ANTiCHRiST
 */
#include <sourcemod>
#include <sdktools>
#include <sdktools_sound>
#include <console>
#include <string>

#pragma semicolon 1

#define PLUGIN_VERSION "1.1.0"
#define MAX_FILE_LEN 256

new Handle:g_hEnabled = INVALID_HANDLE;
new bool:g_bEnabled = true;

public Plugin:myinfo = {
	name = "RoundSound CS:GO",
	author = "ANTiCHRiST Edited by TumTum",
	description = "Plays a Sound at RoundEnd.",
	version = PLUGIN_VERSION,
	url = "http://www.team-secretforce.com"
};

public OnPluginStart() {
	CreateConVar("sm_roundsound_version", PLUGIN_VERSION, "RoundSound version.", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
	g_hEnabled = CreateConVar("sm_roundsound_enable", "1", "RoundSound Enable/Disable CVar.", FCVAR_PLUGIN|FCVAR_NOTIFY);

	HookEvent("round_end", EventRoundEnd);
	HookConVarChange(g_hEnabled, CVarEnabled);
}

public OnMapStart()
{
	decl String:tewin_snd1[MAX_FILE_LEN];
	decl String:tewin_snd2[MAX_FILE_LEN];
	decl String:tewin_snd3[MAX_FILE_LEN];
	decl String:ctwin_snd1[MAX_FILE_LEN];
	decl String:ctwin_snd2[MAX_FILE_LEN];
	decl String:ctwin_snd3[MAX_FILE_LEN];

	Format(tewin_snd1, sizeof(tewin_snd1), "sound/RoundEnd/misc/twinner1.mp3");
	Format(tewin_snd2, sizeof(tewin_snd2), "sound/RoundEnd/misc/twinner2.mp3");
	Format(tewin_snd3, sizeof(tewin_snd3), "sound/RoundEnd/misc/twinner3.mp3");
	Format(ctwin_snd1, sizeof(ctwin_snd1), "sound/RoundEnd/misc/ctwinner1.mp3");
	Format(ctwin_snd2, sizeof(ctwin_snd2), "sound/RoundEnd/misc/ctwinner2.mp3");
	Format(ctwin_snd3, sizeof(ctwin_snd3), "sound/RoundEnd/misc/ctwinner3.mp3");

	if(FileExists(tewin_snd1) && FileExists(tewin_snd2) && FileExists(tewin_snd3) && FileExists(ctwin_snd1) && FileExists(ctwin_snd2) && FileExists(ctwin_snd3)) {
		AddFileToDownloadsTable(tewin_snd1);
		AddFileToDownloadsTable(tewin_snd2);
		AddFileToDownloadsTable(tewin_snd3);
		AddFileToDownloadsTable(ctwin_snd1);
		AddFileToDownloadsTable(ctwin_snd2);
		AddFileToDownloadsTable(ctwin_snd3);
	}
	else {
		LogError("Not all sound files exists.");
		LogError("Unload the Plugin.");
		ServerCommand("sm plugins unload \"RoundSound.smx\"");
	}
}

public OnConfigsExecuted() {
	if(GetConVarBool(g_hEnabled)) {
		g_bEnabled = true;
	}
	else if(!GetConVarBool(g_hEnabled)) {
		g_bEnabled = false;
	}
	else {
		g_bEnabled = true;
		LogError("False value plugin continued");
	}
}

public CVarEnabled(Handle:convar, const String:oldValue[], const String:newValue[]) {
	if(GetConVarBool(g_hEnabled)) {
		g_bEnabled = true;
	}
	else if(!GetConVarBool(g_hEnabled)) {
		g_bEnabled = false;
	}
	else {
		g_bEnabled = true;
		LogError("False value plugin continued");
	}
}

public EventRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) {
	new rnd_sound = GetRandomInt(1, 3);
	new ev_winner = GetEventInt(event, "winner");
	if(g_bEnabled) {
		if(ev_winner == 2) {
			if(rnd_sound == 1) {
				ClientCommand( 0, "play *sound/RoundEnd/misc/twinner1.mp3" );
			}
			else if(rnd_sound == 2) {
				ClientCommand( 0, "play *sound/RoundEnd/misc/twinner2.mp3" );
			}
			else if(rnd_sound == 3) {
				ClientCommand( 0, "play *sound/RoundEnd/misc/twinner3.mp3" );
			}
			else {
				LogError("Ramdom Sound CVar Error.");
			}
		}
		else if(ev_winner == 3) {
			if(rnd_sound == 1) {
				ClientCommand( 0, "play *RoundEnd/misc/ctwinner1.mp3" );
			}
			else if(rnd_sound == 2) {
				ClientCommand( 0, "play *RoundEnd/misc/ctwinner2.mp3" );
			}
			else if(rnd_sound == 3) {
				ClientCommand( 0, "play *RoundEnd/misc/ctwinner3.mp3" );
			}
			else {
				LogError("Ramdom Sound CVar Error.");
			}
		}
		else {
			LogError("No team has win the round.");
		}
	}
}
the sounds do not play, an error prints in the console saying that client 0 is not a valid client, isnt client 0 the server? eg. everyone? does anyone know why doesnt it work??
JelloFacey is offline
JelloFacey
Junior Member
Join Date: Sep 2012
Old 12-13-2014 , 09:50   Re: need help fixing a round end sound plugin in CSGO
Reply With Quote #2

bump help
JelloFacey is offline
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 12-13-2014 , 15:27   Re: need help fixing a round end sound plugin in CSGO
Reply With Quote #3

Quote:
Originally Posted by JelloFacey View Post
bump help
Client can't be 0 you should define it and it will probably work

And i would recommend using sm_play or Emitsound
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player

Last edited by Michalplyoutube; 12-13-2014 at 15:29.
Michalplyoutube is offline
JelloFacey
Junior Member
Join Date: Sep 2012
Old 12-13-2014 , 22:50   Re: need help fixing a round end sound plugin in CSGO
Reply With Quote #4

Quote:
Originally Posted by Michalplyoutube View Post
Client can't be 0 you should define it and it will probably work

And i would recommend using sm_play or Emitsound
should i define it as 1? i want everyone to hear it
JelloFacey is offline
JelloFacey
Junior Member
Join Date: Sep 2012
Old 12-14-2014 , 05:41   Re: need help fixing a round end sound plugin in CSGO
Reply With Quote #5

bumpedy, need help
JelloFacey is offline
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 12-14-2014 , 09:10   Re: need help fixing a round end sound plugin in CSGO
Reply With Quote #6

use instead of client command EmitSoundToAll https://sm.alliedmods.net/api/index....d=show&id=682&
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player
Michalplyoutube is offline
JelloFacey
Junior Member
Join Date: Sep 2012
Old 12-15-2014 , 09:46   Re: need help fixing a round end sound plugin in CSGO
Reply With Quote #7

I used EmitSoundToAll but now it says
cant create mixer for my MP3 file, all of them
JelloFacey is offline
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 12-15-2014 , 09:49   Re: need help fixing a round end sound plugin in CSGO
Reply With Quote #8

Quote:
Originally Posted by JelloFacey View Post
I used EmitSoundToAll but now it says
cant create mixer for my MP3 file, all of them
Make sure u precache it before playing it
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player
Michalplyoutube is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-15-2014 , 10:00   Re: need help fixing a round end sound plugin in CSGO
Reply With Quote #9

If you're going to use EmitSoundToAll, you really need to read the CS:GO Quirks regarding EmitSound.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
JelloFacey
Junior Member
Join Date: Sep 2012
Old 12-15-2014 , 11:38   Re: need help fixing a round end sound plugin in CSGO
Reply With Quote #10

Sorry if i did this wrongly, but heres what i did to precache

PrecacheSound("*RoundEnd/misc/ctwinnar1.mp3", true);
PrecacheSound("*RoundEnd/misc/ctwinnar2.mp3", true);
PrecacheSound("*RoundEnd/misc/ctwinnar3.mp3", true);
PrecacheSound("*RoundEnd/misc/twinnar1.mp3", true);
PrecacheSound("*RoundEnd/misc/twinnar2.mp3", true);
PrecacheSound("*RoundEnd/misc/twinnar3.mp3", true);
I didn't touch anything else, not sure if i did it correctly, but im very new to this
JelloFacey is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode