Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Cool on Feb 12, 2016, 12:01 PM

Title: time
Post by: Cool on Feb 12, 2016, 12:01 PM
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 );
     }

}
Title: Re: time
Post by: KAKAN on Feb 12, 2016, 12:47 PM
Change this:-
secs = (bantime - time()) + allSeconds;To:-
secs = (bantime - time())If it works, then remove the allSeconds variable.
Title: Re: time
Post by: Cool on Feb 12, 2016, 01:04 PM
not working same prob
Title: Re: time
Post by: FarisDon 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
secs = (bantime - time()) + allSeconds; to secs = (bantime - allSeconds);
Title: Re: time
Post by: Cool on Feb 12, 2016, 02:22 PM

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 );
}
Title: Re: time
Post by: FarisDon on Feb 12, 2016, 02:25 PM
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);.....
Title: Re: time
Post by: Cool on Feb 12, 2016, 02:35 PM
now its shows so much time i ban forr 10 mints and its shows banned for 16000 days
Title: Re: time
Post by: FarisDon on Feb 12, 2016, 02:45 PM
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 );
Title: Re: time
Post by: Cool on Feb 12, 2016, 02:51 PM
same result
Title: Re: time
Post by: KAKAN on Feb 12, 2016, 05:06 PM
Show me the TimeRem functions.
Anyways, give this a try:-
( time() - bantime )You know what to replace :)
Title: Re: time
Post by: Cool on Feb 12, 2016, 05:27 PM
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 );
     }

}
Title: Re: time
Post by: KAKAN on Feb 12, 2016, 06:04 PM
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 );
     }

}
Title: Re: time
Post by: Cool on Feb 12, 2016, 06:10 PM
@KAKAN
secs does not exists but here is defined secs then why its giving error :P
Title: Re: time
Post by: KAKAN on Feb 12, 2016, 06:13 PM
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 );
     }

}
Title: Re: time
Post by: Cool on Feb 12, 2016, 06:17 PM
bro same result :D @KAKAN
Title: Re: time
Post by: KAKAN on Feb 12, 2016, 06:19 PM
Quote from: Hercules on Feb 12, 2016, 06:17 PMbro same result :D
What's the result? And tell me what parameter you pass in TimeRem
Like: TimeRem( 0, "1:2:3" );
Title: Re: time
Post by: FarisDon on Feb 12, 2016, 06:25 PM
Quote from: KAKAN on Feb 12, 2016, 05:06 PMShow me the TimeRem functions.
Anyways, give this a try:-
( time() - bantime )You know what to replace :)
Kakan, either you Subtract Time from Bantime, or Bantime, from time results will be the same, just the signs will be different....
and, as, for you, Hercules, why don't you just show us the function :| by Function I mean the Command, by which you ban the player, Temp Ban or whatever it is called.
I'm really confused that what parameters or things you are really sending, Tell me few things.
1.What is the format of your cmd(Plus show the Cmd)
Eg : - /ban Anybody(Player) Bla(Reason).
2. Show the picture of your Ban list in the Database, plus the command, for God sake.
Title: Re: time
Post by: Cool on Feb 12, 2016, 06:25 PM
like this your ban will be expire in 00days 00hours 00mints 23secs
and i in banned for 10mint and thats 23 secs shows how much time spend on his ban
Title: Re: time
Post by: KAKAN on Feb 12, 2016, 06:26 PM
Quote from: Hercules on Feb 12, 2016, 06:25 PMlike this your ban will be expire in 00days 00hours 00mints 23secs
and i in banned for 10mint and thats 23 secs shows how much time spend on his ban

