Ban System

Started by Finch, Apr 16, 2015, 05:43 AM

Previous topic - Next topic

Finch

Hi guys i am facing problem on my ban system wen i ban my self itban me when i join with another nick its unban what is problem this is ban command and ban system

else if ( cmd == "ban" )
{
         if( stats[ player.ID ].Logged == false ) MessagePlayer( "Error - You don't have Login acess.", player);
   else if ( stats[ player.ID ].Level < 8 ) MessagePlayer( "Error - You don't have access to it.", player);
   else if ( !text ) MessagePlayer( "Error - Syntax: /ban <player> <reason>", player);
   else
   {
     local plr = GetPlayer( GetTok( text, " ", 1 ) );
     if ( !plr ) MessagePlayer( "Error - Unknown player.", player);
     else
     {
       local reason = GetTok( text, " ", 2 );
   if ( !reason ) reason = "None";
   Ban( plr, reason );
     }
   }
}



And this is function


function Ban( player, reason )
{
    QuerySQL( sqliteDB, "INSERT INTO Bans VALUES('" + player.Name.tolower() + "', '" + player.IP + "', '" + player.UniqueID + "', '" + reason + "')" );
 Message( "" + player.Name + " have been banned from the server. Reason: " + reason + "." );
    player.Kick();
player.UniqueID;
}


function CheckBan( player )
{
  local query = QuerySQL( sqliteDB, "SELECT * FROM Bans WHERE UID='" + player.UniqueID + "'" );
if( GetSQLColumnData( query, 0 ) ) return 1;
else return 0;
FreeSQLQuery( query );
}
Beztone is a scripter but he is too stupid

Thijn

First of all, that FreeSQLQuery will never be called. You return before that.
Better do something like this:
if( GetSQLColumnData( query, 0 ) ) {
FreeSQLQuery( query );
return 1;
} else {
FreeSQLQuery( query );
return 0;
}



Post your onPlayerJoin function. Also, did you check your database with something like SQLite Database Browser to see if the row is actually there?

Finch

ere is row in database and this is playerjoin

function onPlayerJoin( player )
{
if(timer_status == false)
                {
                        timer_status = true;
                        speedometer.Paused = false;
                        print("Timer Resumed");
                }
 if(player.Name=="Vice-City")
{
KickPlayer( player );
MessagePlayer( "Cant U this Nick", player );
}
MessagePlayer( "FBI Skin is For DeathMatching", player );
qPrivMessage( "Note: If u kill someone your stats will not update they will update when u leave server.", player );
local country = IpToCountry( player.IP );
        Message( "[#F5FFFA]"+player.Name+" Country: [#06FA16]"+country+"[#F5FFFA]." );
     ClientMessage( "pm >> Your Unique ID: " + player.UniqueID, player, 160, 5, 0 );
    wPrivMessage( "Welcome [" + player.Name + "] ",player );
    tPrivMessage( "Welcome to [ Adventure New City ] ",player );
     if ( CheckBan( player ) == 1 ) NewTimer( "Kick", 3000, 1, player.ID );   
     playerson.push( player.ID );
      stats[ player.ID ] = PlayerClass( player.Name, sqliteDB );
    stats[ player.ID ].Join( player );
    Message( "** [" + player.ID + "] " + player.Name + " has joined the server." );
    MessagePlayer( "Your LMS Stats: Played: " + stats[ player.ID ].Played + " Won: " + stats[ player.ID ].Wins + " Lost: " + stats[ player.ID ].Lost + " .", player);
MessagePlayer( "Your Stats: Kills: " + stats[ player.ID ].Kills + " Deaths: " + stats[ player.ID ].Deaths + ".", player);    
AddAlias( player );
}
Beztone is a scripter but he is too stupid

Rocky

Yes it is doing like you coded it to. your CheckBan( player ) function kicks only if player's name is banned not by its IP. Try checking IP or check both IP and nickname. I'm assuming you have stored IP in your column for storing IP Address. try using this:
function CheckBan( player )
{
  local query = QuerySQL( sqliteDB, "SELECT * FROM Bans WHERE IP='" + player.IP + "'" ); //Check by IP.
 if( GetSQLColumnData( query, 0 ) ) return 1;
 else return 0;
 FreeSQLQuery( query );
}

You can code the same to check nickname and check if both statements are true using if statement or do it in a single query.

PS: next time use code tag.

Finch

when i ban my self and join with anther nick hing happens he was unban on new nick and console give error on wrong number of paramettes
Beztone is a scripter but he is too stupid

Rocky

Quote from: Finch on Apr 17, 2015, 02:58 AMwhen i ban my self and join with anther nick hing happens he was unban on new nick and console give error on wrong number of paramettes

Which line does the error show, show me your kick function and one more thing, your function only checks if player's name is banned not its IP like i mentioned before. Even after you fix the parameter error player can join with another nick.

Finch

well there is no line mention on console and this is function kick
function Kick( player, admin, reason )
{
        SetKick(admin,GetKick(admin)+1);
         Message( "Admin " + admin + " Kicked " + player + " for Reason: " + reason );
Message( "[" + player.ID + "] " + player.Name + " left the Server. (Kicked)" );
         KickPlayer( player );
}
Beztone is a scripter but he is too stupid

Thijn

You kick the player in the onPlayerJoin with a timer, using the function Kick (Which you just posted) and the parameter player ID.
As you can see, your Kick function takes 3 parameters.

Finch

what paramet? what is my mistake?
Beztone is a scripter but he is too stupid

Finch

problem solve by my self but thnx






Beztone is a scripter but he is too stupid