Raised This Month: $12 Target: $400
 3% 

Join server sound not work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheBOSS
Member
Join Date: Nov 2018
Old 09-21-2019 , 03:48   Join server sound not work
Reply With Quote #1

I make this plugin to play sound when player join server, but not work.
[CSGO]
what problem?

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <clientprefs>

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo =
{
    
name "Join Music",
    
author "TheBO$$",
    
description "Join server music",
    
version "1.0"
};

Handle g_JM_Cookie null;
Handle g_JM_Volume_Cookie null;

public 
void OnPluginStart()
{

    
g_JM_Cookie RegClientCookie("join_server_sound""Join Music On/Off"CookieAccess_Private);
    
g_JM_Volume_Cookie RegClientCookie("join_music_volume""join Music volume"CookieAccess_Private);
    
    
SetCookieMenuItem(SoundCookieHandler0"Join Server Music");    
    
    
LoadTranslations("joinmusic.phrases.txt");
    
    
HookEvent("player_spawn"Event_PlayerSpawn);
    
    for(
int i 1<= MaxClientsi++)
    {
        if(
IsClientValid(i))
        {
            if(!
AreClientCookiesCached(i))
            {
                continue;
            }
            
OnClientCookiesCached(i);
        }    
    }    
}

public 
void OnMapStart()
{
    
AddFileToDownloadsTable("sound/joinmusic/privet.mp3");
    
PrecacheSound("joinmusic/privet.mp3");
}

public 
void OnClientCookiesCached(int client)
{
    if(
IsFakeClient(client))
        return;

    
GetIntCookie(clientg_JM_Cookie);
    
GetIntCookie(clientg_JM_Volume_Cookie);
}

public 
Action Event_PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));

    if(!
IsClientValid(client))
        return;
    else
        
JoinServerPlayMusic();
}

public 
void SoundCookieHandler(int clientCookieMenuAction actionany infochar[] bufferint maxlen)
{
    
JoinMusicMenu(client0);
}

public 
Action JoinMusicMenu(int clientint args)
{    
    
int cookievalue GetIntCookie(clientg_JM_Cookie);
    
Handle g_CookieMenu CreateMenu(JoinMusicMenuHandler);
    
SetMenuTitle(g_CookieMenu"Join Server Music");
    
char Item[128];
    if(
cookievalue == 0)
    {
        
Format(Itemsizeof(Item), "%t %t""JOINMUSIC_ON""SELECTED"); 
        
AddMenuItem(g_CookieMenu"ON"Item);
        
Format(Itemsizeof(Item), "%t""JOINMUSIC_OFF"); 
        
AddMenuItem(g_CookieMenu"OFF"Item);
    }
    else
    {
        
Format(Itemsizeof(Item), "%t""JOINMUSIC_ON");
        
AddMenuItem(g_CookieMenu"ON"Item);
        
Format(Itemsizeof(Item), "%t %t""JOINMUSIC_OFF""SELECTED"); 
        
AddMenuItem(g_CookieMenu"OFF"Item);
    }

    
Format(Itemsizeof(Item), "%t""VOLUME");
    
AddMenuItem(g_CookieMenu"volume"Item);


    
SetMenuExitBackButton(g_CookieMenutrue);
    
SetMenuExitButton(g_CookieMenutrue);
    
DisplayMenu(g_CookieMenuclient30);
    return 
Plugin_Continue;
}

public 
int JoinMusicMenuHandler(Handle menuMenuAction actionint clientint param2)
{
    
Handle g_CookieMenu CreateMenu(JoinMusicMenuHandler);
    if (
action == MenuAction_DrawItem)
    {
        return 
ITEMDRAW_DEFAULT;
    }
    else if(
param2 == MenuCancel_ExitBack)
    {
        
ShowCookieMenu(client);
    }
    else if (
action == MenuAction_Select)
    {
        switch (
param2)
        {
            case 
0:
            {
                
SetClientCookie(clientg_JM_Cookie"0");
                
JoinMusicMenu(client0);
            }
            case 
1:
            {
                
SetClientCookie(clientg_JM_Cookie"1");
                
JoinMusicMenu(client0);
            }
            case 
2
            {
                
VolumeMenu(client);
            }            
        }
        
CloseHandle(g_CookieMenu);
    }
    else if(
action == MenuAction_End)
    {
        
delete menu;
    }
    return 
0;
}

