Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: KAKAN on Jul 23, 2015, 08:29 AM

Title: unban problem(same as kokia)
Post by: KAKAN on Jul 23, 2015, 08:29 AM
    else if ( cmd == "unban" )
    {
       if ( stats[ player.ID ].Level < 4 ) MessagePlayer( "Error - You don't have access to it.", player);
       else if ( !text ) MessagePlayer( "Error - Syntax: /unban <player name>", player);
       else
       {       
         local query = QuerySQL( sqliteDB, "SELECT * FROM Bans WHERE Name='" + text + "'" );
         if( GetSQLColumnData( query, 0 ) ) Unban( text );
         else MessagePlayer( "This nick isn't banned. Please type the banned nick.", player );
         FreeSQLQuery( query );
       }
    }

Every time I try to unban anyone, it shows "This nick isn't banned. Please type the banned nick.", I need help tho
Title: Re: unban problem(same as kokia)
Post by: Thijn on Jul 23, 2015, 08:37 AM
Are you actually banned? Check your database.
Title: Re: unban problem(same as kokia)
Post by: KAKAN on Jul 23, 2015, 08:51 AM
I tried to ban myself and then I banned it, its in the db file, but I can't unban me from /unban cmd, if no ways are there then i'll have to unban myself using DB
Title: Re: unban problem(same as kokia)
Post by: Thijn on Jul 23, 2015, 08:54 AM
Show your ban command.
Title: Re: unban problem(same as kokia)
Post by: KAKAN on Jul 23, 2015, 09:02 AM
LOL, I posted it in codes, see the topic xD
anyways here it is:-
    else if ( cmd == "unban" )
    {
       if ( stats[ player.ID ].Level < 4 ) MessagePlayer( "Error - You don't have access to it.", player);
       else if ( !text ) MessagePlayer( "Error - Syntax: /unban <player name>", player);
       else
       {       
         local query = QuerySQL( sqliteDB, "SELECT * FROM Bans WHERE Name='" + text + "'" );
         if( GetSQLColumnData( query, 0 ) ) Unban( text );
         else MessagePlayer( "This nick isn't banned. Please type the banned nick.", player );
         FreeSQLQuery( query );
       }
    }
Title: Re: unban problem(same as kokia)
Post by: Thijn on Jul 23, 2015, 09:03 AM
Quote from: Thijn on Jul 23, 2015, 08:54 AMShow your ban command.
Title: Re: unban problem(same as kokia)
Post by: KAKAN on Jul 23, 2015, 09:07 AM
Oh sorry I mistaken it, sorry
here is the code:-
    else if ( cmd == "ban" )
    {
       if ( stats[ player.ID ].Level < 4 ) 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 );
   kick.plr();
         }
       }
    }

Sorry :(
Title: Re: unban problem(same as kokia)
Post by: Thijn on Jul 23, 2015, 09:17 AM
Post your Ban function as well :P
Title: Re: unban problem(same as kokia)
Post by: KAKAN on Jul 23, 2015, 09:26 AM
k
here it is:-
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 + "." );
}
Title: Re: unban problem(same as kokia)
Post by: Thijn on Jul 23, 2015, 09:28 AM
In that case you should fix that SQL query in your unban function to use Name='" + text.tolower() + "'
Title: Re: unban problem(same as kokia)
Post by: KAKAN on Jul 23, 2015, 09:37 AM
Thanks, it worked!
Locked.