Raised This Month: $ Target: $400
 0% 

stock ChatColor


  
 
 
Thread Tools Display Modes
Author Message
leonard19941
Veteran Member
Join Date: Jun 2011
Old 07-08-2012 , 08:58   stock ChatColor
#1

Bueno es una simple tonteria, pero igual si alguien quiere responder bien sino pasen del post.

Cual de los 3 stock, es mejor.

PHP Code:
stock ChatColoridszInput[ ], any:... )
{
    static 
iMsgId191 ];
    
vformatiMsgIdcharsmaxiMsgId ), szInput);

    
replace_alliMsgIdcharsmaxiMsgId ), "!y""^1" ); // Default Color
    
replace_alliMsgIdcharsmaxiMsgId ), "!g""^4" ); // Green Color
    
replace_alliMsgIdcharsmaxiMsgId ), "!team""^3" ); // Team Color
    
    
new iCount 1iPlayers32 ];
    
    if( 
id )
        
iPlayers] = id;
    else
        
get_playersiPlayersiCount"ch" );
    
    for( new 
0iCounti++ )
    {
        if( 
is_user_connectediPlayers] ) )
        {
            
message_beginMSG_ONE_UNRELIABLEg_iMsgSayText_iPlayers] );
            
write_byteiPlayers] );
            
write_stringiMsgId );
            
message_end( );
        }
    }

PHP Code:
stock ChatColoridszInput[ ], any:... )
{
    static 
iMsgId191 ];
    
vformatiMsgIdcharsmaxiMsgId ), szInput);

    
replace_alliMsgIdcharsmaxiMsgId ), "!y""^1" ); // Default Color
    
replace_alliMsgIdcharsmaxiMsgId ), "!g""^4" ); // Green Color
    
replace_alliMsgIdcharsmaxiMsgId ), "!team""^3" ); // Team Color
    
    
new iCount 1iPlayers32 ];
    
    if( 
id )
        
iPlayers] = id;
    else
        
get_playersiPlayersiCount"ch" );
    {
        for( new 
0iCounti++ )
        {
            if( 
is_user_connectediPlayers] ) )
            {
                
message_beginMSG_ONE_UNRELIABLEg_iMsgSayText_iPlayers] );
                
write_byteiPlayers] );
                
write_stringiMsgId );
                
message_end( );
            }
        }
    }

PHP Code:
stock ChatColoridszInput[ ], any:... )
{
    static 
iMsgId191 ];
    
vformatiMsgIdcharsmaxiMsgId ), szInput);

    
replace_alliMsgIdcharsmaxiMsgId ), "!y""^1" ); // Default Color
    
replace_alliMsgIdcharsmaxiMsgId ), "!g""^4" ); // Green Color
    
replace_alliMsgIdcharsmaxiMsgId ), "!team""^3" ); // Team Color
    
    
new iCount 1iPlayers32 ];
    
    if( 
id )
        
iPlayers] = id;
    else
    {
        
get_playersiPlayersiCount"ch" );
        {
            for( new 
0iCounti++ )
            {
                if( 
is_user_connectediPlayers] ) )
                {
                    
message_beginMSG_ONE_UNRELIABLEg_iMsgSayText_iPlayers] );
                    
write_byteiPlayers] )
                    
write_stringiMsgId )
                    
message_end( );
                }
            }
        }
    }

EDIT: Para que sirve esto:

any:...
__________________

Last edited by leonard19941; 07-08-2012 at 09:01.
leonard19941 is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 07-08-2012 , 10:01   Re: stock ChatColor
#2

El último , dudo que funcione , por lo menos si tiene un index definido, y el primero y segundo es exactamente lo mismo , solo varia lo que son los brackets. Porque preguntas si es mejor o no ?
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
p4rp4d30
Veteran Member
Join Date: Mar 2007
Old 07-08-2012 , 12:34   Re: stock ChatColor
#3

Toma usa este.

PHP Code:
enum Color
{
    
NORMAL 1// clients scr_concolor cvar color
    
GREEN// Green Color
    
TEAM_COLOR// Red, grey, blue
    
GREY// grey
    
RED// Red
    
BLUE// Blue
}

#define GRAY GREY

