Convert Timer [+REP]
#1

PHP код:
function BanListCheck(playerid)
{
    new 
count_rowsfieldsbField[2][512], Days[4], sebStr[128]; eString[0] = EOScache_get_data(count_rowsfieldsDB_Connect);
    
//--------------------------------------------------------------------------
    
if(count_rows)
    {
        
Days[0] = cache_get_field_content_int(0"BanExpire"DB_Connect);
        
//----------------------------------------------------------------------
        
cache_get_field_content(0"Reason"bField[0]); cache_get_field_content(0"Admin"bField[1]);
        
//----------------------------------------------------------------------
        
Days[1] = gettime(); Days[2] = Days[0] - Days[1]; Days[3] = floatround(((Days[2]/24)/60)/60);
        
//----------------------------------------------------------------------
        
if(Days[0] == -1)
        {
            for(new 
030i++) SendClientMessage(playerid, ~1" ");
            
SendClientMessage(playeridCOLOR_ABLUE"==============(Ban Details)================");
            
format(eString512"You have been Banned by {00A6FF}%s {D1D1D1}!"bField[1]);
            
SendClientMessage(playeridCOLOR_GREY2eString);
            
format(eString512"Reason: {00A6FF}%s"bField[0]);
            
SendClientMessage(playeridCOLOR_GREY2eString);
            
SendClientMessage(playeridCOLOR_GREY2"Press {FF0000}F8{D1D1D1} to make an Screenshot!");
            
format(eString512"For UnBan, make a request {FF0000}"SERVER_SITE"{D1D1D1} with name {FF0000}%s {D1D1D1}and IP {00A6FF}%s {D1D1D1}!"PlayerName(playerid), GetPlayerIPEx(playerid));
            
SendClientMessage(playeridCOLOR_GREY2eString);
            
SendClientMessage(playeridCOLOR_ABLUE"========================================");
            
KickEx(playerid);
        }
        else if(
gettime() >= Days[0])
        {
            
format(sebStr128"UPDATE `Bans` SET `BanExpire` = '0' WHERE `Name` = '%s'"PlayerName(playerid)),
            
mysql_tquery(DB_ConnectsebStr"""");
        }
        else if(
Days[3] > 0)
        {
            for(new 
030i++) SendClientMessage(playerid, ~1" ");
            
SendClientMessage(playeridCOLOR_ABLUE"==============(Ban Details)================");
            
format(eString512"You have been Banned by {00A6FF}%s {D1D1D1}for {FF0000}%d {D1D1D1}Days!"bField[1], Days[3]);
            
SendClientMessage(playeridCOLOR_GREY2eString);
            
format(eString512"Reason: {00A6FF}%s"bField[0]);
            
SendClientMessage(playeridCOLOR_GREY2eString);
            
SendClientMessage(playeridCOLOR_GREY2"Press {FF0000}F8{D1D1D1} to make an Screenshot!");
            
format(eString512"For UnBan, make a request {FF0000}"SERVER_SITE"{D1D1D1} with name {FF0000}%s {D1D1D1}and IP {00A6FF}%s {D1D1D1}!"PlayerName(playerid), GetPlayerIPEx(playerid));
            
SendClientMessage(playeridCOLOR_GREY2eString);
            
SendClientMessage(playeridCOLOR_ABLUE"========================================");
            
KickEx(playerid);
        }
    }
    return 
1;

CONVERT TIME
How to create for this to get the date and hour and minute of expiration DD/MM/YY H/M
Reply
#2

Hmmm............
Reply
#3

There are many ways to do this, i also suggest not sending the hours/mins because they usually differ to players. So sending DD/MM/YYYY is fine.

Код:
//Off the internet, no credits found
GetDateStamp(Time = 0, bool:IsUnixTime = true)
{
    new hour, minute, sec;
    gettime(hour,minute,sec);
    new secs;
    secs = Time;
    if (IsUnixTime) secs -= gettime();
    secs += sec;
    new mins;
    if (secs >= 60)
    {
        mins = secs / 60;
        secs -= mins * 60;
    }
    mins += minute;
    new hours;
    if (mins >= 60)
    {
        hours = mins / 60;
        mins -= hours * 60;
    }
    hours += hour;
    new Days;
    if (hours >= 24)
    {
        Days = hours / 24;
        hours -= Days * 24;
    }
    new MonthDays[] = {31,28,31,30,31,30,31,31,30,31,30,31};
    new Year;
    new Month;
    new Day;
    getdate(Year,Month,Day);
    if ((Year % 4 == 0) && (Year % 100 != 0) || (Year % 400 == 0)) MonthDays[1] = 29;
    Days += Day;
    new Months;
    while (Days > MonthDays[Month - 1])
    {
        Days -= MonthDays[Month - 1];
        Months++;
    }
    Months += Month;
    new Years;
    if (Months > 12)
    {
        Years = Months / 12;
        Months -= Years * 12;
    }
    Years += Year;
    new YearDay;
    new YearDays[] = {0,31,59,90,120,151,181,212,243,273,304,334};
    YearDay = Days + YearDays[Months - 1];
    if (Months > 2 && (Year % 4 == 0) && (Year % 100 != 0) || (Year % 400 == 0)) YearDay++;
    new string[64];
    format(string,sizeof (string),"%i-%02i-%i",Days,Months,Years);
    return string;
}
Reply
#4

Ok but i dont know how to use this in my server
Reply
#5

Save the ban time using gettime() and compare it when the player connects, if its greater or equal then hes still banned:

Код:
format (string, sizeof(string), "Ban expires on: ", GetDateStamp(time));
SendClientMessage(playerid, -1, string);
if its smaller, then you can remove the ban and allow them to play.
Reply
#6

Soo
will i get with this and minutes ? of time ?
Reply
#7

hm...... let me think what can u do
Reply
#8

Ok tell mee i want it also to get the time with minutes and hours
Also please add it to my first post and repost it
Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)