Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (vicknick, howardR, sleakz), 674 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Chat Colors #83232
07/25/06 12:47
07/25/06 12:47
Joined: Aug 2004
Posts: 2,215
I
ISG Offline OP

Expert
ISG  Offline OP

Expert
I

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




Ground Tactics - Coming Soon
Ground Tactics OFFICIAL WEBSITE
Re: Chat Colors [Re: ISG] #83233
07/25/06 12:51
07/25/06 12:51
Joined: Sep 2005
Posts: 159
The Netherlands
D
Dutchie666 Offline
Member
Dutchie666  Offline
Member
D

Joined: Sep 2005
Posts: 159
The Netherlands
how i am doing that is with draw_text.
just make a loop somewhere wich just acts like the text panels but than just writes it on the screen. en you can do with a check who has send a message if you are that guy and than change the color...
i think that that is the best way to do it.

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 Offline
Expert
FoxHound  Offline
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 Offline
Serious User
D3D  Offline
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


smile
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 Offline

Dichotomic
Captain_Kiyaku  Offline

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 Offline
Expert
FoxHound  Offline
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: FoxHound] #83238
09/06/06 03:11
09/06/06 03:11
Joined: Apr 2006
Posts: 1,551
Netherlands
D3D Offline
Serious User
D3D  Offline
Serious User

Joined: Apr 2006
Posts: 1,551
Netherlands
Slow is not good for multiplayer games played over the internet. So if copy & paste and using 10 different panels would be faster, that route should be better. I'll try both.

All the best,

Dusty


smile
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 Offline
Senior Expert
Michael_Schwarz  Offline
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
Re: Chat Colors [Re: Michael_Schwarz] #83240
09/06/06 18:08
09/06/06 18:08
Joined: Jul 2006
Posts: 783
London, UK
sheefo Offline
User
sheefo  Offline
User

Joined: Jul 2006
Posts: 783
London, UK
You don't need 'draw_textmode' to change the colour of the text. It's done in the last argument of 'draw_text'.

Re: Chat Colors [Re: sheefo] #83241
09/07/06 03:38
09/07/06 03:38
Joined: Apr 2006
Posts: 1,551
Netherlands
D3D Offline
Serious User
D3D  Offline
Serious User

Joined: Apr 2006
Posts: 1,551
Netherlands
Sheefo I guess Michael responded to my reply on what FoxHound said:

Quote:

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 instruction.





So you are right Sheefo, about draw_mode not needed to change the font color. This is done in the last argument of the draw_text instruction. but, the standard font type is arial. To be able to change that. You need draw_mode, which is told to be slow and therefore not recommended.

However Michael said it doesn't influence the online gameplay, because the draw_mode instruction is only executed locally.

Dusty


smile
Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1