View Single Post
stephen473
Senior Member
Join Date: Jan 2017
Location: somewhere on earth
Old 07-10-2019 , 07:56   Re: [CSGO] Round End Sounds
Reply With Quote #7

also, i've edited your code. now it's better, and easier to configure

PHP Code:
#pragma semicolon 1

#define DEBUG

#include <sourcemod>
#include <sdktools>
#include <colors>


// ----->> SONG LIST <<----- //
static char g_sSongList[][][255] =  
{  
    {
"dnc_song1.mp3""Name Song 1"},  
    {
"dnc_song2.mp3""Name Song 2"},  
    {
"dnc_song3.mp3""Name Song 3"},  
    {
"dnc_song4.mp3""Name Song 4"}
};  
// ----->> SONG LIST <<----- //


#define g_sServerTag "{red}[Server]"

public Plugin myinfo 
{
    
name "Round End Musics",
    
author "KaTeX & stephen473",
    
description "Puts Music at the end of Rounds..",
    
version "1.1",
    
url "https://steamcommunity.com/id/kHardy"
};

public 
void OnPluginStart()
{
    
HookEvent("round_end"Event_RoundEndEventHookMode_Pre);
}

public 
void OnMapStart()
{
    
int soundcount;
    
    for(
int i 0<= sizeof(g_sSongList); i++) 
    {
        
char buffer[PLATFORM_MAX_PATH];
        
Format(buffersizeof(buffer), "sound/%s"g_sSongList[i][0]);
        
        
AddFileToDownloadsTable(buffer);
        
PrecacheSound(g_sSongList[i][0]);
        
soundcount i;
    }
    
    
PrintToServer("[Round End] %i sounds loaded."soundcount);
}

public 
void Event_RoundEnd(Event event, const char[] namebool dontBroadcast)
{
    
int randomnum GetRandomInt(0sizeof(g_sSongList) - 1);
    
    
EmitSoundToAll(g_sSongList[randomnum][0]);
    
CPrintToChatAll("%s {default}Now is playing: {green}%s"g_sServerTagg_sSongList[randomnum][1]);

__________________
Also known as Hardy`.

Feel free to contact me if you have a private plugin request!

My Steam Profile | Discord: Hardy`#3792
stephen473 is offline