SA-MP Forums Archive
small problem. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: small problem. (/showthread.php?tid=329691)



small problem. - EviLpRo - 29.03.2012

hello.

this code check if player has ban:

(onplayerconnect)

pawn Код:
format(String,256,"SELECT * FROM `Bans` WHERE `Username`='%s' OR `IP`='%s'",GetName(playerid),GetIP(playerid));
    mysql_query(String);
    mysql_store_result();
    if(mysql_num_rows())
    {
        new baninfo[8][35];
        while(mysql_retrieve_row())
        {
            mysql_fetch_field_row(baninfo[0],"Username");
            mysql_fetch_field_row(baninfo[1],"Adminname");
            mysql_fetch_field_row(baninfo[2],"Reason");
            mysql_fetch_field_row(baninfo[3],"Date");
            mysql_fetch_field_row(baninfo[4],"Time");
            mysql_fetch_field_row(baninfo[5],"IP");
            mysql_fetch_field_row(baninfo[6],"Type");
            mysql_fetch_field_row(baninfo[7],"Days");
        }
        if(strval(baninfo[6]) == 1 && strval(baninfo[7]) < 1)
        {
            format(String,128,"DELETE FROM `Bans` WHERE `Username`='%s' OR `IP`='%s'",GetName(playerid),GetIP(playerid));
            mysql_query(String);
            SendClientMessage(playerid,c_red,".дбап щмк йшг, лрс озгщ");
        }
        else
        {
            SendClientMessage(playerid,c_red,"You are banned from this server.");
            format(String,256,"Ban Info: (Admin: %s | User: %s) (IP: %s)",baninfo[1],baninfo[0],baninfo[5]);
            SendClientMessage(playerid,c_lightblue,String);
            format(String,256,"Ban Info: (Reason: %s | Ban type: %s)",baninfo[2],(strval(baninfo[6])==0)?("Permanent"):("Temporary"));
            SendClientMessage(playerid,c_lightblue,String);
            format(String,256,"Ban Info: (Date: %s | At: %s) (End ban: %s%s)",baninfo[3],baninfo[4],(strval(baninfo[6])==0)?("Never"):(GetNum(strval(baninfo[7]))),(strval(baninfo[6])==0)?(""):(" days"));
            SendClientMessage(playerid,c_lightblue,String);
            SendClientMessage(playerid,c_green,"ан дйрк зещб щбап жд айре оецгч, аъд оежоп мтштш тмйе");
            SendClientMessage(playerid,c_green,"suport.GTAZONE.co.il -бфешен дъойлд щм дчдймд щмре, блъебъ");
        }
        return Kick(playerid);
    }
    mysql_free_result();
but is happen very slowly (the server pause [freeze] in "Join to server" message)
what is the problem with the code ?

thank's a lot


Re: small problem. - CoaPsyFactor - 29.03.2012

while(mysql_retrieve_row()) this is part that slow down your server


Re: small problem. - Partner - 29.03.2012

Try to give the server more cells in 'baninfo'
See:
pawn Код:
new baninfo[8][60];
It's not a smart suggestion... but better then nothing.


Re: small problem. - EviLpRo - 01.04.2012

not working..
please more help


Re: small problem. - EviLpRo - 01.04.2012

bump...
please help


Re: small problem. - WooTFTW - 01.04.2012

If it lags the server, thread the query.