Black List
#1

I'm trying to make a blacklist and I'm coming up with nothing. Anyone know of any tutorials or someone who can possibly assist me?
Reply
#2

what u mean?
Reply
#3

Quote:
Originally Posted by X_Boy
Посмотреть сообщение
what u mean?
I'm trying to make something that loads a .ini file from scriptfiles full of blacklisted names, and if someone joins with one, it kicks them.
Reply
#4

Bump.. sorry for double post I just really need some help with this!
Reply
#5

https://sampforum.blast.hk/showthread.php?tid=235932
Reply
#6

I was bored so i wrote you a little script (using sqlite not ini files). I didn't create commands because i thought that would be pointless as you should need to be admin to use them. Create the commands yourself and use these functions.

You can paste it into your gamemode/admin script if needed. I haven't tested it but it should work.

3 functions the names explain what they do so i wont bother.

Код:
stock AddNameToBlacklist( szPlayerName[] )
stock AddPlayerToBlacklist( playerid )
stock IsPlayerBlacklisted( playerid )
CODE:

pawn Код:
#define FILTERSCRIPT

#include <a_samp>

new DB: dbBlacklist;

public OnFilterScriptInit()
{

    if( !fexist( "blacklist.db" ) )
    {
   
        dbBlacklist = db_open( "blacklist.db" );
       
        db_query( dbBlacklist, "CREATE TABLE blacklist (name VARCHAR(24))");
       
        if( fexist( "blacklist.db" ) )
            print("Blacklist database created");
        else
            print("Could not create blacklist database");
   
    }
    else
    {
        dbBlacklist = db_open( "blacklist.db" );
    }
   
    return 1;
}

public OnFilterScriptExit()
{

    db_close( dbBlacklist );

    return 1;
}

public OnPlayerConnect( playerid )
{

    if( IsPlayerBlacklisted( playerid ) )//player is blacklisted
    {
        //send message or whatever
        Kick( playerid );
    }

    return 1;
}

stock AddPlayerToBlacklist( playerid )
{
    new
        szQuery[ MAX_PLAYER_NAME + 64],
        szPlayerName[ MAX_PLAYER_NAME ];
       
    GetPlayerName( playerid, szPlayerName, MAX_PLAYER_NAME );
   
    format( szQuery, sizeof( szQuery ), "INSERT INTO blacklist (name) VALUES '%s'", szPlayerName );
   
    db_query( dbBlacklist, szQuery );
}

stock AddNameToBlacklist( szPlayerName[] )
{
    new szQuery[ MAX_PLAYER_NAME + 64];

    format( szQuery, sizeof( szQuery ), "INSERT INTO blacklist (name) VALUES '%s'", szPlayerName );

    db_query( dbBlacklist, szQuery );
}

stock IsPlayerBlacklisted( playerid )
{

    new
        DBResult: rResult,
        szQuery[ MAX_PLAYER_NAME + 64],
        szPlayerName[ MAX_PLAYER_NAME ];

    GetPlayerName( playerid, szPlayerName, MAX_PLAYER_NAME );
   
    format( szQuery, sizeof( szQuery ), "SELECT null FROM blacklist WHERE name='%s'", szPlayerName );
   
    rResult = db_query( dbBlacklist, szQuery );
   
    if( db_num_rows( rResult ) )
    {
        db_free_result( rResult );
        return 1;
    }
   
    db_free_result( rResult );
    return 0;

}
You will need to edit the code for your needs but everything needed is provided, and it will be a lot better than using ini files.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)