time ban problem
#1

I try to make a message to dysplay the ban time left,

when I use command /ban

time = gettime() + (days*86400); //86400 I know this it means a day in unix

and when login

"Ban will expire in %d and %d hours",(time-gettime())/86400 , (time-/86400)-(time/86400)/24*24);
SendClientMessage(playerid, -1, string);

,(time-gettime())/86400 this is 2 days and is good, but last who should be hours is wrong 8 and should be 24 because I just banned me for 3 days
Reply
#2

I'm doing like this:
PHP код:
//Onplayerconnect
        
if(gettime() < pAccount[playerid][pBanTime])
        {
            new 
heure// hour
                
jour// day
                
minute// minutes
                
secondes// seconds
            
TimeToDate(pAccount[playerid][pBanTime]-gettime(), __jourheureminutesecondes);
             
KillTimer(p_TimerSpawnAFK{playerid});
            if(
jour >= 365)
            {
                
SCM(playeridRED"Vous кtes banni dйfinitevement du serveur. Veuillez contacter ** en cas d'erreur.");
                
pAccount[playerid][pBanTime] = gettime() + jour*60*60*24;
            }
            else
                
SCMF(playeridRED"Vous кtes banni du serveur pour encore %02i jours, %02i heures, %02i minutes, %02i secondes"jourheureminutesecondes);
            
AdminWarn("%s a tentй de se connecter avec un compte banni."GetName(playeridtrue));
            
SaveSpecificPlayerStats(playerid18);
            
call_kick(playerid200falsefalse);
            return 
1;
        }
// --
TimeToDate(time, &annee 0, &mois 0, &jour 0, &heure 0, &minute 0, &seconds 0)
{
    
seconds time 60;
    
minute time 60;
    
heure minute 60;
    if(
minute >= 60)
        
minute %= 60;
    
jour heure 24;
    if(
heure >= 24)
        
heure %= 24;
    
mois jour 30;
    if(
jour >= 30)
        
heure %= 30;
    
annee mois 12;
    if(
mois >= 12)
        
mois %= 12;

This is not an accurate method for ban which is higher than 30 days.
Reply
#3

Use TimeStampToDate.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)