Local & Global chat & Chat commands.
by Braveheart · in Torque Game Engine · 12/04/2007 (7:21 pm) · 6 replies
Okay, so I want to make a local chat as well as keeping the global chat.
I want to do it where the local chat would work like so:
*You send a message
*The script checks for anyone in a set distance of you (ContainerSearchCurrRadiusDist?)
*If anyone is in the set distance then they will receive the message, the further away the darker the message.
I also want to change the global chat to work when you do /g message this would send the message like normal to everyone. A normal message would be local. Or would it be easier to make a command for local chat?
How could I do this in Torque Script?
Also, I was adding Chatcommands from a resource, it told me to edit some files in common/server but is the common directory a demo game or is that directory used by every game? I noticed the common directory has a lot of different files and folders, should I copy and paste them to my game dir?
I want to do it where the local chat would work like so:
*You send a message
*The script checks for anyone in a set distance of you (ContainerSearchCurrRadiusDist?)
*If anyone is in the set distance then they will receive the message, the further away the darker the message.
I also want to change the global chat to work when you do /g message this would send the message like normal to everyone. A normal message would be local. Or would it be easier to make a command for local chat?
How could I do this in Torque Script?
Also, I was adding Chatcommands from a resource, it told me to edit some files in common/server but is the common directory a demo game or is that directory used by every game? I noticed the common directory has a lot of different files and folders, should I copy and paste them to my game dir?
About the author
#2
stop anything with a "/" first from showing in the chat box? If not, how could I do it? For example you type "command" it would show as normal, but if you type "/command" it wouldn't show in the chat box and if it was a scripted command it would do something of course.
12/05/2007 (8:11 am)
Should this code:if (getSubStr(%a2, 0, 1) $= "/") // this here / is your conditional
chatcommands(%sender,%a2);
if(getSubStr(%a2, 0, 1) !$= "/")
{ // the already existent loop for clients
} // you just have to add thisstop anything with a "/" first from showing in the chat box? If not, how could I do it? For example you type "command" it would show as normal, but if you type "/command" it wouldn't show in the chat box and if it was a scripted command it would do something of course.
#3
12/05/2007 (5:11 pm)
From: here:Quote:If you want to modify the chat, so only players who is in visible range will get the messages what do you do?
Of course you can go similar to this (starter.fps/common/server/commands.cs):
function chatMessageAll( %sender, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10 )
{
if ( ( %msgString $= "" ) || spamAlert( %sender ) || !isObject( %sender.getControlObject() ) )
return;
%senderPosition = %sender.getControlObject().getPosition();
%count = ClientGroup.getCount();
for ( %i = 0; %i < %count; %i++ )
{
%obj = ClientGroup.getObject( %i );
if ( !isObject(%obj.getControlObjecT()) ) continue;
%targetPosition = %obj.getControlObjecT().getPosition();
[b] %distance = VectorDist(%senderPosition, %targetPosition);
if (%distance > $chatDistance) continue;[/b]
if(%sender.team != 0)
chatMessageClient( %obj, %sender, %sender.voiceTag, %sender.voicePitch, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10 );
else
{
// message sender is an observer -- only send message to other observers
if(%obj.team == %sender.team)
chatMessageClient( %obj, %sender, %sender.voiceTag, %sender.voicePitch, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10 );
}
}
}Quote:The alternative way is described in mentioned resource.
But code lacks on:
1. it's scripted, and if you have lots of clients it can hit on performance.
2. if the target player is in interior and not visible but is in range - he will get the message
#4
*A lot of clients can hit on performance.
*Players in visable range will get the message, so only players that you can see? I'm looking for just players in the general area.
The alternative way, is that the C++ engine change way at the bottom?
12/05/2007 (5:21 pm)
Thanks for that Bank, I was actually looking at that, two things caught my attention:*A lot of clients can hit on performance.
*Players in visable range will get the message, so only players that you can see? I'm looking for just players in the general area.
The alternative way, is that the C++ engine change way at the bottom?
#5
the "script only" changes allows you to limit the by "range from speaker" - does not matter if hes inside buiding or just on a "pure nature". The c++ (engine changes) allows you to make the send the chat message to "only players who is in visible range AND in the same "zone". the "Zone" means the same "room" inside the building.
What you need is up to you.
The c++ is the "right way" - (speaking of the "correct chat behaviour") to make what you mean (as far as I understand from the original post).
With the mentioned code you don't need to perform any "casts" (ray or box/container), so you save a lot on performance.
12/05/2007 (5:29 pm)
The "*A lot of clients can hit on performance." means if you use "usual script-routine". The c++ one gives more flexibiliy + performance.the "script only" changes allows you to limit the by "range from speaker" - does not matter if hes inside buiding or just on a "pure nature". The c++ (engine changes) allows you to make the send the chat message to "only players who is in visible range AND in the same "zone". the "Zone" means the same "room" inside the building.
What you need is up to you.
The c++ is the "right way" - (speaking of the "correct chat behaviour") to make what you mean (as far as I understand from the original post).
With the mentioned code you don't need to perform any "casts" (ray or box/container), so you save a lot on performance.
#6
Or can you limit the range anywhere?
12/06/2007 (1:00 am)
So it's just in the same room? What if you're outside? Does that mean everyone can see it outside?Or can you limit the range anywhere?
Torque Owner Mike Rowley
Mike Rowley
The common folder holds all the scripts that are common for most games. It is necessary unless you merge the files with the ones in the game folder.