AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How do i show the messages only for my team? (https://forums.alliedmods.net/showthread.php?t=184084)

Bilal Pro 04-30-2012 16:50

How do i show the messages only for my team?
 
Hello there,

How can i show messages to only my team, i tryed:

PHP Code:

if (get_user_team(id) == 1)
{
    
ColorChat(0GREY"Only terrorists are suppose to see this message!")
}
else if (
get_user_team(id) == 2)
{
    
ColorChat(0GREY"Only counter terrorists are suppose to see this message!")


Am i doing this right?

Liverwiz 04-30-2012 16:54

Re: How do i show the messages only for my team?
 
looks right to me. though i'd suggest adding in another one in case they're talking from spec. That is, if your server and logic allows.

Bilal Pro 04-30-2012 17:19

Re: How do i show the messages only for my team?
 
are you sure this is fine?

fysiks 04-30-2012 17:19

Re: How do i show the messages only for my team?
 
Quote:

Originally Posted by Bilal Pro (Post 1699505)
Hello there,

How can i show messages to only my team, i tryed:

PHP Code:

if (get_user_team(id) == 1)
{
    
ColorChat(0GREY"Only terrorists are suppose to see this message!")
}
else if (
get_user_team(id) == 2)
{
    
ColorChat(0GREY"Only counter terrorists are suppose to see this message!")


Am i doing this right?

No. In both cases you are sending it to everybody (that's what 0 means!). You have to loop through all players and if they are on the team that you want to see the message then show the message.

Bilal Pro 04-30-2012 17:24

Re: How do i show the messages only for my team?
 
How will i check if they are on my team?

Bilal Pro 04-30-2012 17:38

Re: How do i show the messages only for my team?
 
i didn't come further then this..

PHP Code:

new players[32], pnum
get_players
(playerspnum"ae""TERRORIST")

for (new 
ii<pnumi++)



fysiks 04-30-2012 17:42

Re: How do i show the messages only for my team?
 
Quote:

Originally Posted by Bilal Pro (Post 1699527)
How will i check if they are on my team?

Wow, these questions . . .

Use get_players() without flags then check their team and if it is the same as your team then show the message. Very simple.

Liverwiz 04-30-2012 17:59

Re: How do i show the messages only for my team?
 
Quote:

Originally Posted by Bilal Pro (Post 1699521)
are you sure this is fine?

Quote:

Originally Posted by fysiks (Post 1699522)
No. In both cases you are sending it to everybody (that's what 0 means!). You have to loop through all players and if they are on the team that you want to see the message then show the message.

Oh...i assumed you were just posting super-simple code.
go with what fysiks is telling you.

cheating, so you don't have to think:
PHP Code:

new players[32], p_playerCnt
get_players
(playersp_playerCnt"ch")

for(new 
i=1i<p_playerCnti++)
{
    if(
get_user_team(players[i]) == 1)
        
client_print_color(0DontChange"^3Only terrorists are suppose to see this message!")  //using DontChange will print the message in the team color. Just for fun. ^3 signifies to use team color
    
else if(get_user_team(players[i]) == 2)
        
client_print_color(0DontChange"^3Only counter terrorists are suppose to see this message!")
    else
        
client_print_color(0DontChange"^3Only spectators are suppose to see this message!")


I apologize for earlier. ColorChat isn't a function, its an include file.

Bilal Pro 04-30-2012 18:10

Re: How do i show the messages only for my team?
 
PHP Code:

        new players[32], pnum
        get_players
(playerspnum"ch")
        
        for (new 
ii<pnumi++)
        {  
            if (
get_user_team(players[i]) == 1)
            {
                if (
is_user_alive(id))
                {
                    if (
get_user_flags(id) & ADMIN_MENU)
                    {
                        
ColorChat(0RED"^1(Terrorists) ^3%s^1 :  ^4%s"namemessage)
                        return 
PLUGIN_HANDLED
                    
}
                    else
                    {
                        
ColorChat(0RED"^1(Terrorists) ^3%s^1 :  ^1%s"namemessage)
                        return 
PLUGIN_HANDLED
                    
}
                }
                if (!
is_user_alive(id))
                {
                    if (
get_user_flags(id) & ADMIN_MENU)
                    {
                        
ColorChat(0RED"^1(Terrorists) ^1*DEAD* ^3%s^1 :  ^4%s"namemessage)
                        return 
PLUGIN_HANDLED
                    
}
                    else
                    {
                        
ColorChat(0RED"^1(Terrorists) ^1*DEAD* ^3%s^1 :  ^1%s"namemessage)
                        return 
PLUGIN_HANDLED
                    
}
                }
            }
            
            if (
get_user_team(players[i]) == 2)
            {
                if (
is_user_alive(id))
                {
                    if (
get_user_flags(id) & ADMIN_MENU)
                    {
                        
ColorChat(0BLUE"^1(Counter-Terrorists) ^3%s^1 :  ^4%s"namemessage)
                        return 
PLUGIN_HANDLED
                    
}
                    else
                    {
                        
ColorChat(0BLUE"^1(Counter-Terrorists) ^3%s^1 :  ^1%s"namemessage)
                        return 
PLUGIN_HANDLED
                    
}
                }
                if (!
is_user_alive(id))
                {
                    if (
get_user_flags(id) & ADMIN_MENU)
                    {
                        
ColorChat(0BLUE"^1(Counter-Terrorists) *DEAD* ^3%s^1 :  ^4%s"namemessage)
                        return 
PLUGIN_HANDLED
                    
}
                    else
                    {
                        
ColorChat(0BLUE"^1(Counter-Terrorists) *DEAD* ^3%s^1 :  ^1%s"namemessage)
                        return 
PLUGIN_HANDLED
                    
}
                }
            }
            if (
get_user_team(players[i]) == 0)
            {
                if (
get_user_flags(id) & ADMIN_MENU)
                {
                    
ColorChat(0GREY"^1(Spectator) *SPECTATOR* ^3%s^1 :  ^4%s"namemessage)
                    return 
PLUGIN_HANDLED
                
}
                else
                {
                    
ColorChat(0GREY"^1(Spectator) *SPECTATOR* ^3%s^1 :  ^1%s"namemessage)
                    return 
PLUGIN_HANDLED
                
}
            }
        }
        
    }
    return 
PLUGIN_HANDLED


Doesn't work still shows for everyone.

Liverwiz 04-30-2012 18:38

Re: How do i show the messages only for my team?
 
I suck, my mind is on other thing, sorry to confuse you. instead of using 0, use players[i]

0 prints to EVERYONE
you need to specify the ID of the person you want to print to. That is why you're doing this complicated for loop bullshit.


All times are GMT -4. The time now is 07:42.

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