Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Yankee on Jun 09, 2017, 07:37 AM

Title: Basic Anti Spam System
Post by: Yankee on Jun 09, 2017, 07:37 AM
Hi guys,
I searched a lot for a spam system for my server.I found some scripts but i can't use it properly.It gives script errors.I tried to make my own spam system but it don't work ,i did something wrong.Can someone help me ?
Title: Re: Basic Anti Spam System
Post by: SAzEe21 on Jun 09, 2017, 09:48 AM
Post your codes and errors here instead.
Title: Re: Basic Anti Spam System
Post by: Yankee on Jun 09, 2017, 04:18 PM
Quote from: Zeeshan.Bhatti on Jun 09, 2017, 09:48 AMPost your codes and errors here instead.

[b]Spammers <- array(100);
function onPlayerJoin(player)
{
    //...
    Spammers[player.ID] = ["", "", ""];
    //...
}
function onPlayerLeave(player, reason)
{
    //...
    Spammers[player.ID] = ["", "", ""];
    //...
}
function onPlayerMessage(player, message)
{
    Spammers[player.ID][0] = Spammers[player.ID][1];
    Spammers[player.ID][1] = Spammers[player.ID][2];
    Spammers[player.ID][2] = message;
    if (Spammers[player.ID][0] == Spammers[player.ID][1] && Spammers[player.ID][1] == Spammers[player.ID][2])
    {
        MessageAll(player.Name + " has been kicked for spamming.");
        player.Kick();
    }
}[/b]
Here it is,I added all of this to my main.nut.I added array 100 in scriptload.Why it it not working ?I did something wrong .
Title: Re: Basic Anti Spam System
Post by: NicusorN5 on Jun 09, 2017, 04:34 PM
remove [ b ] and  [/ b] from your code
Title: Re: Basic Anti Spam System
Post by: SAzEe21 on Jun 09, 2017, 05:19 PM
onPlayerLeave & onPlayerMessage which functions is this?
Title: Re: Basic Anti Spam System
Post by: Yankee on Jun 09, 2017, 08:35 PM
Quote from: Zeeshan.Bhatti on Jun 09, 2017, 05:19 PMonPlayerLeave & onPlayerMessage which functions is this?

My scripter friend send me this mate.He said if i add these into main.nut,ıt can work.Where should I add the onPlayerLeave and onPlayerMessage function's ?
Title: Re: Basic Anti Spam System
Post by: EK.IceFlake on Jun 10, 2017, 04:59 AM
Rename onPlayerLeave to onPlayerPart and onPlayerMessage to onPlayerChat.
Title: Re: Basic Anti Spam System
Post by: Yankee on Jun 10, 2017, 08:48 AM
Quote from: EK.IceFlake on Jun 10, 2017, 04:59 AMRename onPlayerLeave to onPlayerPart and onPlayerMessage to onPlayerChat.
Look at this,I added my scripts.Where did I wrong ?Can you find it,please.
This is array 100

