06/08/2014, 12:01 PM (Última modificación: 06/08/2014, 12:05 PM por RauliTop.)
jajajajajjaa, me re olvidé
sobre eso de MSG_ONE y unrealiable tengo una duda, quisiera saber cuando es posible que un mensaje no se envíe, porque la verdad que hay ciertos momentos en los que es necesario enviarlo.
no quiero depender de unreliable y luego que empiecen a faltar mensajes por ahí...
y otra cosa sobre lo que dijiste del 33, no hay que enviar 33 sino el valor de get_maxplayers() + 1, que en el caso de ser 32 slots sí que sería 33, pero no siempre.
(17/04/2015, 03:36 PM)Neeeeeeeeeel.- escribió: No se va a volver a conectar a internet en toda su puta vida... nadie sube porno a mi foro y vive para contarlo.
(06/08/2014, 12:01 PM)RauliTop escribió: jajajajajjaa, me re olvidé
sobre eso de MSG_ONE y unrealiable tengo una duda, quisiera saber cuando es posible que un mensaje no se envíe, porque la verdad que hay ciertos momentos en los que es necesario enviarlo.
no quiero depender de unreliable y luego que empiecen a faltar mensajes por ahí...
y otra cosa sobre lo que dijiste del 33, no hay que enviar 33 sino el valor de get_maxplayers() + 1, que en el caso de ser 32 slots sí que sería 33, pero no siempre.
cuando tienes mucho ping por ejemplo, o cuando te mandan muchos mensajes al mismo tiempo es posible que alguno se pierda.
(06/08/2014, 02:18 PM)roccoxx escribió: cuando tienes mucho ping por ejemplo, o cuando te mandan muchos mensajes al mismo tiempo es posible que alguno se pierda.
Se pierden con MSG_ONE? Con MSG_ONE_UNRELIABLE no se pierden?
Believe, be yourself and don't hold on to just one dream ❤
06/08/2014, 02:24 PM (Última modificación: 06/08/2014, 02:25 PM por roccoxx.)
(06/08/2014, 02:19 PM)Federicomb escribió:
(06/08/2014, 02:18 PM)roccoxx escribió: cuando tienes mucho ping por ejemplo, o cuando te mandan muchos mensajes al mismo tiempo es posible que alguno se pierda.
Se pierden con MSG_ONE? Con MSG_ONE_UNRELIABLE no se pierden?
se pierden con los mensajes del canal no seguro, en este caso MSG_ONE_UNRELIABLE.
(06/08/2014, 12:01 PM)RauliTop escribió: jajajajajjaa, me re olvidé
sobre eso de MSG_ONE y unrealiable tengo una duda, quisiera saber cuando es posible que un mensaje no se envíe, porque la verdad que hay ciertos momentos en los que es necesario enviarlo.
no quiero depender de unreliable y luego que empiecen a faltar mensajes por ahí...
y otra cosa sobre lo que dijiste del 33, no hay que enviar 33 sino el valor de get_maxplayers() + 1, que en el caso de ser 32 slots sí que sería 33, pero no siempre.
No hace falta get_maxplayers, no se ganaría nada si con 33 funcionará igual. Así tengas 8 slots, 33 seguirá siendo seguro; eso lo probé.
Es difícil que un mensaje SayText no llegue a enviarse, a menos que estés lidiando con 2000 de latency o algo así... es posible que se pierdan como también es posible que mañana haya una invasión alienígena
(17/04/2015, 03:36 PM)Neeeeeeeeeel.- escribió: No se va a volver a conectar a internet en toda su puta vida... nadie sube porno a mi foro y vive para contarlo.
public msj(id) chatcolor(id, "!g[amxmodx-es.com]!team ;LuKks.-' !y--- !teamPrimero replace_all luego vformat.") public msj2(id) chatcolor2(id, "!g[amxmodx-es.com]!team ;LuKks.-' !y--- !teamPrimero vformat luego replace_all.")
public plugin_init() { g_msgSayText = get_user_msgid("SayText") g_msgTeamInfo = get_user_msgid("TeamInfo") }
public plugin_natives() { register_native("baseoa_chat_color", "native_chat_color") }
public client_putinserver(id) { set_task(0.2, "task_send_teaminfo", id) }
public task_send_teaminfo(id) { if(!is_user_connected(id)) return
send_teaminfo(id, 33, "") // Creo que si entra a un servidor que mande un teaminfo al slot 33 no se limpia al entrar a otro. send_teaminfo(id, 34, "TERRORIST") send_teaminfo(id, 35, "CT") }
public native_chat_color(iPlugin, iParams) { static msg[128], id
No es algo "portable" como para meter en unos stocks, la idea es que este en un plugin base y utilizar la native.
El funcionamiento es similar al ColorChat de ConnorMcLeod con algunas mejoras y sin soporte para lang.
// Replace LANG_PLAYER with player id for (arg_index = 2; arg_index < argscount; arg_index++) { if (getarg(arg_index) == LANG_PLAYER && arg_index + 1 < argscount) { // Check if next param string is a registered language translation static lang_key[64], arg_subindex arg_subindex = 0 while ((lang_key[arg_subindex] = getarg(arg_index + 1, arg_subindex++))) { /* keep looping */ } if (GetLangTransKey(lang_key) != TransKey_Bad) { setarg(arg_index, 0, player) changed_args[changedcount++] = arg_index arg_index++ // skip next argument since we know it's a translation key } } }
// Format message for player (+add ZP prefix) vformat(buffer, charsmax(buffer), message, 3) format(buffer, charsmax(buffer), "%s%s", ZP_PREFIX, buffer)
// Send it message_begin(MSG_ONE_UNRELIABLE, msg_SayText, _, player) write_byte(player) write_string(buffer) message_end()
// Replace back player id's with LANG_PLAYER for (arg_index = 0; arg_index < changedcount; arg_index++) setarg(changed_args[arg_index], 0, LANG_PLAYER) } } // Send to specific target else { // Format message for player (+add ZP prefix) vformat(buffer, charsmax(buffer), message, 3) format(buffer, charsmax(buffer), "%s%s", ZP_PREFIX, buffer)
// Replace LANG_PLAYER with player id for (arg_index = 2; arg_index < argscount; arg_index++) { if (getarg(arg_index) == LANG_PLAYER && arg_index + 1 < argscount) { // Check if next param string is a registered language translation static lang_key[64], arg_subindex arg_subindex = 0 while ((lang_key[arg_subindex] = getarg(arg_index + 1, arg_subindex++))) { /* keep looping */ } if (GetLangTransKey(lang_key) != TransKey_Bad) { setarg(arg_index, 0, player) changed_args[changedcount++] = arg_index arg_index++ // skip next argument since we know it's a translation key } } }
// Format message for player (+add ZP prefix) vformat(buffer, charsmax(buffer), message, 3) format(buffer, charsmax(buffer), "%s%s", ZP_PREFIX, buffer)
// Send it message_begin(MSG_ONE_UNRELIABLE, msg_SayText, _, player) write_byte(player) write_string(buffer) message_end()
// Replace back player id's with LANG_PLAYER for (arg_index = 0; arg_index < changedcount; arg_index++) setarg(changed_args[arg_index], 0, LANG_PLAYER) } } // Send to specific target else { // Format message for player (+add ZP prefix) vformat(buffer, charsmax(buffer), message, 3) format(buffer, charsmax(buffer), "%s%s", ZP_PREFIX, buffer)
No parece que está mal, hay un par de natives que se llaman más de una vez por nada pero no es algo grave. Ese stock tiene la particularidad de poder mostrar multilang con index 0, algo que otros stocks de chat color no hacen...
28/08/2017, 06:00 AM (Última modificación: 28/08/2017, 06:00 AM por Pablo_1998.)
Hola revivo este tema porque tengo una duda sobre el chatcolor. Lo que quería saber si hay alguna forma para que en el say el color que yo elija. Por ejemplo: si yo escribo "HOLA A TODOS" para que salga en blanco o en gris para todos los jugadores tanto para los cts como para los tts. Nosé si me explique bien. Porque si yo pongo "^3HOLA A TODOS" sale el color del mismo equipo. Muchas Gracias. Saludos!
Vamos otra vez con "SayText". El primer argumento en este mensaje es un byte, que es el ID del jugador que envia el mensaje. El color depende del equipo de este jugador. El id puede ser un jugador no conectado, no tendremos problemas con ello, en este caso el color será el del equipo del último jugador que tuvo ese número de ID.
DATO (Gracias Destro por la información): Podemos "hacer creer" a los jugadores que el jugador (o entidad) con ID 33, 34, 35, etc pertenece a un equipo, así al utilizar estos IDs en este byte del mensaje obtendremos los colores deseados. (Más info en los stocks).
28/08/2017, 02:44 PM (Última modificación: 28/08/2017, 02:49 PM por Pablo_1998.)
y cual seria el símbolo a utilizar? si quiero que salga azul o rojo para todos? ^1 ^3 ^4?
Osea me refiero a que si yo pongo "HOLA A TODOS" ¿que le pondría antes del mensaje a enviar del mismo color para todos los jugadores? ^1,^2(no existe no?),^3,^4?
(28/08/2017, 02:44 PM)Pablo_1998 escribió: y cual seria el símbolo a utilizar? si quiero que salga azul o rojo para todos? ^1 ^3 ^4?
Osea me refiero a que si yo pongo "HOLA A TODOS" ¿que le pondría antes del mensaje a enviar del mismo color para todos los jugadores? ^1,^2(no existe no?),^3,^4?
^3 es el color depende del equipo, si está en T va a ser rojo, si está en CT va a ser celeste y si esta de SPECT va a ser gris.
y no el stock que está. Y si no, aquí un colorchat.inc más adecuado: client_print_color para < AMXX 1.8.3.
Código PHP:
#if defined _colorchat_included #endinput #endif #define _colorchat_included
/* ColorChat Support */ #define NORMAL DontChange #define GREEN DontChange #define RED Red #define BLUE Blue #define GREY Grey #define ColorChat client_print_color
#define MAX_TRANSLATION_LENGTH 2048
enum { DontChange = 0, Grey = -1, Red = -2, Blue = -3 };
#define print_team_default DontChange #define print_team_grey Grey #define print_team_red Red #define print_team_blue Blue
stock client_print_color(id, sender, const fmt[], any:...) { // check if id is different from 0 if (id && !is_user_connected(id)) { return 0; }
if (sender < Blue || sender > 32) { sender = DontChange; } else if (sender < DontChange) { sender = -sender + 32; // align indexes to the TeamInfo ones }
// Send message to all players else { // Figure out if at least 1 player is connected // so we don't execute useless useless code if not new iPlayers[32], iNum; get_players(iPlayers, iNum, "ch"); if (!iNum) { return 0; }
new iMlNumber, i, j; new Array:aStoreML = ArrayCreate(); if (iParams >= 5) // ML can be used { for (j = 3; j < iParams; j++) { // retrieve original param value and check if it's LANG_PLAYER value if (getarg(j) == LANG_PLAYER) { i = 0; // as LANG_PLAYER == -1, check if next parm string is a registered language translation while ((szMessage[i] = getarg(j + 1, i++))) {} if (GetLangTransKey(szMessage) != TransKey_Bad) { // Store that arg as LANG_PLAYER so we can alter it later ArrayPushCell(aStoreML, j++);
// Update ML array saire so we'll know 1st if ML is used, // 2nd how many args we have to alterate iMlNumber++; } } } }
// If arraysize == 0, ML is not used // we can only send 1 MSG_ALL message if sender != 0 if (!iMlNumber) { if (iParams == 3) { copy(szMessage, charsmax(szMessage), fmt); } else { vformat(szMessage, charsmax(szMessage), fmt, 4); } if (0 < sender < (32 - Blue)) // if 0 is passed, need to loop { if (sender > (32 - Grey)) { _CC_TeamInfo(0, sender, szTeamName[sender - (32 - Grey)]); } _CC_SayText(0, sender, szMessage); return 1; } }
if (sender > (32 - Blue)) { sender = 0; // use receiver index }
for (--iNum; iNum >= 0; iNum--) { id = iPlayers[iNum];
if (iMlNumber) { for (j = 0; j < iMlNumber; j++) { // Set all LANG_PLAYER args to player index ( = id ) // so we can format the text for that specific player setarg(ArrayGetCell(aStoreML, j), _, id); }
// format string for specific player vformat(szMessage, charsmax(szMessage), fmt, 4); }
// Prevent sending format and localization strings via chat for (new i = 0; i < 192; i++) { if (szMessage[i] == 0) break; if (szMessage[i] == '%' || szMessage[i] == '#') szMessage[i] = ' '; }