time

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

Previous topic - Next topic

Cool

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

ysc3839

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? :(

Cool

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

Cool

function onPlayerJoin( player ){
      NewTimer("Banned", 3000, 1, player.ID );
}

KAKAN

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

}
oh no

MacTavish

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.";
}

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Luckshya

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

}

Cool

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

ysc3839

I noticed you have discussed for a long time. Could you tell me what's the problem and let me have a try? :)

.

Quote from: ysc3839 on Feb 13, 2016, 07:16 PM... discussed for a long time. ...

Pun intended? ;D
.

Cool

@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

jayant

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

EK.IceFlake

#42
What does bantime get?
EDIT: jayant posted a fix, never mind this post.

DizzasTeR

Crystal, check out the whole snippet and you will know what it does. The link to the original snippet was posted.

Cool

Thankyou @jay thanks for posting your fix here
Topic lock.