AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Compatibility - chat isn't colorized on linux (https://forums.alliedmods.net/showthread.php?t=100899)

orglee 08-19-2009 00:03

Compatibility - chat isn't colorized on linux
 
Hi. I cannot get this thing to work on my dedicated server. On windows code bellow is executed properly but on Linux whole text is yellow ( or orange... whatever ) and in places of color modifiers ( !g, !t, !y ) I see spaces. What can be the problem here?
PHP Code:

cc_chatMessage(0"!gGreen !tRedOrBlue !yYellow"); 

PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Chat"
#define VERSION "1.0"
#define AUTHOR "wthc" // Who The Hell Cares

new gHudOvertimegSayTextgMaxSlotsgCvarTag;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_dictionary("chat.txt");
    
    
gSayText get_user_msgid("SayText");
    
gMaxSlots get_maxplayers();
    
gCvarTag register_cvar("chat_tag""[SERVER]");
    
    
gHudOvertime CreateHudSyncObj();
}
public 
plugin_natives()
{
    
register_library(PLUGIN);
    
register_native("cc_chatMessageLang""cc_chatMessageLang"1);
    
register_native("cc_chatMessage""cc_chatMessage"1);
    
register_native("cc_hudMessageLang""cc_hudMessageLang"1);
    
register_native("cc_hudMessage""cc_hudMessage"1);
}
/////////////////
//// NATIVES ////
/////////////////
public cc_chatMessageLang(iPlayer, const sKeyLang[])
{
    
param_convert(2);
    
ChatMessage(iPlayer"%L"iPlayersKeyLang)
}
public 
cc_chatMessage(iPlayer, const sMessage[], ...)
{
    for(new 
2<= numargs(); i++) { param_convert(i); }
    new 
sMsgFinal[192];
    
vformat(sMsgFinalcharsmax(sMsgFinal), sMessage3);
    
ChatMessage(iPlayersMsgFinal)
}
public 
cc_hudMessageLang(iPlayer, const sKeyLang[])
{
    
param_convert(2);
    
HudMessageLang(iPlayersKeyLang);
}
public 
cc_hudMessage(iPlayer, const sMessage[], ...)
{
    for(new 
2<= numargs(); i++) { param_convert(i); }
    new 
sMsgFinal[192];
    
vformat(sMsgFinalcharsmax(sMsgFinal), sMessage3);
    
HudMessage(iPlayersMsgFinal);
}
//////////////////
//// MESSAGES ////
//////////////////
ChatMessage(iPlayer, const sMessage[], ...)
{
    new 
indexMSG_TypesMsg[192], sFinal[192], sTag[32];
    
get_pcvar_string(gCvarTagsTag191);
    if(
iPlayer == 0)
    {
        
index PlayersFind();
        
MSG_Type MSG_ALL;
    
    } else {
        
MSG_Type MSG_ONE;
        
index iPlayer;
    }
    
vformat(sMsgcharsmax(sMsg), sMessage3);
    
format(sFinalcharsmax(sFinal), "%s %s"sTagsMsg);
    
ColorsReplace(sFinalcharsmax(sFinal));
    
message_begin(MSG_TypegSayText_index);
    
write_byte(index);
    
write_string(sFinal);
    
message_end();
}
HudMessageLang(iPlayer, const sKeyLang[])
{
    
HudMessage(iPlayer"%L"iPlayersKeyLang);
}

HudMessage(iPlayer, const sMessage[], ...)
{
    new 
sMsgFinal[192];
    
vformat(sMsgFinalcharsmax(sMsgFinal), sMessage3);
    
set_hudmessage(25500, -1.00.9000.02.00.01.0, -1);
    
ShowSyncHudMsg(iPlayergHudOvertimesMsgFinal);
}
ColorsReplace(sMsg[], iMsgLen)
{
    
replace_all(sMsgiMsgLen"!g""^x04");
    
replace_all(sMsgiMsgLen"!t""^x03");
    
replace_all(sMsgiMsgLen"!y""^x01");
}
PlayersFind()
{
    new 
= -1;

    while(
<= gMaxSlots)
    {
        if(
PlayerIsConnected(++i)) { return i; }
    }
    return -
1;
}
PlayerIsConnected(iPlayer)
{
    return (
is_user_connected(iPlayer) && !is_user_bot(iPlayer))



orglee 08-21-2009 12:26

Re: Compatibility - chat isn't colorized on linux
 
Ok Ive figured out whats wrong thanks to ColorChat by ConnorMcLeod ( thank you! ) The problem was with the way chat message was send. Broadcaster id and Receiver id where mixed up and when message was to every player colors where screwed up.

Fixed code:
PHP Code:

ChatMessage(iReceiver, const sMessage[], ...)
{
    new 
iBroadcasterMSG_TypesMsg[192], sFinal[192], sTag[32];
    
get_pcvar_string(gCvarTagsTag191);
    if(
iReceiver== 0)
    {
        
MSG_Type MSG_ALL;
        
iBroadcaster BroadcasterFind();
    
    } else {
        
MSG_Type MSG_ONE;
        
iBroadcaster iReceiver;
    }
    
vformat(sMsgcharsmax(sMsg), sMessage3);
    
format(sFinalcharsmax(sFinal), "!t%s %s"sTagsMsg);
    
ColorsReplace(sFinalcharsmax(sFinal));
    
message_begin(MSG_TypegSayText_iReceiver);
    
write_byte(iBroadcaster);
    
write_string(sFinal);
    
message_end();
}
BroadcasterFind()
{
    new 
1;

    while(
<= gMaxSlots)
    {
        if(
is_user_connected(i) && !is_user_bot(i)) { return i; }
    }
    return -
1;




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

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