Returning false on PlayerMessage doesn't suppress the message

Started by EK.IceFlake, May 02, 2017, 03:23 PM

Previous topic - Next topic

EK.IceFlake

I tried the following code to test something:
SqCore.On().PlayerMessage.Connect(function (player, message)
{
    return false;
});

But it doesn't suppress the message. In the official plugin, this would successfully suppress a message:
function onPlayerMessage(player, text)
{
    return false;
}

KAKAN

That's because they're so called "Signals". In the official plugin, you get only 1 call, but in SLC's plugin, you can have as many callbacks of the function as you want.
I think there's another way to block it, dunno for sure.

in case you're wondering what the first line meant:
SqCore.On().PlayerMessage.Connect(function (player, message)
{
    print("A");
});
SqCore.On().PlayerMessage.Connect(function (player, message)
{
    print("B");
});

function onPlayerMessage(player, text)
{
    print("A");
}
function onPlayerMessage(player, text)
{
    print("B");
}
oh no

EK.IceFlake

Quote from: KAKAN on May 02, 2017, 04:25 PMThat's because they're so called "Signals". In the official plugin, you get only 1 call, but in SLC's plugin, you can have as many callbacks of the function as you want.
I think there's another way to block it, dunno for sure.

in case you're wondering what the first line meant:
SqCore.On().PlayerMessage.Connect(function (player, message)
{
    print("A");
});
SqCore.On().PlayerMessage.Connect(function (player, message)
{
    print("B");
});

function onPlayerMessage(player, text)
{
    print("A");
}
function onPlayerMessage(player, text)
{
    print("B");
}
I knew all that. Now, how does that help me solve my question?

EK.IceFlake

Solved:
SqCore.On().PlayerMessage.Connect(function (player, message)
{
    SqBroadcast._Message("[#33CC33]User   [#FFFFFF]| [#" + format("%02X%02X%02X", player.Color.r, player.Color.g, player.Color.b) + "]" + player.Name + "[#FFFFFF]: " + message);
   
    SqCore.SetState(0);
});
Browsing through the source isn't all that easy...