Ban check wont work
#1

Hey guys well im updating my server to R39 MySQL, and ban check is refusing to work. I put myself into bans in MySQL database, and the mysql seems to find me in there, but nothing happens. Heres my script:

pawn Код:
stock CheckBans(playerid)
{

    // Create variables
    new
        banned_pname[24],
        MySQLQuery[255],
        Year,
        Month,
        Day,
        Hour,
        Min,
        Sec,
        query[200];

    new rows, fields;
       
    getdate(Year, Month, Day);
    gettime(Hour,Min,Sec);

    GetPlayerName(playerid,banned_pname,sizeof(banned_pname));

   
    mysql_format(mysql, query, sizeof(query), "SELECT * FROM `banai` WHERE `Player` = '%s' OR `IP` = '%s'", banned_pname, IP[playerid]);
    mysql_tquery(mysql, query);
   
    cache_get_data(rows, fields, mysql);//let's get the rows and fields from the database.

    if(rows)
    {
   
   
       format(TempStr, sizeof(TempStr), "{FF0000}» {CC6600}Jums yra {FF0000}draudziama {CC6600}zaisti siame serveryje!\n{FF0000}» {CC6600}Noredami vel zaisti musu serveryje, siuskite SMS zinute uz {FF0000}5 LT / 1.45 Ђ\n{FF0000}» {CC6600}Tekstas: {FF0000}unbanfz %s\n{FF0000}» {CC6600}Numeris: {FF0000}1398\n{FF0000}» {CC6600}Varda zaidime reikia nurodyti, su kuriuo buvote uzblokuotas.", banned_pname);
       ShowPlayerDialog(playerid,678,DIALOG_STYLE_MSGBOX,"{FF0000}Jus esate uzblokuotas!",TempStr,"Iseiti","");
       PlayerPlaySound(playerid, 1057,0.0,0.0,0.0);

        // Send message to all players on server
        format(TempStr, sizeof (TempStr), "[FunZoneLT]>> Zaidejas %s(%d) buvo automatiskai ismestas, kadangi jis yra uzblokuotas.", banned_pname, playerid);
        SendClientMessageToAll(raudona, TempStr);
        // Kick player
        SetTimerEx("IsmestiZaideja",300,false,"d",playerid);
    }
    return 1;
}
this is the MySQL log:

Код:
[21:53:23] [DEBUG] cache_get_data - connection: 1
[21:53:23] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[21:53:40] [DEBUG] mysql_format - connection: 1, len: 200, format: "SELECT * FROM `banai` WHERE `Player` = '%s' OR `IP` = '%s'"
[21:53:40] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `banai` WHERE `Player` = 'TypeR' OR `IP` = 'РH„Аь", callback: "(null)", format: "(null)"
[21:53:40] [DEBUG] cache_get_data - connection: 1
[21:53:40] [WARNING] cache_get_data - no active cache
I have no idea why the IP appears like that though. Cause i get it onplayerconnect, and save it into a string instantly that works all over the script. Anyone know why the script wouldnt get be as banned?
Reply
#2

You do need to use my sql_tquery();
Reply
#3

ok, it works now. My question is though why would tquery not work? And do i need to somehow now free the results? Thank you.
Reply
#4

I was looking up sql_tquery and i cannot seem to find it for SA-MP?
Reply
#5

mysql_tquery doesn't work because tquery is threaded. The results of queries done by tquery and pquery are sent to a callback that you can specifiy.
The way you coded it is non-threaded, which will work with mysql_query

https://sampwiki.blast.hk/wiki/MySQL/R33
That's some newer documentation, read it.
Reply
#6

I just did says that: callback[] The query you want to process (optional).
format[] The format specifier string (optional).
{Float,_}:... Indefinite number of arguments (optional). In my uderstanding their optional??
Reply
#7

They are optional because the results of queries like UPDATE and DELETE don't return any data that you need (in some cases you do, but only rarely). So you can just leave the callback and following parameters empty and it'll ignore the results. If this wasn't possible you'd have to make callbacks without any code in them, which is useless.
Reply
#8

i have the code but not mysqlR39
Reply
#9

ok, soa threaded would be more efficient, if i basically did a TQuery onplayerconnect, that linked to stock CheckBans(playerid)? And one more question. How do i free the results of the regular queries? Can someone just give me a small example? Thank you.
Reply
#10

Hey guys why is this happening when loading IP from databse?

pawn Код:
[21:53:40] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `banai` WHERE `Player` = 'TypeR' OR `IP` = 'РH„Аь", callback: "(null)", format: "(null)"
I dont understand why it does this when it saves this before, i set it as a string.

Heres the lines that put the BAN on player:

pawn Код:
mysql_format(mysql, query, sizeof(query), "INSERT INTO `banai` ( `Admin`, `Player`, `Reason`, `IP`) VALUES ('%s', '%s', '%s', '%s')", Admin, banned_pname, Reason, IP);
    mysql_tquery(mysql, query);
How i get the IP onplayerconnect:

pawn Код:
GetPlayerIp(playerid, IP[playerid], 16);
At the top of the script:

pawn Код:
static
    mysql, //This variable will be used to manage our database
    Name[MAX_PLAYERS][24], //We will use this variable to store player's name.
    IP[MAX_PLAYERS][16] //We will use this variable to store player's ip.
    ;
What could be the issue?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)