| Creating chat rooms for TGE 1.5 |
Basic Information Author: JuanMa (Nov 21, 2007) |
Synopsis: This tutorial will explain how to create simple in-game chat rooms using torque script only. It mods the way MessageVector and GuiMessageVectorCtrl are used in the original version of the starter.fps game to manage the global chat only. This will not allow you to dynamically create chat rooms in game or private chat rooms managed by one user, though the idea of this resource is to provide some basic understanding on how the chat works and how it could be mod hoping that the community will take this idea to work on top of it and create better and cooler resources. If you have any idea how to make this resource better I will appreciate any comments. |
Keywords: ChatRoom chat room onChatMessage clientCmdChatMessage MessageVector HudMessageVector ChatHud |
Article: Open the file chatHud.cs right after the new MessageVector(HudMessageVector); add the following code: // All messages are stored in this HudMessageVector, the actual In this same file ChatHud.cs make the following changes: Change all the HudMessageVector with $ChatRoom or $HudMessageVector or any variable name you feel comfortable using and all the ChatHud with $ChatHud in the whole file, this will enable us to instead of Using a single object we will use a "pointer" (the global variable) to the object so we can change it at any time. Example: while( !chatPageDown.isVisible() && HudMessageVector.getNumLines() && Should look like this. while( !chatPageDown.isVisible() && $ChatRoom.getNumLines() && ($ChatRoom.getNumLines() In the function onChatMessage add an extra parameter %chatWindow function onChatMessage(%message, %voice, %pitch, %chatWindow){...}and replace the whole if statement // Chat goes to the chat HUD. with // Chat goes to the chat HUD. Add at the end of the file. these are copies of ChatHud you will have to add one for work For each chatRoomX that you have //----------------------------------------------------------------------------- Now add 4 buttons and 3 GuiMessageVectorCtrl in chatHud.gui this is not the whole code, Just the part that adds the buttons and the GuiMessageVectorCtrl ... In the file messageHud.cs in the function function MessageHud_Edit::eval(%this){...} around line 87 add one parameter to the commandToServer if(MessageHud.isTeamMsg) In the file common/client/message.cs change the function clientCmdChatMessage with this function clientCmdChatMessage(%sender, %voice, %pitch, %msgString, %a1, %a2, %a3, %a4, Ok so we are done with the client side, at this point if you start your game you should see a chat window with four buttons on the side, if you choose any of these buttons the screen should change. we do not have to mod the server because thankfuly we are using one of the extra paramenters that the messaging system has available :) and there for the parameter of which chat room the message should go to has been passed all the way back to each client that recieves the message and has been taken care of in clientCmdChatMessage. If you want to know where the messages are handled in the server go to common/server/commands.cs and look at the function serverCmdMessageSent(%client, %text, Hope this will help someone. JuanMa |

