Raised This Month: $32 Target: $400
 8% 

[Inc/Stock] Printf


  
 
 
Thread Tools Display Modes
Author Message
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 08-30-2012 , 05:44   [Inc/Stock] Printf
#1

Hola como todos sabrán, existen stock o includes para mandar un mensaje con color, bueno.. no me gusta ninguno así que me arme este xD; soporta todos los colores.. aca les dejo unas imágenes

  • Imágenes


Spoiler


  • Inc.-


Spoiler


  • Stock


Spoiler


  • Ejemplo con Include


PHP Code:
#include <amxmodx>
#include <printf>

#define PLUGIN "Test Stock Chat Color"
#define VERSION "1.0"
#define AUTHOR "[R]ak"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say test""cmdTest")
    
    
register_clcmd("say test2""cmdTest2")

}

public 
cmdTest(id) {
    
    
printf(id, DEFAULT, "%s Acme Inc.- %s"AUTHORPLUGIN// comun
    
    
printf(idRED"%s Acme Inc.- %s"AUTHORPLUGIN// rojo
    
    
printf(idBLUE"%s Acme Inc.- %s"AUTHORPLUGIN// azul
    
    
printf(idGRAY"%s Acme Inc.- %s"AUTHORPLUGIN// gris
    
    
printf(idGREEN"^%s Acme Inc.- %s"AUTHORPLUGIN// verde
    
    
return PLUGIN_HANDLED
}

public 
cmdTest2(id) {
    
    
printf(id, DEFAULT, "^x04%s^x03 Acme Inc.- ^x01%s"AUTHORPLUGIN// comun
    
    
printf(idRED"^x04%s^x03 Acme Inc.- ^x01%s"AUTHORPLUGIN// rojo

    
printf(idBLUE"^x04%s^x03 Acme Inc.- ^x01%s"AUTHORPLUGIN// azul
    
    
printf(idGRAY"^x04%s^x03 Acme Inc.- ^x01%s"AUTHORPLUGIN// gris
    
    
printf(idGREEN"%s^x03 Acme Inc.- ^x01%s"AUTHORPLUGIN// verde
    
    
return PLUGIN_HANDLED

  • Ejemplo con Stock


PHP Code:
#include <amxmodx>

#define PLUGIN "Test Stock Chat Color"
#define VERSION "1.0"
#define AUTHOR "[R]ak"

enum {
    DEFAULT,
    
RED,
    
BLUE,
    
GRAY,
    
GREEN
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say test""cmdTest")
    
    
register_clcmd("say test2""cmdTest2")

}

public 
cmdTest(id) {
    
    
printf(id, DEFAULT, "%s Acme Inc.- %s"AUTHORPLUGIN// comun
    
    
printf(idRED"%s Acme Inc.- %s"AUTHORPLUGIN// rojo
    
    
printf(idBLUE"%s Acme Inc.- %s"AUTHORPLUGIN// azul
    
    
printf(idGRAY"%s Acme Inc.- %s"AUTHORPLUGIN// gris
    
    
printf(idGREEN"^%s Acme Inc.- %s"AUTHORPLUGIN// verde
    
    
return PLUGIN_HANDLED
}

public 
cmdTest2(id) {
    
    
printf(id, DEFAULT, "^x04%s^x03 Acme Inc.- ^x01%s"AUTHORPLUGIN// comun
    
    
printf(idRED"^x04%s^x03 Acme Inc.- ^x01%s"AUTHORPLUGIN// rojo

    
printf(idBLUE"^x04%s^x03 Acme Inc.- ^x01%s"AUTHORPLUGIN// azul
    
    
printf(idGRAY"^x04%s^x03 Acme Inc.- ^x01%s"AUTHORPLUGIN// gris
    
    
printf(idGREEN"%s^x03 Acme Inc.- ^x01%s"AUTHORPLUGIN// verde
    
    
return PLUGIN_HANDLED
}

stock printf(idcolor, const msg[], any:...) {
    
    static 
Buffer[192], MsgSayTextMsgTeamInfoTeam[11]
    
    if(!
MsgSayText) {
        
        
MsgTeamInfo get_user_msgid("TeamInfo")
        
        
MsgSayText get_user_msgid("SayText")
        
    }
        
    
vformat(Buffer[1], charsmax(Buffer) - 1msg4)
    
    static const 
Teams[4][11] = {
        
"UNASSIGNED",
        
"TERRORIST",
        
"CT",
        
"SPECTATOR"
    
}
    
    if(
color) {
        
        if(
color == GREEN) {
            
            
Buffer[0] = 0x04
            
            message_begin
(MSG_ONE_UNRELIABLEMsgSayText_id
        
            
write_byte(id
        
            
write_string(Buffer)   
        
            
message_end()
            
        }
        else {
            
            
Buffer[0] = 0x03
        
            get_user_team
(idTeamcharsmax(Team))
            
            
message_begin(MSG_ONE_UNRELIABLEMsgTeamInfo_id
        
            
write_byte(id
        
            
write_string(Teams[color])   
        
            
message_end()
            
            
message_begin(MSG_ONE_UNRELIABLEMsgSayText_id
        
            
write_byte(id
        
            
write_string(Buffer)   
        
            
message_end()
        
            
message_begin(MSG_ONE_UNRELIABLEMsgTeamInfo_id
        
            
write_byte(id
        
            
write_string(Team)   
        
            
message_end()
            
        }
        
    }
    else {
        
        
Buffer[0] = 0x01
        
        message_begin
(MSG_ONE_UNRELIABLEMsgSayText_id
        
        
write_byte(id
        
        
write_string(Buffer)   
        
        
message_end()
        
    }

Saludos
Attached Files
File Type: inc printf.inc (1.1 KB, 331 views)
__________________

www.amxmodx-es.com

Steam: Luchokoldo

Last edited by rak; 08-30-2012 at 05:47. Reason: JAJAJA me olvide de subir el inc. JAJA
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
r0ma
Senior Member
Join Date: Apr 2012
Location: Great Tomb of Nazarick
Old 08-30-2012 , 05:55   Re: [Inc/Stock] Printf
#2

Ta bueno el stock ahora lo testeo
__________________
Discord:FluffyDeveloper#4753
Github: https://github.com/francoromaniello
AMX-ES: https://amxmodx-es.com/r0ma'
r0ma is offline
Send a message via MSN to r0ma
sofi1990
Junior Member
Join Date: Aug 2012
Location: Argentina
Old 08-30-2012 , 08:11   Re: [Inc/Stock] Printf
#3

y como doy el color gris a un player solo?

"sofi" (en gris) : asdada (en gris)
osea el nick y el say

soy un asco en esto xd
__________________
sjskjsks

Last edited by sofi1990; 08-30-2012 at 08:12.
sofi1990 is offline
Send a message via MSN to sofi1990
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viña del Mar, Chile
Old 08-30-2012 , 08:31   Re: [Inc/Stock] Printf
#4

No me cabe la logica de porque lo llamaste printf lol ni que fuera la funcion de C
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Manu127
Veteran Member
Join Date: Jul 2010
Location: Argentina
Old 08-30-2012 , 10:55   Re: [Inc/Stock] Printf
#5

Quote:
Originally Posted by meTaLiCroSS View Post
No me cabe la logica de porque lo llamaste printf lol ni que fuera la funcion de C
Idem.

Mas alla de eso... interesante... gj
__________________
Manu127 is offline
Send a message via MSN to Manu127 Send a message via Skype™ to Manu127
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 08-30-2012 , 11:10   Re: [Inc/Stock] Printf
#6

Quote:
Originally Posted by sofi1990 View Post
y como doy el color gris a un player solo?

"sofi" (en gris) : asdada (en gris)
osea el nick y el say

soy un asco en esto xd
Si te referis al say , tenes que hookear el say y hacer checks.
__________________
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
sofi1990
Junior Member
Join Date: Aug 2012
Location: Argentina
Old 08-30-2012 , 11:16   Re: [Inc/Stock] Printf
#7

Quote:
Originally Posted by lucas_7_94 View Post
Si te referis al say , tenes que hookear el say y hacer checks.
como?
__________________
sjskjsks
sofi1990 is offline
Send a message via MSN to sofi1990
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 08-30-2012 , 12:50   Re: [Inc/Stock] Printf
#8

Quote:
Originally Posted by sofi1990 View Post
como?
PHP Code:
#include < amxmodx >

enum 
    DEFAULT, 
    
RED
    
BLUE
    
GREY
    
GREEN 


public 
plugin_init( )
    
register_clcmd"say""hook_say" );

public 
hook_sayid )
{
     new 
chat292 ], szName32 ];
     
read_argschatcharsmaxchat ) ); // chat ahora equivale a lo que escribis en say...

     
get_user_nameidszNamecharsmaxszName ) ); // aca obtenes el nombre del player

     
if( equaliszName"tu tag" ) ) // si szName es igual al string "tu tag" ... (no es sensible a mayusculas y minusculas)
     
{
          
// aca tenes que hacer chequeos de si estan vivos o muertos y blablabla que no tengo ganas de hacer asique se lo mando a todos sin importar nada...
          
printf0GREY"%s: %s"szNamechat );
          return 
PLUGIN_HANDLED;
     }
}

stock printf(idcolor, const msg[], any:...) { 
     
    static 
Buffer[192], MsgSayTextMsgTeamInfoTeam[11
     
    if(!
MsgSayText) { 
         
        
MsgTeamInfo get_user_msgid("TeamInfo"
         
        
MsgSayText get_user_msgid("SayText"
         
    } 
         
    
vformat(Buffer[1], charsmax(Buffer) - 1msg4
     
    static const 
Teams[4][11] = { 
        
"UNASSIGNED"
        
"TERRORIST"
        
"CT"
        
"SPECTATOR" 
    

     
    if(
color) { 
         
        if(
color == GREEN) { 
             
            
Buffer[0] = 0x04 
             
            message_begin
(MSG_ONE_UNRELIABLEMsgSayText_id)  
         
            
write_byte(id)  
         
            
write_string(Buffer)    
         
            
message_end() 
             
        } 
        else { 
             
            
Buffer[0] = 0x03 
         
            get_user_team
(idTeamcharsmax(Team)) 
             
            
message_begin(MSG_ONE_UNRELIABLEMsgTeamInfo_id)  
         
            
write_byte(id)  
         
            
write_string(Teams[color])    
         
            
message_end() 
             
            
message_begin(MSG_ONE_UNRELIABLEMsgSayText_id)  
         
            
write_byte(id)  
         
            
write_string(Buffer)    
         
            
message_end() 
         
            
message_begin(MSG_ONE_UNRELIABLEMsgTeamInfo_id)  
         
            
write_byte(id)  
         
            
write_string(Team)    
         
            
message_end() 
             
        } 
         
    } 
    else { 
         
        
Buffer[0] = 0x01 
         
        message_begin
(MSG_ONE_UNRELIABLEMsgSayText_id)  
         
        
write_byte(id)  
         
        
write_string(Buffer)    
         
        
message_end() 
         
    } 

__________________

Last edited by Neeeeeeeeeel.-; 08-30-2012 at 15:48.
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
r0ma
Senior Member
Join Date: Apr 2012
Location: Great Tomb of Nazarick
Old 08-30-2012 , 13:00   Re: [Inc/Stock] Printf
#9

ta mal la forma que pusiste neeeel

tendrias que hacer el return PLUGIN_HANDLED adentro del if y afuera del if 1 return PLUGIN_CONTINUE
__________________
Discord:FluffyDeveloper#4753
Github: https://github.com/francoromaniello
AMX-ES: https://amxmodx-es.com/r0ma'
r0ma is offline
Send a message via MSN to r0ma
Destro-
Veteran Member
Join Date: Jun 2010
Location: $me->location();
Old 08-30-2012 , 13:18   Re: [Inc/Stock] Printf
#10

Quote:
Originally Posted by meTaLiCroSS View Post
No me cabe la logica de porque lo llamaste printf lol ni que fuera la funcion de C
_____________________________________________ ___

También te falto soporte para index 0 y en mods como el zp se bugearia el teaminfo.
__________________

Last edited by Destro-; 08-30-2012 at 13:19.
Destro- 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 12:41.


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