Raised This Month: $32 Target: $400
 8% 

[BUG] - Welcome Sound


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Yusochan
Member
Join Date: Sep 2021
Location: Algeria
Old 12-08-2021 , 16:10   [BUG] - Welcome Sound
Reply With Quote #1

Hello !

When i join the server the sound doesn't play..

Code:
#include <amxmodx>

new const szPLUGIN[] = "Welcome kho", szVERSION[] = "2.0", szAUTHOR[] = "YusoChan-";

new const szWelcome[] = "sound/misc/welcome.wav";

public plugin_init() {
	
	register_plugin(szPLUGIN, szVERSION, szAUTHOR);
}

public client_connect(id) {
	set_task(3.0, "Welcome", id);
}

public plugin_precache()
{
	precache_sound(szWelcome);
}

public Welcome(id)
{
	if(is_user_connected(id)) {
		client_cmd(id, "spk welcome.wav", szWelcome);
	}
}
__________________
<b>IP : <font color=Red>93.115.53.168:27017</font></b>
<b>Founder : <font color=Cyan>YusoChan-</font></b>
Yusochan is offline
SHIFT0
Senior Member
Join Date: Apr 2021
Location: Palestine
Old 12-08-2021 , 16:45   Re: [BUG] - Welcome Sound
Reply With Quote #2

Quote:
Originally Posted by Yusochan View Post
Hello !

When i join the server the sound doesn't play..

Code:
#include <amxmodx>

new const szPLUGIN[] = "Welcome kho", szVERSION[] = "2.0", szAUTHOR[] = "YusoChan-";

new const szWelcome[] = "sound/misc/welcome.wav";

public plugin_init() {
	
	register_plugin(szPLUGIN, szVERSION, szAUTHOR);
}

public client_connect(id) {
	set_task(3.0, "Welcome", id);
}

public plugin_precache()
{
	precache_sound(szWelcome);
}

public Welcome(id)
{
	if(is_user_connected(id)) {
		client_cmd(id, "spk welcome.wav", szWelcome);
	}
}

PHP Code:
#include <amxmodx>

// change this number to the amount of sounds u have
#define Maxsounds 2

// add here your sounds, sounds must be somewhere in <ModDir>/sound
// format must be like: {"misc/sound1","ambience/sound2"}
new soundlist[Maxsounds][] = {"misc/welcome""misc/prepare"}

new 
plugin_author[] = "White Panther"
new plugin_version[] = "1.2.3"

public plugin_init( )
{
    
register_plugin("Connect Sound"plugin_versionplugin_author)
    
register_cvar("connectsound_version"plugin_versionFCVAR_SERVER)
}

public 
plugin_precache( )
{
    new 
temp[128], soundfile[128]
    for ( new 
0Maxsoundsa++ )
    {
        
format(temp127"sound/%s.wav"soundlist[a])
        if ( 
file_exists(temp) )
        {
            
format(soundfile127"%s.wav"soundlist[a])
            
precache_sound(soundfile)
        }
    }
}

public 
client_putinserverid )
{
    
set_task(1.0"consound"100 id)
}

public 
consoundtimerid_id )
{
    new 
id timerid_id 100
    
new Usertime
    Usertime 
get_user_time(id0)
    if ( 
Usertime <= )
    {
        
set_task(1.0"consound"timerid_id)
    }else
    {
        new 
random(Maxsounds)
        
client_cmd(id"spk ^"%s^""soundlist[i])
    }
    
    return 
PLUGIN_CONTINUE

SHIFT0 is offline
Yusochan
Member
Join Date: Sep 2021
Location: Algeria
Old 12-08-2021 , 17:56   Re: [BUG] - Welcome Sound
Reply With Quote #3

Mate :/ are u okay ?
__________________
<b>IP : <font color=Red>93.115.53.168:27017</font></b>
<b>Founder : <font color=Cyan>YusoChan-</font></b>
Yusochan is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-09-2021 , 15:56   Re: [BUG] - Welcome Sound
Reply With Quote #4

1. client_connect() is called while the client is still connecting. Playing the sound 3 seconds after this doesn't guarantee that he is in the server and can hear the sound. It's best to use client_putinserver() for this which is called when the client enters the game.

2. You defined your path as "sound/misc/welcome.wav" but you're playing "welcome.wav" which defaults to the "sound" folder. You're not using the "szWelcome" variable there.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 12-09-2021 , 16:48   Re: [BUG] - Welcome Sound
Reply With Quote #5

Replace
Code:
is_user_connected()
with
Code:
is_user_connecting()
http://www.amxmodx.org/api/amxmodx/is_user_connecting
http://www.amxmodx.org/api/amxmodx/is_user_connected

And what said OciXCrom at 2nd point.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 12-09-2021 at 16:48.
Shadows Adi is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-10-2021 , 02:24   Re: [BUG] - Welcome Sound
Reply With Quote #6

If he does that then it won't work if the player has connected which is very likely to happen when changing the forward.
__________________

Last edited by OciXCrom; 12-10-2021 at 02:24.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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 20:04.


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