SA-MP Forums Archive
MySQL R34 - Banning Player - 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: MySQL R34 - Banning Player (/showthread.php?tid=488659)



MySQL R34 - Banning Player - sammp - 18.01.2014

Alright so banning the player works fine, though this doesn't:

pawn Код:
stock CheckBan(playerid)
    {
        new dquery[256];
        format(dquery, sizeof(dquery), "SELECT FROM `bans` WHERE `IP` = '%s'", getIP(playerid));
        mysql_tquery(SQL, dquery, "", "");
        mysql_store_result();
       
        if(mysql_num_rows() > 0)
        {
            new reason[128], admin[25], pIp[25];
            cache_get_field_content(0, "Reason", reason);
            cache_get_field_content(0, "BannedBy", admin);
            cache_get_field_content(0, "IP", pIp);
            new string[1024];
           
            format(string, sizeof(string), "You have been blocked from playing here at Rural Roleplay.\n\nInformation of this ban:\n\n\nBanning Administrator: %s\nReason For Ban: %s\n\nYour Name: %s\nYour IP: %s - This IP is blocked", admin, reason, RemoveUnderScore(playerid), getIP(playerid));
            ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Information", string, "Exit", "");
           
            printf("%s", string);
            Kick(playerid);
        }
        else return 1;
        return 1;
       
    }



Re: MySQL R34 - Banning Player - Gh0s7 - 18.01.2014

You forgot *
Код:
format(dquery, sizeof(dquery), "SELECT * FROM `bans` WHERE `IP` = '%s'", getIP(playerid));



Re: MySQL R34 - Banning Player - sammp - 18.01.2014

Still not working..


Re: MySQL R34 - Banning Player - Vince - 18.01.2014

You muse use a callback! Those two parameters aren't there just for their good looks.
https://sampforum.blast.hk/showthread.php?tid=337810


Re: MySQL R34 - Banning Player - sammp - 18.01.2014

I've also tried using the two parameters, Vince but it gave the same result: nothing.

Can you provide me the codes that _should_ insert it? Thanks for helping, too


Re: MySQL R34 - Banning Player - InglewoodRoleplay - 18.01.2014

Quote:
Originally Posted by sammp
Посмотреть сообщение
I've also tried using the two parameters, Vince but it gave the same result: nothing.

Can you provide me the codes that _should_ insert it? Thanks for helping, too
Make that function a public and then call it by using

mysql_function_query(g_mysql_handle, szQuery, true, "CheckBanSQL", "d", playerid);
where szQuery would be your MySQL query.

Example:
pawn Код:
stock CheckBan(playerid) {
    new dquery[256];
    format(dquery, sizeof(dquery), "SELECT FROM `bans` WHERE `IP` = '%s'", getIP(playerid));
    mysql_function_query(g_mysql_handle, dquery, true, "CheckBanSQL", "d", playerid);
    return 1;
}
forward CheckBanSQL(playerid);

public CheckBanSQL(playerid) {
    new id_string[MAX_PLAYER_NAME];
    //new id;
    new rows,fields;
    cache_get_data(rows,fields);
   
    if(rows > 0) {
        new reason[128], admin[25], pIp[25];

        cache_get_row(0,1,id_string);
        format(reason, sizeof(id_string), "%s", id_string);
        cache_get_row(0,2,id_string);
        format(admin, sizeof(id_string), "%s", id_string);
        cache_get_row(0,3,id_string);
        format(ip, sizeof(id_string), "%s", id_string);
       
        new string[1024];
       
        format(string, sizeof(string), "You have been blocked from playing here at Rural Roleplay.\n\nInformation of this ban:\n\n\nBanning Administrator: %s\nReason For Ban: %s\n\nYour Name: %s\nYour IP: %s - This IP is blocked", admin, reason, RemoveUnderScore(playerid), getIP(playerid));
        ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Information", string, "Exit", "");
       
        printf("%s", string);
        Kick(playerid);
    }
    return 1;
}



Re: MySQL R34 - Banning Player - sammp - 18.01.2014

Still nothing..

I've got this under OnPlayerConnect:

CheckBan(playerid);

Should i put my OnPlayerConnect dialogs under CheckBan?