stock ChatColor(idColor:type, const msg[], any:...)
{
    new 
index = (id && is_user_connected(id)) ? id GetPlayer();
    if( !
index ) return;
    
    new 
MSG_Type = (index == id) ? MSG_ONE MSG_ALL;
    
    static 
message[192];
    
    switch(
type)
    {
        case 
NORMAL// clients scr_concolor cvar color
        
{
            
message[0] = 0x01;
        }
        case 
GREEN// Green
        
{
            
message[0] = 0x04;
        }
        default: 
// White, Red, Blue
        
{
            
message[0] = 0x03;
        }
    }
    
    
vformat(message[1], 190msg4);
    
    new 
szTeam[16], team get_user_team(indexszTeam15);
    new 
teaminfo;
    switch( 
type )
    {
        case 
RED:
        {
            if( 
team != teaminfo Team_Info(indexMSG_Type"TERRORIST");
        }
        case 
BLUE:
        {
            if( 
team != teaminfo Team_Info(indexMSG_Type"CT");
        }
        case 
GREY:
        {
            if( 
<= team <= teaminfo Team_Info(indexMSG_Type"SPECTATOR");
        }
    }

    
ShowColorMessage(indexMSG_Typemessage);
        
    if(
teaminfo)
    {
        
Team_Info(indexMSG_TypeszTeam);
    }
}

stock ShowColorMessage(idtypemessage[])
{
    static 
bool:saytext_used;
    static 
get_user_msgid_saytext;
    if(!
saytext_used)
    {
        
get_user_msgid_saytext get_user_msgid("SayText");
        
saytext_used true;
    }
    
message_begin(typeget_user_msgid_saytext_id);
    
write_byte(id)        
    
write_string(message);
    
message_end();    
}

stock Team_Info(idtypeteam[])
{
    static 
bool:teaminfo_used;
    static 
get_user_msgid_teaminfo;
    if(!
teaminfo_used)
    {
        
get_user_msgid_teaminfo get_user_msgid("TeamInfo");
        
teaminfo_used true;
    }
    
message_begin(typeget_user_msgid_teaminfo_id);
    
write_byte(id);
    
write_string(team);
    
message_end();
    return 
1;
}

stock GetPlayer()
{
    static 
maxplayers;
    if( !
maxplayers )
    {
        
maxplayers get_maxplayers();
    }
    
    for( new 
1<= maxplayersi++ )
    {
        if( 
is_user_connected(i) )
        {
            return 
i;
        }
    }
    
    return 
0;

Utilizacion:
PHP Code:
ChatColor(idGREY,"[AMXX]^x01 Hola soy Mamon"
Por default color de todo el texto es GREEN despues si qures hacer que solo 1 palabra tenga otro color entonces le espesificas.

Los any... significan "lo que sea" osea cualquier parámetro que querramos pasar para despues su uso que eso lo capta los parametros en un string como %s para mostrar el vlaor del parametro string o %d para mostrar parametros si el parametro contiene int.

Last edited by p4rp4d30; 07-08-2012 at 12:36.
p4rp4d30 is offline
shinoda
Spanish Moderator
Join Date: Nov 2009
Location: ag_crossfire
Old 07-08-2012 , 18:29   Re: stock ChatColor
#4

@leonard19941
Ninguno, ese stock es horroroso.
shinoda is offline
Send a message via MSN to shinoda Send a message via Skype™ to shinoda
leonard19941
Veteran Member
Join Date: Jun 2011
Old 07-08-2012 , 18:49   Re: stock ChatColor
#5

Quote:
Originally Posted by lucas_7_94 View Post
El último, dudo que funcione, por lo menos si tiene un index definido, y el primero y segundo es exactamente lo mismo, solo varia lo que son los brackets. Porque preguntas si es mejor o no ?
Vale pues el tercero lo doy por eliminado, pero nose si te fijaste, que en el segundo stock hay unos

brackets que ni idea porque estan alli, me podrias explicar eso, por favor.


Pues porque me sale 1 warning dependiendo del stock que ponga.


Quote:
Originally Posted by p4rp4d30 View Post
Toma usa este.

PHP Code:
enum Color
{
    
NORMAL 1// clients scr_concolor cvar color
    
GREEN// Green Color
    
TEAM_COLOR// Red, grey, blue
    
GREY// grey
    
RED// Red
    
BLUE// Blue
}

#define GRAY GREY

stock ChatColor(idColor:type, const msg[], any:...)
{
    new 
index = (id && is_user_connected(id)) ? id GetPlayer();
    if( !
index ) return;
    
    new 
MSG_Type = (index == id) ? MSG_ONE MSG_ALL;
    
    static 
message[192];
    
    switch(
type)
    {
        case 
NORMAL// clients scr_concolor cvar color
        
{
            
message[0] = 0x01;
        }
        case 
GREEN// Green
        
{
            
message[0] = 0x04;
        }
        default: 
// White, Red, Blue
        
{
            
message[0] = 0x03;
        }
    }
    
    
vformat(message[1], 190msg4);
    
    new 
szTeam[16], team get_user_team(indexszTeam15);
    new 
teaminfo;
    switch( 
type )
    {
        case 
RED:
        {
            if( 
team != teaminfo Team_Info(indexMSG_Type"TERRORIST");
        }
        case 
BLUE:
        {
            if( 
team != teaminfo Team_Info(indexMSG_Type"CT");
        }
        case 
GREY:
        {
            if( 
<= team <= teaminfo Team_Info(indexMSG_Type"SPECTATOR");
        }
    }

    
ShowColorMessage(indexMSG_Typemessage);
        
    if(
teaminfo)
    {
        
Team_Info(indexMSG_TypeszTeam);
    }
}

stock ShowColorMessage(idtypemessage[])
{
    static 
bool:saytext_used;
    static 
get_user_msgid_saytext;
    if(!
saytext_used)
    {
        
get_user_msgid_saytext get_user_msgid("SayText");
        
saytext_used true;
    }
    
message_begin(typeget_user_msgid_saytext_id);
    
write_byte(id)        
    
write_string(message);
    
message_end();    
}

stock Team_Info(idtypeteam[])
{
    static 
bool:teaminfo_used;
    static 
get_user_msgid_teaminfo;
    if(!
teaminfo_used)
    {
        
get_user_msgid_teaminfo get_user_msgid("TeamInfo");
        
teaminfo_used true;
    }
    
message_begin(typeget_user_msgid_teaminfo_id);
    
write_byte(id);
    
write_string(team);
    
message_end();
    return 
1;
}

stock GetPlayer()
{
    static 
maxplayers;
    if( !
maxplayers )
    {
        
maxplayers get_maxplayers();
    }
    
    for( new 
1<= maxplayersi++ )
    {
        if( 
is_user_connected(i) )
        {
            return 
i;
        }
    }
    
    return 
0;

Utilizacion:
PHP Code:
ChatColor(idGREY,"[AMXX]^x01 Hola soy Mamon"
Por default color de todo el texto es GREEN despues si qures hacer que solo 1 palabra tenga otro color entonces le espesificas.

Los any... significan "lo que sea" osea cualquier parámetro que querramos pasar para despues su uso que eso lo capta los parametros en un string como %s para mostrar el vlaor del parametro string o %d para mostrar parametros si el parametro contiene int.
Muchas gracias, por tu ayuda, pero la verdad para utilizar esos stock, prefiero utilizar el #include.


Quote:
Originally Posted by shinoda View Post
@leonard19941
Ninguno, ese stock es horroroso.

Alguno mejor ?

PD: No me digas que utilize el #include ya que no quiero utilizarlo, me refiero si hay otro stock mejor.
__________________
leonard19941 is offline
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 07-08-2012 , 19:16   Re: stock ChatColor
#6

usar un include o usar lo que te pasaron es lo mismo
__________________

www.amxmodx-es.com

Steam: Luchokoldo
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 07-08-2012 , 20:35   Re: stock ChatColor
#7

Es lo mismo que agregar comillas al final de code , es opcional, no hacen diferencia.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 07-08-2012 , 20:41   Re: stock ChatColor
#8

yo uso asi

PHP Code:
#define PLUGIN "Test"
#define VERSION "1.0"

printf(id"^x04[R]ak Acme Inc.-^x01 %s^x03 %s"PLUGINVERSION)

printf(id, const msg[], any:...) {
    
    static 
buffer[512], msg_SayText 0
    
    
if(!msg_SayText)
        
msg_SayText get_user_msgid("SayText")
        
    
vformat(buffercharsmax(buffer), msg3)
            
    
message_begin(MSG_ONE_UNRELIABLEmsg_SayText_id)
    
write_byte(id)
    
write_string(buffer)
    
message_end()
    

__________________

www.amxmodx-es.com

Steam: Luchokoldo
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 07-08-2012 , 21:43   Re: stock ChatColor
#9

Quote:
Originally Posted by ConnorMcLeod View Post
ChatColor stock is horrible, re-consider it.
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
p4rp4d30
Veteran Member
Join Date: Mar 2007
Old 07-09-2012 , 00:54   Re: stock ChatColor
#10

usar chatcolor esta mal pero tampoco es para tanto... yo lo uso al sock que tengo yo y funciona joya nunca tube 1 problema y funciona bien

lo que diga connor obviamente dce qe si queremos usar chatcolor lo mejor es usar la forma de MODULE...

Pero en el caso de que tengamos error de algun tipo con algun plugin con el de stock usemos las otras formas menos las de stock...

el stock que te pase yo simplemente ponelo en un archivo llamalo colorchat.inc ponelo con include en tu plugin que ademas te ahorras lineas de poner el stock en el plugin directo... al pedo xD ya que yo todas las funciones que hice para mis necesidades estan en stock y en .inc las instanseo cuando quiero.

y listo la mejor forma de stock es la que tengo yo... mucho buscar y etc salio esa

salu2
p4rp4d30 is offline
 



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 11:22.


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