Jump to content

Question

Posted

Salut, am doua probleme. 1. am doua warning-uri (warning 219: local variable "CheckPlayerAccount" shadows a variable at a preceding level), si 2. nu imi apare dialogul sa ma inregistrez/loghez

COD:

public OnPlayerRequestClass(playerid, classid)
{
    TogglePlayerSpectating(playerid, true);
    gQuery[0] = (EOS);
    inline checkBan()
    {
        if(!cache_num_rows())
        {
            // Login
            WARNING inline CheckPlayerAccount()
            {
                gQuery[0] = (EOS);
                mysql_format(SQL, gQuery, 256, "SELECT * FROM `server_bans_ip` WHERE `PlayerIP` = '%d' AND `Active` = '1' LIMIT 1", getIp(playerid));
                mysql_pquery(SQL, gQuery, "CheckPlayerBanIP", "d", playerid);            
            }
            return true;
        }

        new adminName[MAX_PLAYER_NAME], reason[64], date[64];
        cache_get_field_content(0, "AdminName", adminName, SQL, MAX_PLAYER_NAME);
        cache_get_field_content(0, "Reason", reason, SQL, 64);
        cache_get_field_content(0, "Date", date, SQL, 64);

        // Check Permanent Ban
        if(cache_get_field_content_int(0, "Permanent") != 0)
        {
            ClearChat(playerid);

            SCMF(playerid, COLOR_CLIENT, "SERVER: {FFFFFF}You are banned on this server by %s, reason: %s.", adminName, reason);
            SCMF(playerid, COLOR_CLIENT, "SERVER: {FFFFFF}You are banned from %s.", date);
            SCM(playerid, COLOR_CLIENT, "SERVER: {FFFFFF}This ban is permanent, meaning that it will never expire.");

            defer KickEx(playerid);
            return true;
        }

        // Check Temporar Ban
        if(cache_get_field_content_int(0, "Days") > gettime())
        {
            ClearChat(playerid);

            new year, month, day, hour, minute, second;
            TimestampToDate(cache_get_field_content_int(0, "Days"), year, month, day, hour, minute, second, 2);

            SCMF(playerid, COLOR_CLIENT, "SERVER: {FFFFFF}You have been banned by %s, reason: %s.", adminName, reason);
            SCMF(playerid, COLOR_CLIENT, "SERVER: {FFFFFF}You are banned from %s to %02d:%02d:%02d : %02d/%02d/%d.", date, hour, minute, second, day, month, year);
            
            defer KickEx(playerid);
            return true;
        }

        mysql_format(SQL, gQuery, 256, "SELECT * FROM `server_bans_ip` WHERE `PlayerIP` = '%d' AND `Active` = '1' LIMIT 1", getIp(playerid));
        mysql_pquery(SQL, gQuery, "CheckPlayerBanIP", "d", playerid);

        // Disable Ban
        mysql_format(SQL, gQuery, 256, "UPDATE `server_bans` SET `Active` = '0' WHERE `ID` = '%d'", cache_get_field_content_int(0, "ID"));
        mysql_tquery(SQL, gQuery);
        return true;
    }

    // Check Ban
    mysql_format(SQL, gQuery, 256, "SELECT * FROM `server_bans` WHERE `PlayerName` = '%s' AND `Active` = '1' LIMIT 1", GetName(playerid));
    mysql_pquery_inline(SQL, gQuery, using inline checkBan, "");    
    return 1;
}

function CheckPlayerBanIP(playerid)
{
    if(!cache_num_rows())
    {
        gQuery[0] = (EOS);
        WARNING inline CheckPlayerAccount()
        {
            if(!cache_num_rows()) return Dialog_Show(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Login", "Welcome to Wing RPG, %s.\nType a password to register your account:", "Register", "Cancel", GetName(playerid));
            
            new lastLogin[64];
            cache_get_field_content(0, "LastLogin", lastLogin, SQL, 64);

            Dialog_Show(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Welcome back to Wing RPG, %s.\nType your password to login:\n\nLast login: %s", "Login", "Cancel", GetName(playerid), lastLogin);
            //PlayerInfo[playerid][pLoginTimer] = defer LoginTimer(playerid);
            return true;
        }
        mysql_format(SQL, gQuery, sizeof gQuery, "SELECT * FROM `server_accounts` WHERE `Name` = '%s' LIMIT 1", GetName(playerid));
        mysql_pquery_inline(SQL, gQuery, using inline CheckPlayerAccount, "");        
        return true;
    }

    new AdminName[MAX_PLAYER_NAME], Reason[64], Date[32];
    cache_get_field_content(0, "AdminName", AdminName, SQL, MAX_PLAYER_NAME);
    cache_get_field_content(0, "Reason", Reason, SQL, 64);
    cache_get_field_content(0, "Date", Date, SQL, 32);

    SCMF(playerid, COLOR_CLIENT, "SERVER: {FFFFFF}IP %s is banned on this server by %s, reason: %s.", getIp(playerid), AdminName, Reason);
    SCMF(playerid, COLOR_CLIENT, "SERVER: {FFFFFF}You are banned from %s.", Date);
    SCM(playerid, COLOR_CLIENT, "SERVER: {FFFFFF}This ban is permanent, meaning that it will never expire.");
    return true;
}

Se poate sa ma ajute cineva?

9 answers to this question

Recommended Posts

  • 0
Posted

OnPlayerRequestClass nu este folosit deobicei pentru asa ceva, eu iti las un model cu OnPlayerConnect, nu stiu ce versiune de mysql folosesti, am incercat cat de cat sa incorporez cache-urile in scriptul meu.

Acesta este modelul: https://pastebin.com/yS8KKAYL

Sper sa te ajute

  • Upvote 1
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.