function onScriptLoad()
{
{
print(">>> System SubBan loaded <<<");
db <- ConnectSQL( "DataBase.db" );
QuerySQL( db, "CREATE TABLE IF NOT EXISTS SubBans ( Name VARCHAR(32), IP VARCHAR(25), Admin TEXT, Reason TEXT )" );
}
    AddClass( 1, RGB( 0, 191, 255 ) ,201, Vector( 372, -478, 13.8172 ), 130.0325, 21, 999 ,17, 200, 4, 255 );
    AddClass( 1, RGB( 30,144,255 ) ,202 Vector( -660, 760, 11.0862 ), 130.0325, 101, 999 ,17, 200, 104, 1000 );
    AddClass( 1, RGB( 0, 139, 0 ) ,203, Vector( -1715.79, -160, 15 ), 140.020, 105, 999 ,100, 200, 12, 255 );
    AddClass( 2, RGB( 255, 48, 48 ) ,204, Vector( -25, 0, 24 ), 140.020, 103, 999 ,102, 25, 15, 50 );
    AddClass( 2, RGB( 255, 48, 48 ) ,205, Vector( -695, -1583, 12 ), 140.020, 19, 999 ,28, 100, 23, 1000 );
    AddClass( 1, RGB( 255, 215, 0 ) ,28, Vector( -1009, 196, 11.3937 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 3, RGB( 255, 255, 255 ) ,7, Vector( -841, 551, 10.930 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 4, RGB( 255, 255, 255 ) ,11, Vector( 464, -456, 10.532 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 5, RGB( 255, 255, 255 ) ,27, Vector( 387, -693, 10.97 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 6, RGB( 255, 255, 255 ) ,55, Vector( 464, -456, 10.532 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 7, RGB( 255, 255, 255 ) ,95, Vector( -213, -1440, 8.1129 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 8, RGB( 255, 255, 255 ) ,104, Vector( -776, 977, 10.8241 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 9, RGB( 255, 255, 255 ) ,114, Vector( -394, 894, 10.6133 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 10, RGB( 255, 255, 255 ) ,167, Vector( 464, -456, 10.532 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 11, RGB( 255, 255, 255 ) ,169, Vector( -855, 666, 10.9932 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 12, RGB( 255, 255, 255 ) ,131, Vector( -607, 652, 10.5843 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 13, RGB( 255, 255, 255 ) ,19, Vector( -842, -679, 10.9420 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 14, RGB( 255, 255, 255 ) ,58, Vector( 336, 1201, 17.1962 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 15, RGB( 255, 255, 255 ) ,13, Vector( -753, 927, 11.2812 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 16, RGB( 255, 255, 255 ) ,14, Vector( -782, 672, 10.8485 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 17, RGB( 255, 255, 255 ) ,17, Vector( 387, -693, 10.97 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 18, RGB( 255, 255, 255 ) ,21, Vector( -757, 1333, 11.39 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 19, RGB( 255, 255, 255 ) ,22, Vector( -975, -831, 6.4925 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 20, RGB( 255, 255, 255 ) ,54, Vector( -848, -909, 10.9547 ), 140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 21, RGB( 255, 255, 255 ) ,157, Vector( 387, -693, 10.97 ),  140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 22, RGB( 255, 255, 255 ) ,174, Vector( 387, -693, 10.97 ),  140.020, 0, 0 ,0, 0, 0, 0 );
    AddClass( 23, RGB( 255, 255, 255 ) ,100, Vector( 387, -693, 10.97 ), 140.020, 0, 0 ,0, 0, 0, 0 );
Spammers <- array(100);
}
This is PlayerJoin function

function onPlayerJoin( player )
{
                ClientMessage("-> [#daff00]Sunucumuza hosgeldiniz,/hesap yazarak girmeyi UNUTMAYIN.",player,255,0,102);
                ClientMessage("-> [#83bab3]Admin Facebook adresi:www.facebook.com/saidbali443",player,255,0,102);
                ClientMessage("-> [#83bab3]/komutlar yazarak komutlara bakabilirsiniz.",player,255,0,102);
                ClientMessage("-> [#83bab3]AY YILDIZ TURKEY.",player,255,0,102);
                NewTimer( "CheckBan", 1000, 1, player.ID );
    //...
    Spammers[player.ID] = ["", "", ""];
    //...   
}

This is PlayerPart function

function onPlayerPart( player, reason )
{
//...
Spammers[player.ID] = ["", "", ""];
//...
WriteIniBool("Stats.ini","Logged",player.UniqueID, false)
if (ReadIniBool("Stats.ini","Logged",player.UniqueID))
{
SaveAccount(player)
}
}

This is PlayerChat function

function onPlayerChat( player, text )
{
print( player.Name + ": " + text );
return 1;
    Spammers[player.ID][0] = Spammers[player.ID][1];
    Spammers[player.ID][1] = Spammers[player.ID][2];
    Spammers[player.ID][2] = message;
    if (Spammers[player.ID][0] == Spammers[player.ID][1] && Spammers[player.ID][1] == Spammers[player.ID][2])
    {
        MessageAll(player.Name + " spam yapmaktan ATILDI!");
        player.Kick();
    }
}











Title: Re: Basic Anti Spam System
Post by: SAzEe21 on Jun 10, 2017, 02:57 PM
You are ready to use this now, if any other error occurs you can post here.
Title: Re: Basic Anti Spam System
Post by: Yankee on Jun 10, 2017, 03:41 PM
Quote from: Zeeshan.Bhatti on Jun 10, 2017, 02:57 PMYou are ready to use this now, if any other error occurs you can post here.

I'm using now but it doesn't work,I did something wrong,command,line or column error etc.Can you check again for me ?
Title: Re: Basic Anti Spam System
Post by: SAzEe21 on Jun 10, 2017, 05:37 PM
Can you post the errors without that we can't help you.
Title: Re: Basic Anti Spam System
Post by: Yankee on Jun 10, 2017, 07:46 PM
Quote from: Zeeshan.Bhatti on Jun 10, 2017, 05:37 PMCan you post the errors without that we can't help you.

There's no error and it's not working ;D probably i did something wrong,maybe i forgot something important.Can you see something in the my commands.I pasted them.
Title: Re: Basic Anti Spam System
Post by: kennedyarz on Jun 10, 2017, 10:59 PM
Spammers <- array(100);change for
Spammers  <- array( GetMaxPlayers(), null );or
Spammers  <- array(100, null );
Title: Re: Basic Anti Spam System
Post by: Yankee on Jun 11, 2017, 09:40 AM
Quote from: kennedyarz on Jun 10, 2017, 10:59 PMSpammers <- array(100);change for
Spammers  <- array( GetMaxPlayers(), null );or
Spammers  <- array(100, null );
Thanks for you advice i added it but nothing changed :P
Title: Re: Basic Anti Spam System
Post by: EK.IceFlake on Jun 11, 2017, 10:05 AM
Quote from: kennedyarz on Jun 10, 2017, 10:59 PMSpammers <- array(100);change for
Spammers  <- array( GetMaxPlayers(), null );or
Spammers  <- array(100, null );
array defaults to null if no default value is specified (http://www.squirrel-lang.org/doc/squirrel3.html#d0e2365).
Title: Re: Basic Anti Spam System
Post by: Mötley on Jun 12, 2017, 10:29 AM
You stopped onPlayerChat( player, text), After that print( player.Name + ": " + text ).

Remove     

    print( player.Name + ": " + text );
    return 1;

function onPlayerChat( player, text )
{
 
    print( player.Name + ": " + text );
    //return 1;
    Spammers[player.ID][0] = Spammers[player.ID][1];
    Spammers[player.ID][1] = Spammers[player.ID][2];
    Spammers[player.ID][2] = message;
    if (Spammers[player.ID][0] == Spammers[player.ID][1] && Spammers[player.ID][1] == Spammers[player.ID][2])
    {
        MessageAll(player.Name + " spam yapmaktan ATILDI!");
        player.Kick();
    }
}



About the basic anti spam script, I really hate it.

And is it just me or once the player is done with a third message they get kicked regardless? No automatic method to clear the players spam, Nothing, And it kicks the player instead of muting them D:
Title: Re: Basic Anti Spam System
Post by: EK.IceFlake on Jun 12, 2017, 10:47 AM
Quote from: TurboGrafx on Jun 12, 2017, 10:29 AMAbout the basic anti spam script, I really hate it.

And is it just me or once the player is done with a third message they get kicked regardless? No automatic method to clear the players spam, Nothing, And it kicks the player instead of muting them D:
The OP requested a basic anti spam script and since I don't really like doing such stuff I sketched up a very basic anti spam script.
Title: Re: Basic Anti Spam System
Post by: Mötley on Jun 12, 2017, 11:01 AM
Just a preference:
I personally prefer adding something spam related to a player class, As well mute related, Add something to a player loop to decrease the spam integer if it were higher than 0.

And on each message increase the spam integer, maybe by five each time. if the spam integer is above 17 mute the player for five minutes.

Now set the mute to 300, And decrease it in seconds. This equals five minutes. Dont forget to clear the spam once muted.

And on player chat, If Mute is higher than 0, Or doesn't equal 0, Tell the player they are muted, Then return 0 on the players chat.

You could also add the mute value to the players accounts if spam is bad in your server, Hence so bad players just reconnect to remove the spam to continue spamming
Title: Re: Basic Anti Spam System
Post by: EK.IceFlake on Jun 14, 2017, 08:21 AM
Quote from: TurboGrafx on Jun 12, 2017, 11:01 AMJust a preference:
I personally prefer adding something spam related to a player class, As well mute related
Having separate arrays for different player values increases performance by reducing cache miss.