AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] Why this message appears many times in chat? (https://forums.alliedmods.net/showthread.php?t=204362)

Shockblade 12-29-2012 14:36

[SOLVED] Why this message appears many times in chat?
 
Hello,
why in this function the message appears many times, when counter-terrorists win?

PHP Code:

public Event_SendAudio_CtsWin()
{
        for(new 
client FIRST_PLAYER_IDclient <= g_maxClientsclient++)
        {
                new 
Winner_XP get_pcvar_num(cvar_XP_Win)
            
                
/* if( IsUserConnected(client) && */
                
if( IsUserAuthorized(client) )
                {
                    if( 
cs_get_user_team(client) == CS_TEAM_CT )
                    {
                        
g_XP[client] += Winner_XP
                
                        
#if defined ADMIN_EXTRA_XP_WIN
                            
if( get_pcvar_num(cvar_Admin_Extra) && get_user_flags(client) & ADMIN_EXTRA )
                            {
                                
g_XP[client] += get_pcvar_num(cvar_Admin_Extra_XP)
                            }
                        
#endif
                    
}    
                    
Check_Level(client)
                }
                
client_print_color(0Blue"^4%s ^3Seekers ^1received ^4%i ^1XP for winning the round!"g_szPrefix, (get_pcvar_num(cvar_Admin_Extra) && get_user_flags(client) & ADMIN_EXTRA get_pcvar_num(cvar_Admin_Extra_XP) : 0) + Winner_XP)
        }



simanovich 12-29-2012 15:17

Re: Why this message appears many times in chat?
 
Post the register_event first

Shockblade 12-29-2012 15:54

Re: Why this message appears many times in chat?
 
...
I want to fix the function only... In my plugin there is register_event.

pokemonmaster 12-29-2012 16:01

Re: Why this message appears many times in chat?
 
Look closer, you are printing a chat message in a loop ... try to get it out of it, then it will work fine.

fysiks 12-29-2012 16:03

Re: Why this message appears many times in chat?
 
No, he is printing to everybody on every loop with user specific information. He should print the message to each individual player with user specific information.

Shockblade 12-29-2012 16:11

Re: Why this message appears many times in chat?
 
I tried to put message in the if( IsUserAuthorized(client) ) function and again it appears many times...

fysiks 12-29-2012 16:15

Re: Why this message appears many times in chat?
 
Quote:

Originally Posted by Shockblade (Post 1862958)
I tried to put message in the if( IsUserAuthorized(client) ) function and again it appears many times...

It's because you are printing it for everybody on every loop.

Shockblade 12-29-2012 16:16

Re: Why this message appears many times in chat?
 
how can I fix it?

fysiks 12-29-2012 16:26

Re: Why this message appears many times in chat?
 
Quote:

Originally Posted by Shockblade (Post 1862963)
how can I fix it?

Print the message only to the individual player ("client").

Shockblade 12-29-2012 16:36

Re: Why this message appears many times in chat?
 
Ok, but I want and the other team to see that message. How can I make that without problems?


All times are GMT -4. The time now is 13:46.

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