void VolumeMenu(int client){
    

    
float volumeArray[] = { 1.00.750.500.250.10 };
    
float selectedVolume GetClientVolume(client);

    
Menu volumeMenu = new Menu(VolumeMenuHandler);
    
volumeMenu.SetTitle("%t""JMVOLUME");
    
volumeMenu.ExitBackButton true;

    for(
int i 0sizeof(volumeArray); i++)
    {
        
char strInfo[10];
        
Format(strInfosizeof(strInfo), "%0.2f"volumeArray[i]);

        
char display[20], selected[5];
        if(
volumeArray[i] == selectedVolume)
            
Format(selectedsizeof(selected), "%t""SELECTED");

        
Format(displaysizeof(display), "%s %s"strInfoselected);

        
volumeMenu.AddItem(strInfodisplay);
    }

    
volumeMenu.Display(clientMENU_TIME_FOREVER);
}

public 
int VolumeMenuHandler(Menu menuMenuAction actionint clientint param2)
{
    if(
action == MenuAction_Select){
        
char sInfo[10];
        
GetMenuItem(menuparam2sInfosizeof(sInfo));
        
SetClientCookie(clientg_JM_Volume_CookiesInfo);
        
VolumeMenu(client);
    }
    else if(
param2 == MenuCancel_ExitBack)
    {
        
JoinMusicMenu(client0);
    }
    else if(
action == MenuAction_End)
    {
        
delete menu;
    }
}

public 
Action JoinServerPlayMusic()
{
    for (
int  i 1<= MaxClientsi++)
    {
        if(
IsClientValid(i) && GetIntCookie(ig_JM_Cookie) == 0)
        {
            
float selectedVolume GetClientVolume(i);
            
EmitSoundToClient(i"joinmusic/privet.mp3"____selectedVolume______);  
        }
    }
}

int GetIntCookie(int clientHandle handle)
{
    
char sCookieValue[11];
    
GetClientCookie(clienthandlesCookieValuesizeof(sCookieValue));
    return 
StringToInt(sCookieValue);
}

float GetClientVolume(int client){
    
float defaultVolume 0.75;

    
char sCookieValue[11];
    
GetClientCookie(clientg_JM_Volume_CookiesCookieValuesizeof(sCookieValue));

    if(
StrEqual(sCookieValue"") || StrEqual(sCookieValue"0"))
        
Format(sCookieValue sizeof(sCookieValue), "%0.2f"defaultVolume);

    return 
StringToFloat(sCookieValue);
}


stock bool IsClientValid(int client)
{
    if (
client >= && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client))
        return 
true;
    return 
false;


Last edited by DarkDeviL; 09-22-2019 at 00:20. Reason: Merge bumps/multi-posting
TheBOSS is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 09-21-2019 , 13:49   Re: Join server sound not work
Reply With Quote #2

What game?
Maxximou5 is offline
TheBOSS
Member
Join Date: Nov 2018
Old 09-21-2019 , 15:23   Re: Join server sound not work
Reply With Quote #3

Quote:
Originally Posted by Maxximou5 View Post
What game?
CSGO
TheBOSS is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 09-28-2019 , 06:17   Re: Join server sound not work
Reply With Quote #4

https://forums.alliedmods.net/showthread.php?t=315145

Check description and emitsound snippet.
Maybe, something will be helpful for you.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Reply


Thread Tools
Display Modes

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 19:14.


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