Quote from: KAKAN on Feb 12, 2016, 06:19 PMWhat's the result? And tell me what parameter you pass in TimeRem
Like: TimeRem( 0, "1:2:3" );
Did you read my reply? Tell me the answer.
Title: Re: time
Post by: Cool on Feb 12, 2016, 06:27 PM
if ( cmd == "tempban" )
     {
      local txt_Split;
           if( !text ) MessagePlayer("[RBAN] /tempban <player> <day:hour:min> <reason>", player);
          else
          {
                if( NumTok( text, " " ) == 2 )
{
     txt_Split = split( text, " " );
local plr = FindPlayer( txt_Split[ 0 ] ), expire = txt_Split[ 1 ];
if( plr ) AddBan( player, plr, expire );
else MessagePlayer("[RBAN] No such player.", player );
}
else if( NumTok( text, " " ) >= 3 )
         {
                                           txt_Split = split( text, " " );
                                           local plr = FindPlayer( txt_Split[ 0 ] ), expire = txt_Split[ 1 ], reason = GetTok( text, " ", 3, NumTok( text, " " ) );
if( plr ) AddBan( player, plr, expire, reason );
else MessagePlayer("[RBAN] No such player.", player );
}
else MessagePlayer("[RBAN] /c tempban <player> <day:hour:min> <reason>", player);
  }
     }
else if( cmd == "untempban" )
{
if( !text ) MessagePlayer("[RBAN] /c untempban <Fullname>", player);
else if( !IsBanned( text ) ) MessagePlayer("[RBAN]Player is not banned.", player);
else
{
        QuerySQL( sqliteDB, "DELETE TABLE FROM Banned WHERE ban_nick='" + text + "' COLLATE NOCASE" );
Message("Unbanned: [ " + text + " ] by Admin: [ " + player.Name + " ]" );
}
}
Title: Re: time
Post by: KAKAN on Feb 12, 2016, 06:28 PM
There's no TimeRem function used here lol.
SHOW ME TIMEREM's FUNCTION PARAMETER!
Title: Re: time
Post by: Cool on Feb 12, 2016, 06:34 PM
CoMMands are posted already and this is full system i didnt use anything else without this and i use only a timer nothing else what you want to check you can check
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 );
}


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 );
}
Title: Re: time
Post by: FarisDon on Feb 12, 2016, 06:35 PM
Quote from: KAKAN on Feb 12, 2016, 06:28 PMThere's no TimeRem function used here lol.
SHOW ME TIMEREM's FUNCTION PARAMETER!
Dude, Hercules -.- i'll simply say one thing.
In which, Command are you using TIMEREM'S function :'(
Show us that dude.
else if ( cmd =="usingleakedtempban")
{
local noob = FindPlayer(player)
{
if ( noob )
{
(bla )
{
Temprem(bla,bla)//the BlA BLA is called parameters! -,- i can't explain you really like, but you can say that.
}
else ClientMessage(" ALREADY SAID MAKE YOUR OWN SCRIPT FROM SCRATCH! don't just copy like noobs, and then me :O at the times like this.",noob,255,255,0);
}
else ClientMessage(":( Sorry he isn't here; copying other snippets",noob,255,255,0);
}
Title: Re: time
Post by: Cool on Feb 12, 2016, 06:36 PM
llol its not a leaked tempban its a released
Title: Re: time
Post by: KAKAN on Feb 12, 2016, 06:38 PM
Just saw that you are using this (http://vcmp.liberty-unleashed.co.uk/forum/index.php?topic=1713.0) script.
How do you expect it to work without the necessary editing?
You need to do some editing.
local Time_Left = TimeRem( GetSQLColumnData( query, 3 ).tointeger(), GetSQLColumnData( query, 4 ) );Use this, don't ask me where and use the TimeRem function I gave above
Title: Re: time
Post by: FarisDon on Feb 12, 2016, 06:38 PM
Quote from: Hercules on Feb 12, 2016, 06:34 PMCoMMands are posted already and this is full system i didnt use anything else without this and i use only a timer nothing else what you want to check you can check
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 );
}


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 );
}
Yr Hercules agar Urdu/Hindi Samjh mai ati hai to mera bhai, jo Command use kar reha hoo, mean ke jis Command sai tumha pata chal reha hai ki kitna days hain wo post karo, Or database ke ban list ko photo bhi do.(Dude, Hercules if you can understand Urdu/Hindi, so I basically mean the Command from which you are getting/knowing that how many days are left, please kindly post that, and kindly give Database Banlist photo as well.)
Title: Re: time
Post by: Cool on Feb 12, 2016, 06:39 PM
i am not to much noob KAKAN DUDE dont be angry
Title: Re: time
Post by: Cool on Feb 12, 2016, 06:41 PM
bhai destroyer ye jab banned player join karta hai na us ko message jata hai k itne din reh gaye unban k liye
Title: Re: time
Post by: FarisDon on Feb 12, 2016, 06:42 PM
Quote from: Hercules on Feb 12, 2016, 06:41 PMbhai destroyer ye jab banned player join karta hai na us ko message jata hai k itne din reh gaye unban k liye
So, I actually mean that show the join function where it is actually being used, and that's it.( To mai yahi keha reha hoo ki join function mai agar use hota hai to ye dehkao, bas)
P.S : - anyway guess when you will go through with Kakan's function it is surely gonna work. .-. if he is really, so damn confident in it.( wese I guess uski koi zarorat nhi hai cause Kakan ka function zaror work karega, or wese bhi wo bohat confident hai)
Title: Re: time
Post by: Cool on Feb 12, 2016, 06:46 PM
that is used in functions of banned (p) i already posted bhai aur is function ko call timer karti hai  ab samjy timer on player join me hai
Title: Re: time
Post by: Cool on Feb 12, 2016, 06:58 PM
yar destroyer Kakan ghussa hojata hai ab kam nhi karta to e kia karoon khudkashi ka dil karta hai subah se isi pe laga hoon
Title: Re: time
Post by: ysc3839 on Feb 12, 2016, 07:01 PM
Quote from: Hercules on Feb 12, 2016, 06:58 PMyar destroyer Kakan ghussa hojata hai ab kam nhi karta to e kia karoon khudkashi ka dil karta hai subah se isi pe laga hoon
What do you say? :(
Title: Re: time
Post by: Cool on Feb 12, 2016, 07:03 PM
i say that thats Not Working IF i say Kakan will be angry but its not works what i do i want todo suscide because fro morning i trying to solve it but i cant
Title: Re: time
Post by: Cool on Feb 12, 2016, 07:53 PM
function onPlayerJoin( player ){
      NewTimer("Banned", 3000, 1, player.ID );
}
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi64.tinypic.com%2F1z1gthz.jpg&hash=064b04c87761f5e8188dbbf4e8a133c2a17f5703)
Title: Re: time
Post by: KAKAN on Feb 13, 2016, 06:02 AM
Quote from: ysc3839 on Feb 12, 2016, 07:01 PM
Quote from: Hercules on Feb 12, 2016, 06:58 PMyar destroyer Kakan ghussa hojata hai ab kam nhi karta to e kia karoon khudkashi ka dil karta hai subah se isi pe laga hoon
What do you say? :(
R.I.P hindi, nothing else.

@Hercules I'm going to help you, if you find errors, I can't do anything.
Use this function:-
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, 3 ).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 );
   }
}
}
}

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 );
     }

}
Title: Re: time
Post by: MacTavish on Feb 13, 2016, 02:59 PM
i am using this function and i'd never had any problem with it

