tempban tostring problem

Started by Nihongo^, Aug 12, 2023, 08:06 AM

Previous topic - Next topic

Nihongo^

My temp ban is working perfectly but whenver this guy name "[THC]^CUTE^295" joins the server  it gives an error here

local banType = GetSQLColumnData(q, 9).tostring();

Here's my full checktempban function

function CheckTempBan(player) {
    local q = QuerySQL(db, "SELECT * FROM TempBans WHERE Name='" + escapeSQLString(player.Name) + "' OR IP='" + escapeSQLString(player.IP) + "' OR UID='" + escapeSQLString(player.UniqueID) + "' OR UID2='" + escapeSQLString(player.UniqueID2) + "'");
    if (q) {
        local banType = GetSQLColumnData(q, 9).tostring(); <--- Line 518
                local currentTime = time();
            local banStartTime = GetSQLColumnData(q, 4).tointeger();
            local banDuration = GetSQLColumnData(q, 5).tointeger();
            if (currentTime - banStartTime >= banDuration) {
                QuerySQL(db, "DELETE FROM TempBans WHERE LOWER(Name)='" + player.Name.tolower() + "'");
            } else {
                local timeLeft = banDuration - (currentTime - banStartTime);
                ServerMessage("[#FF0000][PRIOR BAN]: [#FFFFFF] [ " + player.Name + " ] is banned for Reason: [ " + GetSQLColumnData(q, 8) + " ]");
                ServerMessage("[#FF0000][PRIOR BAN]: [#FFFFFF] TimeLeft: [ " + GetBanRemainingTime(GetSQLColumnData(q, 4).tointeger(), GetSQLColumnData(q, 6).tostring()) + " ], Admin: [ " + GetSQLColumnData(q, 7) + " ]");
                EchoMessage("[PRIOR BAN]: [ " + player.Name + " ] is banned for Reason: [ " + GetSQLColumnData(q, 8) + " ] TimeLeft: [ " + GetBanRemainingTime(GetSQLColumnData(q, 4).tointeger(), GetSQLColumnData(q, 6).tostring()) + " ], Admin: [ " + GetSQLColumnData(q, 7) + " ]");
        player.Kick();         
        }
        }
        }
        }

Kindly explain me about "tostring();" is it really necessary ? and what is it ?
Thank you in advance

habi

#1
Show the result of print statement:
print(GetSQLColumnData(q, 9));
local banType = GetSQLColumnData(q, 9).tostring()


tostring converts number, boolean, etc into string
local a=2;
local b= a.tostring()
//a=2 and b="2"

Nihongo^

Ah damn, i just figure out the data inside the table in "NULL" didn't check
Problem sovled