Biiig question, help
#1

Hey there.


So, I have ban system, it add's player info banned = 1.
So how can I make some IP Bans table, and it selects from that table.

If on player connect this IP is on that list, he will get kicked.
Please help
Reply
#2

You can use /rcon ban or
pawn Код:
dcmd_ban(playerid,params[])
{
    if(AccInfo[playerid][LoggedIn] == 1)
    {
        if(AccInfo[playerid][Level] >= 4)
        {
            new Index;
            new tmp[256];  tmp  = strtok(params,Index);
            new tmp2[256]; tmp2 = strtok(params,Index);

            if(!strlen(params)) return
            SendClientMessage(playerid, LIGHTBLUE2, "Usage: /ban [PlayerID] [Reason]") &&
            SendClientMessage(playerid, orange, "Function: Will Ban the specified player");
            if(!strlen(tmp2))
            return SendClientMessage(playerid, red, "ERROR: Reason unspecified!");
            new player1;
            new string[128];
            new playername[MAX_PLAYER_NAME];
            new adminname [MAX_PLAYER_NAME];
            player1 = strval(tmp);

            if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (AccInfo[player1][Level] != ServerInfo[MaxAdminLevel]))
            {
                GetPlayerName(player1, playername, sizeof(playername));
                GetPlayerName(playerid, adminname, sizeof(adminname));
                new year,month,day; getdate(year, month, day);
                new hour,minuite,second; gettime(hour,minuite,second);
                SendCommandToAdmins(playerid,"Ban");
                format(string,sizeof(string),"|- %s has been Banned by Administrator %s | Reason: %s [Date: %d/%d/%d] [Time: %d:%d]",playername,adminname,params[2],day,month,year,hour,minuite);
                SendClientMessageToAll(lightred,string);
                new str[128];
                format(str,sizeof(str),"%s has been Banned by Administrator %s | Reason: %s",playername,adminname,params[2]);
                SaveIn("BanLog",str);
                print(string);
                if(udb_Exists(PlayerName2(player1)) && AccInfo[player1][LoggedIn] == 1)
                dUserSetINT(PlayerName2(player1)).("Banned",1);
                format(string,sizeof(string),"Banned by Administrator %s. | Reason: %s",adminname,params[2]);
                return BanEx(player1, string);
            }
            else return SendClientMessage(playerid, red, "ERRPR: Player is not connected or is yourself or is the highest level admin");
        }
        else return ErrorMessages(playerid, 1);
    }
    else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
Reply
#3

I didn't mean that..
I MEAN:
If player conńects, and his/her IP is on that BANS mysql table list, then he gets kicked.
Reply
#4

BUMP..

It's somehow with SELECT * From `bans` where Name ....
Reply
#5

DELETED
Reply
#6

NewbBeginner,u can use dini to store in a bannedip.log file all the ips then using dini_get OnPlayerConnect to check the IP.
Reply
#7

As I said, it is with MYSQL, and it's more difficult than with dini.
Reply
#8

Hmm... that's a really tricky one.

What I'd suggest to do is:

Create a new table with the IP, and A Tinyint called active. the size of IP should be 50, and the size of the Tinyint should be 15.

Now, the whole concept is, when the user is banned, their IP is sent to the table, and the Tinyint called 'active' is set to one. After that, go back to the gamemode and do this.

You need to create something that checks the table for that IP the user connects with, and see if the 'active' is set to either 1, or 0. If it is 1, refuse the connection, by kicking the player. If it is 0, let them connect.

So:

pawn Код:
new
       k[1][50],
       string[128], //optional; if you have a global query, delete this
       pIP[16]; //for player IP

   GetPlayerIp(playerid, pIP, 16);

    format(string, 128, "SELECT IP from TableName WHERE active = 1");
    mysql_query(string);
    mysql_store_result();
    mysql_free_result();

//and so on
But note, you might get a bug where it checks all the IP's, when you're only looking for the one IP the user connected with, be careful. And this has not even been tested, so don't blame me if it doesn't work. I'm trying to help you get a headstart on this.
Reply
#9

Hiitchy you are a noob!

pawn Код:
new
       string[128], //optional; if you have a global query, delete this
       pIP[16]; //for player IP

   GetPlayerIp(playerid, pIP, 16);

    format(string, 128, "SELECT COUNT(*) from TableName WHERE active = 1 AND IP='%s'",pIP);
    mysql_query(string);
    mysql_store_result();
    new banned = mysql_fetch_int();
    mysql_free_result();

    if(banned)
    {
           Kick(playerid);
           return 1;
    }
Anyway if you used Ban(playerid); , it is impossible to join back from this IP.
Reply
#10

Uhm, I created a table called bans.

Now, my ban command - it somehow need to set in that table active 1 & IP banned player IP.
But, I need to make some player name too in that BANS table ? like ban, active, IP.
Please help me, i need whole code.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)