function TimeRem( bantime,  banratio )
{
        local ban_current = time()-bantime, sp = split(banratio,":"), ban_Days, ban_Hours, ban_Minutes,
ban_Day = sp[ 0 ].tointeger(),
ban_Hour = sp[ 1 ].tointeger(),
ban_Minute = sp[ 2 ].tointeger();
ban_Days = ban_current/86400;
ban_current = ban_current%86400;
ban_Hours = ban_current/3600;
ban_current = ban_current%3600;
ban_Minutes = ban_current/60;
ban_current = ban_current%60;
ban_Day -= ban_Days;
ban_Hour -= ban_Hours;
ban_Minute -= ban_Minutes;
return ban_Day + " Day(s), " + ban_Hour + " Hour(s), " + ban_Minute + " Minutes.";
}
Title: Re: time
Post by: Luckshya on Feb 13, 2016, 03:25 PM
By Thomas,
QuoteHello There, Someone or some people may have actually experienced some bug ( wrong time ) in Rocky's Temp ban system.

It shows Time in negative i.e ( 02 Days , -12 Hours, -43 minutes ) when player re-joins or server gets reseted
The Time increases, as it should decrease. in positive

/*


//This returns the time left for ban in Day:hour:minute format.
function TimeRem( bantime,  banratio )
{
        local ban_current = time()-bantime, sp = split(banratio,":"), ban_Days, ban_Hours, ban_Minutes,
ban_Day = sp[ 0 ].tointeger(),
ban_Hour = sp[ 1 ].tointeger(),
ban_Minute = sp[ 2 ].tointeger();
ban_Days = ban_current/86400;
ban_current = ban_current%86400;
ban_Hours = ban_current/3600;
ban_current = ban_current%3600;
ban_Minutes = ban_current/60;
ban_current = ban_current%60;
ban_Day -= ban_Days;
ban_Hour -= ban_Hours;
ban_Minute -= ban_Minutes;
return ban_Day + " Day(s), " + ban_Hour + " Hour(s), " + ban_Minute + " Minutes.";
}

/*
  ~End of the code~
*/
The above function is bugged. it returns time in wrong value. i.e in negative or UN-usual value like increasing seconds, as it should be decreasing

