Veteran Member
Join Date: Oct 2011
Location: banned country
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
Spoiler
Code:
#if defined _printf_included
#endinput
#endif
#define _printf_included
enum {
DEFAULT,
RED,
BLUE,
GRAY,
GREEN
}
stock printf(id, color, const msg[], any:...) {
static Buffer[192], MsgSayText, MsgTeamInfo, Team[11]
if(!MsgSayText) {
MsgTeamInfo = get_user_msgid("TeamInfo")
MsgSayText = get_user_msgid("SayText")
}
vformat(Buffer[1], charsmax(Buffer) - 1, msg, 4)
static const Teams[4][11] = {
"UNASSIGNED",
"TERRORIST",
"CT",
"SPECTATOR"
}
if(color) {
if(color == GREEN) {
Buffer[0] = 0x04
printf_do(id, Buffer, MsgSayText)
}
else {
Buffer[0] = 0x03
get_user_team(id, Team, charsmax(Team))
printf_do(id, Teams[color], MsgTeamInfo)
printf_do(id, Buffer, MsgSayText)
printf_do(id, Team, MsgTeamInfo)
}
}
else {
Buffer[0] = 0x01
printf_do(id, Buffer, MsgSayText)
}
}
printf_do(id, const data[], MsgID) {
message_begin(MSG_ONE_UNRELIABLE, MsgID, _, id)
write_byte(id)
write_string(data)
message_end()
}
Spoiler
PHP Code:
enum {
DEFAULT,
RED ,
BLUE ,
GRAY ,
GREEN
}
stock printf ( id , color , const msg [], any :...) {
static Buffer [ 192 ], MsgSayText , MsgTeamInfo , Team [ 11 ]
if(! MsgSayText ) {
MsgTeamInfo = get_user_msgid ( "TeamInfo" )
MsgSayText = get_user_msgid ( "SayText" )
}
vformat ( Buffer [ 1 ], charsmax ( Buffer ) - 1 , msg , 4 )
static const g_Teams [ 4 ][ 11 ] = {
"UNASSIGNED" ,
"TERRORIST" ,
"CT" ,
"SPECTATOR"
}
if( color ) {
if( color == GREEN ) {
Buffer [ 0 ] = 0x04
message_begin ( MSG_ONE_UNRELIABLE , MsgSayText , _ , id )
write_byte ( id )
write_string ( Buffer )
message_end ()
}
else {
Buffer [ 0 ] = 0x03
get_user_team ( id , Team , charsmax ( Team ))
message_begin ( MSG_ONE_UNRELIABLE , MsgTeamInfo , _ , id )
write_byte ( id )
write_string ( g_Teams [ color ])
message_end ()
message_begin ( MSG_ONE_UNRELIABLE , MsgSayText , _ , id )
write_byte ( id )
write_string ( Buffer )
message_end ()
message_begin ( MSG_ONE_UNRELIABLE , MsgTeamInfo , _ , id )
write_byte ( id )
write_string ( Team )
message_end ()
}
}
else {
Buffer [ 0 ] = 0x01
message_begin ( MSG_ONE_UNRELIABLE , MsgSayText , _ , id )
write_byte ( id )
write_string ( Buffer )
message_end ()
}
}
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 ( PLUGIN , VERSION , AUTHOR )
register_clcmd ( "say test" , "cmdTest" )
register_clcmd ( "say test2" , "cmdTest2" )
}
public cmdTest ( id ) {
printf ( id , DEFAULT, "%s Acme Inc.- %s" , AUTHOR , PLUGIN ) // comun
printf ( id , RED , "%s Acme Inc.- %s" , AUTHOR , PLUGIN ) // rojo
printf ( id , BLUE , "%s Acme Inc.- %s" , AUTHOR , PLUGIN ) // azul
printf ( id , GRAY , "%s Acme Inc.- %s" , AUTHOR , PLUGIN ) // gris
printf ( id , GREEN , "^%s Acme Inc.- %s" , AUTHOR , PLUGIN ) // verde
return PLUGIN_HANDLED
}
public cmdTest2 ( id ) {
printf ( id , DEFAULT, "^x04%s^x03 Acme Inc.- ^x01%s" , AUTHOR , PLUGIN ) // comun
printf ( id , RED , "^x04%s^x03 Acme Inc.- ^x01%s" , AUTHOR , PLUGIN ) // rojo
printf ( id , BLUE , "^x04%s^x03 Acme Inc.- ^x01%s" , AUTHOR , PLUGIN ) // azul
printf ( id , GRAY , "^x04%s^x03 Acme Inc.- ^x01%s" , AUTHOR , PLUGIN ) // gris
printf ( id , GREEN , "%s^x03 Acme Inc.- ^x01%s" , AUTHOR , PLUGIN ) // verde
return PLUGIN_HANDLED
}
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 ( PLUGIN , VERSION , AUTHOR )
register_clcmd ( "say test" , "cmdTest" )
register_clcmd ( "say test2" , "cmdTest2" )
}
public cmdTest ( id ) {
printf ( id , DEFAULT, "%s Acme Inc.- %s" , AUTHOR , PLUGIN ) // comun
printf ( id , RED , "%s Acme Inc.- %s" , AUTHOR , PLUGIN ) // rojo
printf ( id , BLUE , "%s Acme Inc.- %s" , AUTHOR , PLUGIN ) // azul
printf ( id , GRAY , "%s Acme Inc.- %s" , AUTHOR , PLUGIN ) // gris
printf ( id , GREEN , "^%s Acme Inc.- %s" , AUTHOR , PLUGIN ) // verde
return PLUGIN_HANDLED
}
public cmdTest2 ( id ) {
printf ( id , DEFAULT, "^x04%s^x03 Acme Inc.- ^x01%s" , AUTHOR , PLUGIN ) // comun
printf ( id , RED , "^x04%s^x03 Acme Inc.- ^x01%s" , AUTHOR , PLUGIN ) // rojo
printf ( id , BLUE , "^x04%s^x03 Acme Inc.- ^x01%s" , AUTHOR , PLUGIN ) // azul
printf ( id , GRAY , "^x04%s^x03 Acme Inc.- ^x01%s" , AUTHOR , PLUGIN ) // gris
printf ( id , GREEN , "%s^x03 Acme Inc.- ^x01%s" , AUTHOR , PLUGIN ) // verde
return PLUGIN_HANDLED
}
stock printf ( id , color , const msg [], any :...) {
static Buffer [ 192 ], MsgSayText , MsgTeamInfo , Team [ 11 ]
if(! MsgSayText ) {
MsgTeamInfo = get_user_msgid ( "TeamInfo" )
MsgSayText = get_user_msgid ( "SayText" )
}
vformat ( Buffer [ 1 ], charsmax ( Buffer ) - 1 , msg , 4 )
static const Teams [ 4 ][ 11 ] = {
"UNASSIGNED" ,
"TERRORIST" ,
"CT" ,
"SPECTATOR"
}
if( color ) {
if( color == GREEN ) {
Buffer [ 0 ] = 0x04
message_begin ( MSG_ONE_UNRELIABLE , MsgSayText , _ , id )
write_byte ( id )
write_string ( Buffer )
message_end ()
}
else {
Buffer [ 0 ] = 0x03
get_user_team ( id , Team , charsmax ( Team ))
message_begin ( MSG_ONE_UNRELIABLE , MsgTeamInfo , _ , id )
write_byte ( id )
write_string ( Teams [ color ])
message_end ()
message_begin ( MSG_ONE_UNRELIABLE , MsgSayText , _ , id )
write_byte ( id )
write_string ( Buffer )
message_end ()
message_begin ( MSG_ONE_UNRELIABLE , MsgTeamInfo , _ , id )
write_byte ( id )
write_string ( Team )
message_end ()
}
}
else {
Buffer [ 0 ] = 0x01
message_begin ( MSG_ONE_UNRELIABLE , MsgSayText , _ , id )
write_byte ( id )
write_string ( Buffer )
message_end ()
}
}
Saludos
__________________
Last edited by rak; 08-30-2012 at 05:47 .
Reason: JAJAJA me olvide de subir el inc. JAJA