time

Started by Cool, Feb 12, 2016, 12:01 PM

Previous topic - Next topic

Cool

its shows how much time spends you are banned but i want to its show how much time remains
Please help
function TimeRem( bantime, banratio )
{
local sp = split(banratio,":"),
Days = sp[0].tointeger() * 86400, Hours = sp[1].tointeger() * 3600, Minutes = sp[0].tointeger() *60,
allSeconds = (Days + Hours + Minutes),
secs = (bantime - time()) + allSeconds; //Collect all the time calculated in single variable,' secs '
//Thomas's Method to calculate the time
  if( secs ) {
     
     
     local thomas_time_token,thomas_hours, thomas_minutes, thomas_seconds, thomas_days;

          thomas_time_token = abs(secs);
                   
           thomas_days = floor(thomas_time_token / 86400);
                 
             thomas_time_token -= thomas_days * 86400;
             
               thomas_hours = floor(thomas_time_token / 3600) % 24;
             
              thomas_time_token -= thomas_hours * 3600;
           
             thomas_minutes = floor(thomas_time_token / 60) % 60;
         
           thomas_time_token -= thomas_minutes * 60;
           
          thomas_seconds = thomas_time_token % 60;
         
//boom yeah! lets return the time in string we counted so far!
return format( "%02d Days , %02d Hours , %02d Minutes , %02d Seconds",thomas_days, thomas_hours,thomas_minutes, thomas_seconds );
     }

}

KAKAN

Change this:-
secs = (bantime - time()) + allSeconds;To:-
secs = (bantime - time())If it works, then remove the allSeconds variable.
oh no

Cool

not working same prob

FarisDon

#3
Quote from: Hercules on Feb 12, 2016, 01:04 PMnot working same prob
Show me the query, how are you actually getting this TimeRem( bantime, banratio ) like Timerem(bla,bla);Anyway give it a try
secs = (bantime - time()) + allSeconds; to secs = (bantime - allSeconds);

Cool


function Banned( p )
{
local player = FindPlayer(p);
if(player)
{
local query = QuerySQL( sqliteDB, "SELECT * FROM Banned WHERE ban_nick='" + player + "' COLLATE NOCASE" ), IP = player.IP.tostring();
   if( GetSQLColumnData( query, 0 )  )
   {
         if( ( time() - GetSQLColumnData( query, 2 ).tointeger() ) >= GetSQLColumnData( query, 3 ).tointeger() )
   {
       local query2 = QuerySQL( sqliteDB, "DELETE FROM Banned WHERE ban_nick='" + player.Name.tostring() + "'" );
    FreeSQLQuery( query2 );
       MessagePlayer("[RBAN] Your ban has been expired.", player );
    MessagePlayer("[RBAN] Stick to the rules or you will get permanently banned.", player );
   }
   else
   {
        local Time_Left = TimeRem( GetSQLColumnData( query, 2 ).tointeger(), GetSQLColumnData( query, 4 ) );
        //local splitban = split(  GetSQLColumnData( query, 4 ), ":"  ), Calc = splitban[ 0 ] + " Day(s), " + splitban[ 1 ] + " Hour(s), " + splitban[ 2 ] + " Minute(s).";
        MessagePlayer("[RBAN] Your ban has not expired.", player );
     MessagePlayer("[RBAN] Your ban is set to expire in. " + Time_Left, player );
     KickPlayer( player );
   }
}
}
}
//Check is player is banned.
function IsBanned( fullname )
{
      local query = QuerySQL( sqliteDB, "SELECT ban_ip FROM Banned WHERE ban_nick='" + fullname + "' COLLATE NOCASE" );
  if( GetSQLColumnData( query, 2 )  ) return true;
  return false;
  KickPlayer( player );
}

FarisDon

#5
Quote from: [TBS]Destroyer on Feb 12, 2016, 02:20 PM
Quote from: Hercules on Feb 12, 2016, 01:04 PMnot working same prob
Show me the query, how are you actually getting this TimeRem( bantime, banratio ) like Timerem(bla,bla);Anyway give it a try
[code secs = (bantime - time()) + allSeconds; [/code] to [code]secs = (bantime - allSeconds);[/code]
Anyway give it a try
secs = (bantime - time()) + allSeconds; to secs = (bantime - allSeconds);.....

Cool

now its shows so much time i ban forr 10 mints and its shows banned for 16000 days

FarisDon

Quote from: Hercules on Feb 12, 2016, 02:35 PMnow its shows so much time i ban forr 10 mints and its shows banned for 16000 days
Uhm, what about this
secs = (allSeconds - bantime );

Cool


KAKAN

Show me the TimeRem functions.
Anyways, give this a try:-
( time() - bantime )You know what to replace :)
oh no

