|
Chat Colors
#83232
07/25/06 12:47
07/25/06 12:47
|
Joined: Aug 2004
Posts: 2,215
ISG
OP
Expert
|
OP
Expert
Joined: Aug 2004
Posts: 2,215
|
I've recently adapted Locoweeds chat script to my MP game (online not LAN). I was wondering if anyone had any idea how to make YOUR text YOU type one color, and the clients (or other players) that type on your screen another color. Code is below: Code:
bmap pcxChat = <Chat.pcx>; // Chat Panel
// Chat strings string strChat0[100]; // Chat entries string strChat1[100]; string strChat2[100]; string strChat3[100]; string strChat4[100]; string strChat5[100]; string strChat6[100]; string strChat7[100]; string strChat8[100]; string strChatEntry[80]; // current chat entry string strSendChat[100]; // chat to send
// text for chat panel text txtChat { pos_x = 2; pos_y = 0; layer = 30; font _a4font; strings = 9; string = strChat0, strChat1, strChat2, strChat3, strChat4, strChat5, strChat6, strChat7, strChat8; }
// text for chat entry text txtChatEntry { pos_x = 2; pos_y = 0; layer = 30; font _a4font; string strChatEntry; }
// chat panel panel pnlChat { bmap = pcxChat; layer = 18; pos_x = 0; pos_y = 0; flags = overlay,transparent,refresh; }
// Call this in your main function,.. function init_chat() { // if host or client set up chat if (connection == 2 || connection == 3) { pnlChat.pos_y = screen_size.y - 100; txtChat.pos_y = screen_size.y - 100; txtChatEntry.pos_y = screen_size.y - 15; pnlChat.visible = ON; txtChat.visible = ON; txtChatEntry.visible = OFF; } }
function chat_entry() { // if host or client if (connection == 2 || connection == 3) { // if inkey already open return if (inkey_active == 1) { return; } txtChatEntry.visible = ON; inkey(strChatEntry); // get chat entry
// if entry was empty don't process if(str_cmp(strChatEntry,"")) { return; } txtChatEntry.visible = OFF; str_cpy(strSendChat,player_name); // put players name before entry str_cat(strSendChat,": "); str_cat(strSendChat,strChatEntry); // if Host go ahead and do chat manipulation if (connection == 3) { send_string(strSendChat); str_cpy(strChat0, strChat1); str_cpy(strChat1, strChat2); str_cpy(strChat2, strChat3); str_cpy(strChat3, strChat4); str_cpy(strChat4, strChat5); str_cpy(strChat5, strChat6); str_cpy(strChat6, strChat7); str_cpy(strChat7, strChat8); str_cpy(strChat8, strSendChat); str_cpy(strSendChat,""); } else // if client send entry to server for processing { send_string(strSendChat); } str_cpy(strSendChat,""); // clear the strings for client and str_cpy(strChatEntry,""); // server called functions } }
//-------------------------------------------------------------------- // Function Server_Called(): server was called //--------------------------------------------------------------------
function server_called() { // chat stuff if (event_type == event_string) { if (!str_cmp(strSendChat,"")) { ifdef server; send_string(strSendChat); // send string to clients str_cpy(strChat0, strChat1); // move old chat entries up 1 str_cpy(strChat1, strChat2); str_cpy(strChat2, strChat3); str_cpy(strChat3, strChat4); str_cpy(strChat4, strChat5); str_cpy(strChat5, strChat6); str_cpy(strChat6, strChat7); str_cpy(strChat7, strChat8); str_cpy(strChat8, strSendChat); str_cpy(strSendChat,""); endif; } } }
//-------------------------------------------------------------------- // Function Client_Called(): client was called //--------------------------------------------------------------------
function client_called() { // string event if (event_type == event_string) { // chat entry sent from server, process if (!str_cmp(strSendChat,"")) { str_cpy(strChat0, strChat1); // move old chat entries up 1 str_cpy(strChat1, strChat2); str_cpy(strChat2, strChat3); str_cpy(strChat3, strChat4); str_cpy(strChat4, strChat5); str_cpy(strChat5, strChat6); str_cpy(strChat6, strChat7); str_cpy(strChat7, strChat8); str_cpy(strChat8, strSendChat); str_cpy(strSendChat,""); } } }
on_server = server_called; // on server event, call server_called() on_client = client_called; // on client event, call client_called() on_enter = chat_entry; // on <enter> start chat entry
|
|
|
Re: Chat Colors
[Re: Dutchie666]
#83234
07/26/06 01:39
07/26/06 01:39
|
Joined: Jun 2004
Posts: 2,234 Wisconsin USA
FoxHound
Expert
|
Expert
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
|
One idea I have is to have 10 different panels for each line of the chat window, When you update the strings, also update an array which holds which color the font is, at which point update the font in each of those panels.
I'm not sure if that will work, but it's an idea.
--------------------- There is no signature here.
QUIT LOOKING FOR ONE!
|
|
|
Re: Chat Colors
[Re: Dutchie666]
#83235
09/05/06 00:19
09/05/06 00:19
|
Joined: Apr 2006
Posts: 1,551 Netherlands
D3D
Serious User
|
Serious User
Joined: Apr 2006
Posts: 1,551
Netherlands
|
I like this idea because it looks more flexible with draw_text: Code:
draw_text("Test!",100,10,vector(100,100,255)); // red text
All the best, Dusty
|
|
|
Re: Chat Colors
[Re: D3D]
#83236
09/05/06 06:41
09/05/06 06:41
|
Joined: Apr 2002
Posts: 4,801 Richmond B.C., Canada
Captain_Kiyaku
Dichotomic
|
Dichotomic
Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
|
yeah it would work with draw_text. hmm i should try that too. in my chat system, i use one color for all persons, then one color for system messages, and one color for picking up something, etc. but i defined new strings all the time so it really sucks.
My Blog"Tag und Nacht schrei ich mich heiser, Wind weht alle Worte fort, Tag und Nacht schrei ich mein Krähenwort!"Subway To Sally - Krähenkönig
|
|
|
Re: Chat Colors
[Re: Captain_Kiyaku]
#83237
09/05/06 17:10
09/05/06 17:10
|
Joined: Jun 2004
Posts: 2,234 Wisconsin USA
FoxHound
Expert
|
Expert
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
|
Remeber that you can't change the font with draw_text, it is Arial 20 bold, to change the font you need "draw_textmode" and it is a slow instrunction.
--------------------- There is no signature here.
QUIT LOOKING FOR ONE!
|
|
|
Re: Chat Colors
[Re: D3D]
#83239
09/06/06 12:24
09/06/06 12:24
|
Joined: Aug 2003
Posts: 7,439 Red Dwarf
Michael_Schwarz
Senior Expert
|
Senior Expert
Joined: Aug 2003
Posts: 7,439
Red Dwarf
|
the draw_textmode instuction is only executed locally and has no influence on the online expereience, the way you can use it without any problems in multiplayer games
"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
|
|
|
|