SA-MP Forums Archive
MYSQL - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MYSQL (/showthread.php?tid=263807)



MYSQL - SILENT! - 23.06.2011

pawn Код:
if(mysql_num_rows() >= 1) {
                while(mysql_retrieve_row())
                {
                    new result[256], string[256];
                    mysql_fetch_field_row(result,"playerBanReason");
                    mysql_get_field("playerBanReason",result);
                    format(string,sizeof(string),"%s.",result);
                    SendClientMessage(extraid,COLOR_LIGHTRED,string);
                    Kick(extraid);
                }
            }

I just want to say the reason for ban . What's wrong with it?


Re: MYSQL - WackoX - 23.06.2011

What's wrong with it?


Re: MYSQL - SILENT! - 23.06.2011

It doesn't show me the reason. Just "."[dot] .


Re: MYSQL - SILENT! - 23.06.2011

pawn Код:
format(queryString, sizeof(queryString), "SELECT `banID` FROM `bans` WHERE `IPBanned` = '%s'", playerIP);
    mysql_query(queryString, THREAD_CHECK_BANS_LIST, playerid);
And from OnQueryFinish:

pawn Код:
case THREAD_CHECK_BANS_LIST: {
            mysql_store_result();

            if(!IsPlayerConnected(extraid))
                return mysql_free_result();

            if(mysql_num_rows() >= 1) {
                new result[256], string[256], querySz[256], ipban[64];
                GetPlayerIp(extraid, ipban, sizeof(ipban));
                format(querySz, sizeof(querySz), "SELECT playerBanReason FROM bans WHERE IPBanned = '%s'", ipban);
                mysql_query(querySz);
                mysql_store_result();
                mysql_fetch_field_row(result,"playerBanReason");
                mysql_get_field("playerBanReason",result);
                format(string,sizeof(string),"%s.",result);
                SendClientMessage(extraid,COLOR_LIGHTRED,string);
                Kick(extraid);
            }
I tried this way too, but it didn't work.


Re: MYSQL - xxmitsu - 23.06.2011

why are you sending 2 queries when you could send only one ? (do you need banid ?)

Also always free the result before storing another query

pawn Код:
.
    GetPlayerIp(playerid, ipban, sizeof(ipban));
    format(queryString, sizeof(queryString), "SELECT playerBanReason FROM bans WHERE IPBanned = '%s'", ipban);
    mysql_query(queryString, THREAD_CHECK_BANS_LIST, playerid);

pawn Код:
.
    case THREAD_CHECK_BANS_LIST: {
            mysql_store_result();

            if(!IsPlayerConnected(extraid))
                return mysql_free_result();

            if(mysql_num_rows() >= 1) {
                new result[128];
                mysql_fetch_field_row(result,"playerBanReason");
                format(string,sizeof(string),"Reason: %s.",result);
                SendClientMessage(extraid,COLOR_LIGHTRED,string);
                mysql_free_result();
                // perhaps adding a timer that calls kick is a good idea
                // since otherwise you'll be kicked too quickly and you won't see the ban message
                //Kick(extraid);
            }



Re: MYSQL - SILENT! - 23.06.2011

pawn Код:
format(queryString, sizeof(queryString), "SELECT `banID` FROM `bans` WHERE `IPBanned` = '%s'", playerIP);
    mysql_query(queryString, THREAD_CHECK_BANS_LIST, playerid);
pawn Код:
case THREAD_CHECK_BANS_LIST: {
            mysql_store_result();

            if(!IsPlayerConnected(extraid))
                return mysql_free_result();

            if(mysql_num_rows() >= 1) {
                new result[256], string[256], querySz[256], ipban[64];
                GetPlayerIp(extraid, ipban, sizeof(ipban));
                format(querySz, sizeof(querySz), "SELECT playerBanReason FROM bans WHERE IPBanned = '%s'", ipban);
                mysql_query(querySz);
                mysql_store_result();
                mysql_fetch_field_row(result,"playerBanReason");
                mysql_get_field("playerBanReason",result);
                format(string,sizeof(string),"%s.",result);
                SendClientMessage(extraid,COLOR_LIGHTRED,string);
                Kick(extraid);
            }
This checks if the IP is banned. I need to show the reason.


Re: MYSQL - SILENT! - 23.06.2011

Resolved.