Raised This Month: $ Target: $400
 0% 

How work this is_user_connected (Need some Help)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-26-2011 , 17:20   How work this is_user_connected (Need some Help)
Reply With Quote #1

Hi

Is it correct.
I want this, if player connecting on server then this client_cmd "mp3 play"
Not work for him like if client connect then no sounds play only loading sound plugin.

Here is my code.
PHP Code:
 
// Plays a sound on clients
PlaySound_Mp3(const sound[] , id)
{
 if (!
is_user_connected(id))
 
client_cmd(0"mp3 play ^"sound/%s^""sound)
}
PlayMP3Sound(const soundMP3[])
{
 if (!
is_user_connected(0)) 
 
client_cmd(0"mp3 play ^"sound/%s^""soundMP3)

Is this works same like i want ?
.Dare Devil. is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 04-26-2011 , 17:38   Re: How work this is_user_connected (Need some Help)
Reply With Quote #2

.Dare Devil.
The "!" means "NOT". if (!is_user_connected(id)) means "if client #id NOT connected". if (!is_user_connected(0)) statement has no meaning, because there is no player #0. Player numbers are from 1 to get_maxplayers(). 0 used as "all players" "server" and "worldspawn" in some functions, but in most cases it means "no value", "not found" or "error".

Quote:
I want this, if player connecting on server then this client_cmd "mp3 play"
Ancient and one of my favourite plugins:
PHP Code:
Play a sound during the connection.
*
Random code part taken from plugin
connectsound by White Panther
*
v1.0
*
*/

#include <amxmodx>

// sounds localized in gcf cache (valve/media)
// you can add more song if you want.
new soundlist[][] = {"Half-Life01","Half-Life02","Half-Life04","Half-Life12","Half-Life13","Half-Life17"}

public 
client_connect(id)
    
client_cmd(id,"mp3 play media/%s",soundlist[random_num(0charsmax(soundlist))])

public 
plugin_init()
    
register_plugin("Loading Sound","1.0","Amxx User"
Just 2 functions, 5 lines and yet so usefull <3
__________________


Last edited by SonicSonedit; 04-26-2011 at 17:46.
SonicSonedit is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-26-2011 , 18:13   Re: How work this is_user_connected (Need some Help)
Reply With Quote #3

I mean this code is like i want

PHP Code:
 
PlaySound_Mp3
(const sound[] , id)
{
 if (!
is_user_connected(id))
 
client_cmd(0"mp3 play ^"sound/%s^""sound)

When userd connecting or loading ( he are not yet on server. Loading ... ) or download models or sounds then playSound_Mp3 Dont work for this client who was loading or download items.
.Dare Devil. is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 04-26-2011 , 18:22   Re: How work this is_user_connected (Need some Help)
Reply With Quote #4

PHP Code:
PlaySound_Mp3(const sound[] , id)
{
 if (!
is_user_connected(id))
 
client_cmd(0"mp3 play ^"sound/%s^""sound)

1) coded incorrectly
2) does nothing
3) use code from post #2
__________________

SonicSonedit is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-27-2011 , 01:39   Re: How work this is_user_connected (Need some Help)
Reply With Quote #5

You mean this
PHP Code:
 
PlayMP3Sound
(const soundMP3[])
{
 if (!
is_user_connected(0)) 
 
client_cmd(0"mp3 play ^"sound/%s^""soundMP3)

When yes thanks you soo much.
it was very important for me...
.Dare Devil. is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-27-2011 , 02:40   Re: How work this is_user_connected (Need some Help)
Reply With Quote #6

You have to loop all players.

PHP Code:
PlaySound_Mp3(const szSound[] , id)
{
    if( 
id )
    {
        if( 
is_user_connected(id) && !is_user_connecting(id) )
        {
            
client_cmd(id"mp3 play %s"szSound)
        }
    }
    else
    {
        new 
iPlayers[32], iNum
        get_players
(iPlayersiNum"c")
        for(--
iNumiNum>=0iNum--)
        {
            
id iPlayers[iNum]
            if( !
is_user_connecting(id) )
            {
                
client_cmd(id"mp3 play %s"szSound)
            }
        }
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-27-2011 , 05:08   Re: How work this is_user_connected (Need some Help)
Reply With Quote #7

Quote:
Originally Posted by ConnorMcLeod View Post
You have to loop all players.

PHP Code:
PlaySound_Mp3(const szSound[] , id)
{
    if( 
id )
    {
        if( 
is_user_connected(id) && !is_user_connecting(id) )
        {
            
client_cmd(id"mp3 play %s"szSound)
        }
    }
    else
    {
        new 
iPlayers[32], iNum
        get_players
(iPlayersiNum"c")
        for(--
iNumiNum>=0iNum--)
        {
            
id iPlayers[iNum]
            if( !
is_user_connecting(id) )
            {
                
client_cmd(id"mp3 play %s"szSound)
            }
        }
    }

Thanks.
.Dare Devil. is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-27-2011 , 09:49   Re: How work this is_user_connected (Need some Help)
Reply With Quote #8

Now i done.
But is that correct what i done?

Call the play

PHP Code:
 
 
// Play it on clients
 
if (ismp3)
  
PlaySound_Mp3(sound id)
 else
  
PlaySound(sound)
 
 
// Set the task for when the sound is done playing
 
set_task(float(duration), "ambience_sound_effects"TASK_AMBIENCESOUNDS
PHP Code:
 
  
// Play win sound and increase score
  
ArrayGetString(sound_win_humansrandom_num(0ArraySize(sound_win_humans) - 1), soundMP3charsmax(soundMP3))
  
PlayMP3Sound(soundMP3id)
  
g_scorehumans++ 
And Now.

PHP Code:
 
PlaySound_Mp3
(const sound[] , id

    if( 
id 
    { 
        if( 
is_user_connected(id) && !is_user_connecting(id) ) 
        { 
            
client_cmd(id"mp3 play ^"sound/%s^""sound
        } 
    } 
    else 
    { 
        new 
iPlayers[32], iNum 
        get_players
(iPlayersiNum"c"
        for(--
iNumiNum>=0iNum--) 
        { 
            
id iPlayers[iNum
            if( !
is_user_connecting(id) ) 
            { 
                
client_cmd(id"mp3 play ^"sound/%s^""sound 
            } 
        } 
    } 

PlayMP3Sound(const soundMP3[] , id

    if( 
id 
    { 
        if( 
is_user_connected(id) && !is_user_connecting(id) ) 
        { 
            
client_cmd(id"mp3 play ^"sound/%s^""soundMP3
        } 
    } 
    else 
    { 
        new 
iPlayers[32], iNum 
        get_players
(iPlayersiNum"c"
        for(--
iNumiNum>=0iNum--) 
        { 
            
id iPlayers[iNum
            if( !
is_user_connecting(id) ) 
            { 
                
client_cmd(id"mp3 play ^"sound/%s^""soundMP3 )
            } 
        } 
    } 

.Dare Devil. is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-27-2011 , 14:53   Re: How work this is_user_connected (Need some Help)
Reply With Quote #9

Why do you have 2 functions that do the exact same thing?

Use one of those in all places where both are used and then delete the one you didn't use.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-27-2011 , 16:01   Re: How work this is_user_connected (Need some Help)
Reply With Quote #10

Quote:
Originally Posted by Exolent[jNr] View Post
Why do you have 2 functions that do the exact same thing?

Use one of those in all places where both are used and then delete the one you didn't use.
Some items not working when i do this way.
.Dare Devil. 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 04:20.


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