Ban system error

Started by KAKAN, Aug 29, 2015, 04:50 PM

Previous topic - Next topic

KAKAN

[spoiler="Ban cmd"]    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 NumTok( text, " " ) );
           if ( !reason ) reason = "None";
           Ban( plr, player, reason );
         }
       }
    }[/spoiler]
[spoiler="Ban Function"]function Ban( plr, player, reason )
{
    QuerySQL( sqliteDB, "INSERT INTO Bans(Name, IP, UID, Reason, Time, Admin) VALUES('" + plr.Name + "', '" + plr.IP + "', '" + plr.UniqueID + "', '" + reason + "', '" + GetFullTime() + "', '"+player+"')" );
    EMessage( "Admin " + player + " has banned "+plr.Name+" from this server. Reason: " + reason + "." );
    plr.Kick();
}[/spoiler]

The ban system is working perfectly. I use the same function in IRC too

UBAN:-
Its the error, it says "The nick isn't banned....."
[spoiler="Unban cmd"]    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 );
              EMessage(">>  Admin " + player.Name + " has unbanned " + text );
       }
         else MessagePlayer(">> This nick isn't banned. Please type the banned nick.", player );
         FreeSQLQuery( query );
       }
    }[/spoiler]

[spoiler="Unban Function"]function Unban( text )
{
    QuerySQL( sqliteDB, "DELETE FROM Bans WHERE Name='" + text + "'" );
}[/spoiler]
oh no

Thijn

Check your database. Try executing the query manually to see if it actually works.

KAKAN

Yup tried it, it creates it in database, tried executing it manually still then didn't work
oh no

.

Don't take this as advertising but I really do recommend this SQLite plugin instead. It's way easier to debug because you get a descriptive error message if something fails in the query. And it's pretty much similar to the official one except the function names are different to avoid conflict.
.

KAKAN

I'm never gonna take your posts as advertise, I'm gonna try that SQLite plugin made by you
oh no

KAKAN

Thanks all! its working NOW!
oh no