i've made a fix for it.

use the following function and replace it with original one
function TimeRem( bantime, banratio )
{
//Assign the Locals variables

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 );
}

}
Title: Re: time
Post by: Cool on Feb 13, 2016, 07:13 PM
Quote from: Kusanagi on Feb 13, 2016, 02:59 PMi am using this function and i'd never had any problem with it

function TimeRem( bantime,  banratio )
{
        local ban_current = time()-bantime, sp = split(banratio,":"), ban_Days, ban_Hours, ban_Minutes,
ban_Day = sp[ 0 ].tointeger(),
ban_Hour = sp[ 1 ].tointeger(),
ban_Minute = sp[ 2 ].tointeger();
ban_Days = ban_current/86400;
ban_current = ban_current%86400;
ban_Hours = ban_current/3600;
ban_current = ban_current%3600;
ban_Minutes = ban_current/60;
ban_current = ban_current%60;
ban_Day -= ban_Days;
ban_Hour -= ban_Hours;
ban_Minute -= ban_Minutes;
return ban_Day + " Day(s), " + ban_Hour + " Hour(s), " + ban_Minute + " Minutes.";
}
its giving negative time as thomas says
Title: Re: time
Post by: ysc3839 on Feb 13, 2016, 07:16 PM
I noticed you have discussed for a long time. Could you tell me what's the problem and let me have a try? :)
Title: Re: time
Post by: . on Feb 13, 2016, 07:21 PM
Quote from: ysc3839 on Feb 13, 2016, 07:16 PM... discussed for a long time. ...

Pun intended? ;D
Title: Re: time
Post by: Cool on Feb 13, 2016, 10:09 PM
@ysc3839 the problem is that if you want functions i posted all function in my above
its shows how much time spends you are banned but i want to its show how much time remains in unban
Title: Re: time
Post by: jayant on Mar 02, 2016, 01:09 PM
Bump:

I was trying to fix it for my server and I fixed it,its Rocky's snippet:
function TimeRem( bantime,  banratio )
{
        local ban_current = time()-bantime, sp = split(banratio,":"), ban_Days = 0, ban_Hours = 0, ban_Minutes = 0,
  ban_Day = sp[ 0 ].tointeger(),
  ban_Hour = sp[ 1 ].tointeger(),
  ban_Minute = sp[ 2 ].tointeger();
  bantime = ban_Day + ban_Hour + ban_Minute;
  ban_Days = ban_current/86400;
  ban_current = ban_current%86400;
  ban_Hours = ban_current/3600;
  ban_current = ban_current%3600;
  ban_Minutes = ban_current/60;
  ban_current = ban_current%60;
  ban_Day -= ban_Days;
  ban_Hour -= ban_Hours;
  ban_Minute -= ban_Minutes;
  return ban_Day + " Day(s), " + ban_Hour + " Hour(s), " + ban_Minute + " Minutes.";
}
Your other functions should be working
Title: Re: time
Post by: EK.IceFlake on Mar 03, 2016, 05:12 AM
What does bantime get?
EDIT: jayant posted a fix, never mind this post.
Title: Re: time
Post by: DizzasTeR on Mar 03, 2016, 05:44 AM
Crystal, check out the whole snippet and you will know what it does. The link to the original snippet was posted.
Title: Re: time
Post by: Cool on Mar 03, 2016, 09:24 AM
Thankyou @jay thanks for posting your fix here
Topic lock.