Vice City: Multiplayer

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

Title: Returning false on PlayerMessage doesn't suppress the message
Post by: EK.IceFlake on May 2nd, 2017, 04:23 PM
I tried the following code to test something:
Code: [Select]
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:
Code: [Select]
function onPlayerMessage(player, text)
{
    return false;
}
Title: Re: Returning false on PlayerMessage doesn't suppress the message
Post by: KAKAN on May 2nd, 2017, 05: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:
Code: [Select]
SqCore.On().PlayerMessage.Connect(function (player, message)
{
    print("A");
});
SqCore.On().PlayerMessage.Connect(function (player, message)
{
    print("B");
});

Code: [Select]
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 2nd, 2017, 05:27 PM
Quote from KAKAN on May 2nd, 2017, 05: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:
Code: [Select]
SqCore.On().PlayerMessage.Connect(function (player, message)
{
    print("A");
});
SqCore.On().PlayerMessage.Connect(function (player, message)
{
    print("B");
});

Code: [Select]
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 2nd, 2017, 06:58 PM
Solved:
Code: [Select]
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...