AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Say / Say_Team (https://forums.alliedmods.net/showthread.php?t=163060)

Dr7sTyLe 07-26-2011 09:35

Say / Say_Team
 
I tried making the message that player writes with the colors and stuff as i like:
PHP Code:

#include <amxmodx>
#include <colorchat>

public plugin_init()
{
    
register_clcmd("say","handle_say")
    
register_clcmd("say_team","handle_sayteam")
}
public 
handle_say(id)
{
    new 
szArg[192]
    new 
name[32]
    
read_args(szArg,charsmax(szArg))
    
get_user_name(id,name,31)
    
remove_quotes(szArg)
    
ColorChat(0,RED,"%s^x04 :^x01 %s.",name,szArg)
}
public 
handle_sayteam(id)
{
    new 
szArg[192]
    
read_args(szArg,charsmax(szArg))
    
remove_quotes(szArg)
    if(
get_user_team(id) == 1)
    {
        new 
players[32], pnumtempid
        new 
szName[32], szTempid[10]; 
        
get_user_name(id,szName,31)
        
get_players(playerspnum"a"); 
        for( new 
ii<pnumi++ ) 
        { 
            
tempid players[i];
            
get_user_name(tempidszName31); 
            
num_to_str(tempidszTempid9);
        } 
        
ColorChat(tempid,RED,"[^x04 Team^x03 ]^x01 %s^x04 :^x01 %s.",szName,szArg)
    }
    if(
get_user_team(id) == 2)
    {
        new 
players[32], pnumtempid
        new 
szName[32], szTempid[10]; 
        
get_user_name(id,szName,31)
        
get_players(playerspnum"a"); 
        for( new 
ii<pnumi++ ) 
        { 
            
tempid players[i];
            
get_user_name(tempidszName31); 
            
num_to_str(tempidszTempid9);
        } 
        
ColorChat(tempid,BLUE,"[^x04 Team^x03 ]^x01 %s^x04 :^x01 %s.",szName,szArg)
    }


but im having problem with the say_team i want it to show the message only for the users team.

One 07-26-2011 09:50

Re: Say / Say_Team
 
check first in which team your user is ( writer ).
exaple :
PHP Code:

if(get_user_team(id) == 1)
{
while....
if(
get_user_team(tempid) == 1)
{
//show the msg


Ps. i would use switches...

r0ck 07-26-2011 09:50

Re: Say / Say_Team
 
TRY THIS ?
PHP Code:


#include <amxmodx> 
#include <colorchat> 

public plugin_init() 

    
register_clcmd("say","handle_say"
    
register_clcmd("say_team","handle_sayteam"

public 
handle_say(id

    new 
szArg[192
    new 
name[32
    
read_args(szArg,charsmax(szArg)) 
    
get_user_name(id,name,31
    
remove_quotes(szArg
    
ColorChat(0,RED,"%s^x04 :^x01 %s.",name,szArg

public 
handle_sayteam(id

    new 
szArg[192
    
read_args(szArg,charsmax(szArg)) 
    
remove_quotes(szArg
    if(
get_user_team(id) == 1
    { 
        new 
players[32], pnumtempid;  
        new 
szName[32], szTempid[10];  
        
get_user_name(id,szName,31
        
get_players(playerspnum"ae""TERRORIST");  
        for( new 
ii<pnumi++ )  
        {  
            
tempid players[i]; 
            
get_user_name(tempidszName31);  
            
num_to_str(tempidszTempid9); 
        }  
        
ColorChat(tempid,RED,"[^x04 Team^x03 ]^x01 %s^x04 :^x01 %s.",szName,szArg
    } 
    if(
get_user_team(id) == 2
    { 
        new 
players[32], pnumtempid;  
        new 
szName[32], szTempid[10];  
        
get_user_name(id,szName,31
        
get_players(playerspnum"ae""CT");  
        for( new 
ii<pnumi++ )  
        {  
            
tempid players[i]; 
            
get_user_name(tempidszName31);  
            
num_to_str(tempidszTempid9); 
        }  
        
ColorChat(tempid,BLUE,"[^x04 Team^x03 ]^x01 %s^x04 :^x01 %s.",szName,szArg
    } 



Dr7sTyLe 07-26-2011 09:56

Re: Say / Say_Team
 
Quote:

Originally Posted by r0ck (Post 1518869)
TRY THIS ?
PHP Code:


#include <amxmodx> 
#include <colorchat> 

public plugin_init() 

    
register_clcmd("say","handle_say"
    
register_clcmd("say_team","handle_sayteam"

public 
handle_say(id

    new 
szArg[192
    new 
name[32
    
read_args(szArg,charsmax(szArg)) 
    
get_user_name(id,name,31
    
remove_quotes(szArg
    
ColorChat(0,RED,"%s^x04 :^x01 %s.",name,szArg

public 
handle_sayteam(id

    new 
szArg[192
    
read_args(szArg,charsmax(szArg)) 
    
remove_quotes(szArg
    if(
get_user_team(id) == 1
    { 
        new 
players[32], pnumtempid;  
        new 
szName[32], szTempid[10];  
        
get_user_name(id,szName,31
        
get_players(playerspnum"ae""TERRORIST");  
        for( new 
ii<pnumi++ )  
        {  
            
tempid players[i]; 
            
get_user_name(tempidszName31);  
            
num_to_str(tempidszTempid9); 
        }  
        
ColorChat(tempid,RED,"[^x04 Team^x03 ]^x01 %s^x04 :^x01 %s.",szName,szArg
    } 
    if(
get_user_team(id) == 2
    { 
        new 
players[32], pnumtempid;  
        new 
szName[32], szTempid[10];  
        
get_user_name(id,szName,31
        
get_players(playerspnum"ae""CT");  
        for( new 
ii<pnumi++ )  
        {  
            
tempid players[i]; 
            
get_user_name(tempidszName31);  
            
num_to_str(tempidszTempid9); 
        }  
        
ColorChat(tempid,BLUE,"[^x04 Team^x03 ]^x01 %s^x04 :^x01 %s.",szName,szArg
    } 



k i will try it later.
but it wont show the users normal message without the colors right ?

Dr7sTyLe 07-26-2011 13:55

Re: Say / Say_Team
 
Quote:

Originally Posted by Dr7sTyLe (Post 1518872)
k i will try it later.
but it wont show the users normal message without the colors right ?

Help Me Please It Shows Both The Normal message ani my plugins message help pls ?

One 07-26-2011 14:15

Re: Say / Say_Team
 
you have to return the normal msg :)

Dr7sTyLe 07-26-2011 14:53

Re: Say / Say_Team
 
Quote:

Originally Posted by One (Post 1519073)
you have to return the normal msg :)

i know i already fixed that but another problem.
if i write something in say_team im the only person who see it -_-

fysiks 07-26-2011 16:08

Re: Say / Say_Team
 
Probably because you copied code from a menu.
All of your color chats are not in any loop.

PHP Code:

loop through players
    
if player has the same team as "id"
        
show the message
endloop 


One 07-26-2011 16:35

Re: Say / Say_Team
 
or :

PHP Code:

function ()
{
    
check users team
    
    
switch teams
    
{
        case 
team T =
        
make a loop between all users in the same team
        
{
            
show the message to the users  and return the standard msg
        
}
        
        case 
team CT =
        
make a loop between all users in the same team TEAM 2 )
        {
            
show the message and return the standard msg
        
}
    }


:D

Dr7sTyLe 07-27-2011 02:52

Re: Say / Say_Team
 
Quote:

Originally Posted by fysiks (Post 1519180)
Probably because you copied code from a menu.
All of your color chats are not in any loop.

PHP Code:

loop through players
    
if player has the same team as "id"
        
show the message
endloop 


Quote:

Originally Posted by One (Post 1519192)
or :

PHP Code:

function ()
{
    
check users team
    
    
switch teams
    
{
        case 
team T =
        
make a loop between all users in the same team
        
{
            
show the message to the users  and return the standard msg
        
}
        
        case 
team CT =
        
make a loop between all users in the same team TEAM 2 )
        {
            
show the message and return the standard msg
        
}
    }


:D

Yeah thank you both,but someoone already explained me what was wrong :]


All times are GMT -4. The time now is 01:11.

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