Vice City: Multiplayer

Community Projects => SLC's Squirrel Plugin => Bug Reports => Topic started by: EK.IceFlake on May 02, 2017, 03:23 PM

Title: Returning false on PlayerMessage doesn't suppress the message
Post by: EK.IceFlake on May 02, 2017, 03:23 PM
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;
}
Title: Re: Returning false on PlayerMessage doesn't suppress the message
Post by: KAKAN on May 02, 2017, 04:25 PM
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");
}
Title: Re: Returning false on PlayerMessage doesn't suppress the message
Post by: EK.IceFlake on May 02, 2017, 04:27 PM
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?
Title: Re: Returning false on PlayerMessage doesn't suppress the message
Post by: EK.IceFlake on May 02, 2017, 05:58 PM
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...