Cool

not working and here is function
function TimeRem( bantime, banratio )
{
local sp = split(banratio,":"),
Days = sp[0].tointeger() * 86400, Hours = sp[1].tointeger() * 3600, Minutes = sp[0].tointeger() *60,
allSeconds = (Days + Hours + Minutes),
secs = (bantime - time()) + allSeconds; //Collect all the time calculated in single variable,' secs '
//Thomas's Method to calculate the time
  if( secs ) {
     
     
     local thomas_time_token,thomas_hours, thomas_minutes, thomas_seconds, thomas_days;

          thomas_time_token = abs(secs);
                   
           thomas_days = floor(thomas_time_token / 86400);
                 
             thomas_time_token -= thomas_days * 86400;
             
               thomas_hours = floor(thomas_time_token / 3600) % 24;
             
              thomas_time_token -= thomas_hours * 3600;
           
             thomas_minutes = floor(thomas_time_token / 60) % 60;
         
           thomas_time_token -= thomas_minutes * 60;
           
          thomas_seconds = thomas_time_token % 60;
         
//boom yeah! lets return the time in string we counted so far!
return format( "%02d Days , %02d Hours , %02d Minutes , %02d Seconds",thomas_days, thomas_hours,thomas_minutes, thomas_seconds );
     }

}

KAKAN

What parameters do you pass in TimeRem?
Tell us that.
Anyways, you're free to try this:
function TimeRem( bantime, shit ) //that 'shit' is of no use, just adding it in place of banratio
{
secs = (time() - bantime) //Collect all the time calculated in single variable,' secs '
//Thomas's Method to calculate the time
  if( secs > 0 ) {
     
     
     local thomas_time_token,thomas_hours, thomas_minutes, thomas_seconds, thomas_days;

          thomas_time_token = abs(secs);
                   
           thomas_days = floor(thomas_time_token / 86400);
                 
             thomas_time_token -= thomas_days * 86400;
             
               thomas_hours = floor(thomas_time_token / 3600) % 24;
             
              thomas_time_token -= thomas_hours * 3600;
           
             thomas_minutes = floor(thomas_time_token / 60) % 60;
         
           thomas_time_token -= thomas_minutes * 60;
           
          thomas_seconds = thomas_time_token % 60;
         
//boom yeah! lets return the time in string we counted so far!
return format( "%02d Days , %02d Hours , %02d Minutes , %02d Seconds",thomas_days, thomas_hours,thomas_minutes, thomas_seconds );
     }

}
oh no

Cool

#12
@KAKAN
secs does not exists but here is defined secs then why its giving error :P

KAKAN

ahh shit. sorry, forgot about that. Use this instead:-
function TimeRem( bantime, shit ) //that 'shit' is of no use, just adding it in place of banratio
{
local secs = (time() - bantime) //Collect all the time calculated in single variable,' secs '
//Thomas's Method to calculate the time
  if( secs > 0 ) {
     
     
     local thomas_time_token,thomas_hours, thomas_minutes, thomas_seconds, thomas_days;

          thomas_time_token = abs(secs);
                   
           thomas_days = floor(thomas_time_token / 86400);
                 
             thomas_time_token -= thomas_days * 86400;
             
               thomas_hours = floor(thomas_time_token / 3600) % 24;
             
              thomas_time_token -= thomas_hours * 3600;
           
             thomas_minutes = floor(thomas_time_token / 60) % 60;
         
           thomas_time_token -= thomas_minutes * 60;
           
          thomas_seconds = thomas_time_token % 60;
         
//boom yeah! lets return the time in string we counted so far!
return format( "%02d Days , %02d Hours , %02d Minutes , %02d Seconds",thomas_days, thomas_hours,thomas_minutes, thomas_seconds );
     }

}
oh no

Cool

bro same result :D @KAKAN