View Single Post
LenHard
Senior Member
Join Date: Jan 2016
Old 06-23-2018 , 17:32   Re: |CSGO| Custom Join-Message-Sound by Steamid
Reply With Quote #2

PHP Code:
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
#pragma newdecls required

KeyValues gK_JoinInfo;

public 
void OnMapStart()
{
    
gK_JoinInfo = new KeyValues("joininfo");

    
char[] sFile = new char[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMsFilePLATFORM_MAX_PATH"configs/joininfo.cfg");
    
gK_JoinInfo.ImportFromFile(sFile);
}

public 
void OnMapEnd() {
    
delete gK_JoinInfo;
}

public 
void OnClientPostAdminCheck(int client)
{
    if (!
IsFakeClient(client))
    {
        
char[] sSteamId = new char[MAX_NAME_LENGTH];
        
GetClientAuthId(clientAuthId_Steam2sSteamIdMAX_NAME_LENGTH);
     
        if (
gK_JoinInfo.JumpToKey(sSteamIdfalse))
        {
            
char[] sFormat = new char[PLATFORM_MAX_PATH];
            
gK_JoinInfo.GetString("sound"sFormatPLATFORM_MAX_PATH);
            
            if (
sFormat[0] != '\0'
            {
                if (
sFormat[0] != '*')
                    
Format(sFormatPLATFORM_MAX_PATH"*%s"sFormat);    
                
EmitSoundToAll(sFormat);
            }
            
            
gK_JoinInfo.GetString("message"sFormatPLATFORM_MAX_PATH);
            
            if (
sFormat[0] != '\0'
            {
                
FilterColors(sFormat);
                
PrintToChatAll(" %s"sFormat);
            }
        }
        
gK_JoinInfo.Rewind();
    }
}

void FilterColors(char[] sString)
{    
    
ReplaceString(sStringPLATFORM_MAX_PATH"{red}""\x02"false);
    
ReplaceString(sStringPLATFORM_MAX_PATH"{green}""\x04"false);
    
ReplaceString(sStringPLATFORM_MAX_PATH"{olive}""\x06"false);
    
ReplaceString(sStringPLATFORM_MAX_PATH"{purple}""\x03"false);
    
ReplaceString(sStringPLATFORM_MAX_PATH"{yellow}""\x09"false);
    
ReplaceString(sStringPLATFORM_MAX_PATH"{blue}""\x0B"false);
    
ReplaceString(sStringPLATFORM_MAX_PATH"{pink}""\x0E"false);
    
ReplaceString(sStringPLATFORM_MAX_PATH"{grey}""\x08"false);
    
ReplaceString(sStringPLATFORM_MAX_PATH"{lightred}""\x07"false);
    
ReplaceString(sStringPLATFORM_MAX_PATH"{white}""\x01"false);
    
ReplaceString(sStringPLATFORM_MAX_PATH"{orange}""\x10"false);

Create a file in configs folder called "joininfo.cfg" and in it add
Code:
"joininfo"
{
	"STEAM_ID"
	{
		"sound" 		"*blah/file.mp3"
		"message"		"Testing"
	}
}
Try it out (Untested)

Note: Precache + add the sounds to downloads table before adding them into the file.
Attached Files
File Type: sp Get Plugin or Get Source (Join-Info.sp - 601 views - 2.1 KB)
__________________

Last edited by LenHard; 06-25-2018 at 05:54.
LenHard is offline