Author Topic: ChatMsgAll outside of minigames  (Read 1033 times)

In case you guys missed the subtlety in port's post, you should use messageAll for the chatmessage one instead of overcomplicating things
I forgot those commands existed.

Code: [Select]
registerOutputEvent(fxDtsBrick, "ChatMessageServer", "STRING 200 150", 1);
registerOutputEvent(fxDtsBrick, "CenterPrintServer", "STRING 200 150 INTEGER 0 10", 1);
registerOutputEvent(fxDtsBrick, "BottomPrintServer", "STRING 200 150 INTEGER 0 10 BOOL", 1);

function fxDtsBrick::ChatMessageServer(%this, %msg, %oClient)
{
messageAll('', %msg);
}

function fxDtsBrick::CenterPrintServer(%this, %msg, %time, %oClient)
{
centerprintall(%msg, %time);
}

function fxDtsBrick::BottomPrintServer(%this, %msg, %time, %bar, %oClient)
{
bottomprintall(%msg, %time, %bar);
}

I'm working on a mod to add targets to existing input events. Once it's done you'll be able to make an event like:

onActivate => Server => chatMsgAll blah

Or you could just use the announce command. That usually works.

Which would be pointless, because all it does is this:

Code: [Select]
function announce( %message )
{
messageAll( '', %mesage );
}

Which would be pointless, because all it does is this:

Code: [Select]
function announce( %message )
{
messageAll( '', %mesage );
}
I know but it's just another way of doing it. :)

Is clientGroup.get(%i); even valid?

Is clientGroup.get(%i); even valid?

Oh wow, didn't notice that one.
Nope, you're right, the method they should be using is getObject.
This is also the definite reason for why their code not working for the OP.

Code: [Select]
registerOutputEvent(fxDtsBrick, "ChatMessageServer", "STRING 200 150", 1);
registerOutputEvent(fxDtsBrick, "CenterPrintServer", "STRING 200 150 INTEGER 0 10", 1);
registerOutputEvent(fxDtsBrick, "BottomPrintServer", "STRING 200 150 INTEGER 0 10 BOOL", 1);

function fxDtsBrick::ChatMessageServer(%this, %msg, %oClient)
{
messageAll('', %msg);
}

function fxDtsBrick::CenterPrintServer(%this, %msg, %time, %oClient)
{
%numClients = ClientGroup.getCount();
for(%i; %i<numClients; %i++)
{
%client = ClientGroup.getObject(%i);
%client.centerPrint(%msg,%time);
}
}

function fxDtsBrick::BottomPrintServer(%this, %msg, %time, %bar, %oClient)
{
%numClients = ClientGroup.getCount();
for(%i; %i<numClients; %i++)
{
%client = ClientGroup.getObject(%i);
%client.bottomPrint(%msg,%time,%bar);
}
}
If the latest code by pecon doesn't work or if anyone finds this piece of code useful, here you go.

I tested it and it works, I'll package it by myself tomorrow. Thanks a very big lot, all of you :D
Gonna get some sleep first.

I packaged it and completely forgot to test all events, only ChatMsgAll seems to be working, centerprint and bottomprint aren't. I only needed chatmsg, so it's no problem, but I can see other people wanting to use that.

Code: [Select]
registerOutputEvent(fxDtsBrick, "ChatMessageServer", "STRING 200 150", 1);
registerOutputEvent(fxDtsBrick, "CenterPrintServer", "STRING 200 150 INTEGER 0 10", 1);
registerOutputEvent(fxDtsBrick, "BottomPrintServer", "STRING 200 150 INTEGER 0 10 BOOL", 1);

function fxDtsBrick::ChatMessageServer(%this, %msg, %oClient)
{
messageAll('', %msg);
}

function fxDtsBrick::CenterPrintServer(%this, %msg, %time, %oClient)
{
centerPrintAll(%msg,%time);
}

function fxDtsBrick::BottomPrintServer(%this, %msg, %time, %bar, %oClient)
{
bottomPrintAll(%msg,%time,%bar);
}
If the latest code by pecon doesn't work or if anyone finds this piece of code useful, here you go.
Removed useless code

why is the client being appended?

you don't need it for anything

why is the client being appended?

you don't need it for anything
There's supposed to be code there to convert %1 to the client's name.