How can I add a timer to this?
#1

it's under OnPlayerConnect.

Basically, my server has a little lag I think and it logs the player in before checking if they're banned, theres nothing wrong with my code below, I think. It's just that when a player connects, it takes a while to load up and I'd like to let the server load up first before logging in?

pawn Код:
new escape[MAX_PLAYER_NAME*2];
    mysql_real_escape_string(GetName(playerid), escape);
    format(query, sizeof(query), "SELECT `id` FROM `accounts` WHERE `PlayerName` = '%s' LIMIT 1", escape);
    mysql_query(query);
    mysql_store_result();

    if(mysql_num_rows() > 0)
    {
        PlayerSQLID[playerid] = mysql_fetch_int();
        new string[256],ip[16], pip;

        Tazed[playerid] = 0;
        pip = GetPlayerIp(playerid, ip, sizeof(ip));
        Time[playerid] = gettime();
        BanTime[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "BanTime", "accounts");
        if(BanTime[playerid] > Time[playerid])
        {
            format(string,sizeof(string), "You are still {FF0000}BANNED{FFFFFF} from Bone County Roleplay until {FF0000}%s", date(BanTime[playerid]));
            SendClientMessage(playerid, COLOUR_WHITE, string);
            SendClientMessage(playerid, COLOUR_REALRED, "{FFFFFF}PLEASE DO {FF0000}NOT{FFFFFF} POST A {FF0000}BAN APPEAL {FFFFFF}as this is a Temporary Ban.");
            SetTimerEx("KickPlayer",100,false,"i",playerid);// Kicks player in 500ms
        }
        if(Time[playerid] > BanTime[playerid])   // Check when a player connects to see if they have a timestamp, and if they do, check if it exceeds gettime()
        {
           MySQL_SetInteger(PlayerSQLID[playerid], "BanTime", 0, "accounts");
        }
        if(IsPlayerBanned(playerid) == 1)
        {
            format(string,sizeof(string), "Your IP:{FF0000} %s{FFFFFF} is {FF0000}BANNED{FFFFFF} from Bone County Roleplay.", pip);
            SendClientMessage(playerid, COLOUR_WHITE, string);
            format(string, sizeof(string), "PLEASE POST A {FF0000}BAN APPEAL{FFFFFF} ON http://bc-rp.net/forum/");
            SendClientMessage(playerid, COLOUR_WHITE, string);
            SetTimerEx("KickPlayer",100,false,"i",playerid);// Kicks player in 500ms
        }
        if(BanTime[playerid] == 0 && IsPlayerBanned(playerid)== 0)
        {
            format(string, sizeof(string), "Welcome to %s (SQLID %d)\n\nPlease enter your password below:", HOSTNAME, PlayerSQLID[playerid]);
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login Dialog", string, "Login", "Leave");
        }
    }
    else
    {
        new string[256];
        format(string, sizeof(string), "Welcome to %s\n\nPlease create an account by entering a password below:", HOSTNAME);
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register Dialog", string, "Register", "Leave");
    }
    mysql_free_result();
}
Reply


Messages In This Thread
How can I add a timer to this? - by Dokins - 05.02.2013, 16:56
Re: How can I add a timer to this? - by Faisal_khan - 05.02.2013, 17:00
Re: How can I add a timer to this? - by Dokins - 05.02.2013, 17:05
Re: How can I add a timer to this? - by Faisal_khan - 05.02.2013, 17:06
Re: How can I add a timer to this? - by Dokins - 05.02.2013, 17:07
Re: How can I add a timer to this? - by Faisal_khan - 05.02.2013, 17:16
Re: How can I add a timer to this? - by Dokins - 05.02.2013, 17:18
Re: How can I add a timer to this? - by Faisal_khan - 05.02.2013, 17:20
Re: How can I add a timer to this? - by Dokins - 05.02.2013, 17:21
Re: How can I add a timer to this? - by Faisal_khan - 05.02.2013, 17:28

Forum Jump:


Users browsing this thread: 2 Guest(s)