Showing comma in duration

Started by Nihongo^, Jul 31, 2023, 05:19 PM

Previous topic - Next topic

Nihongo^

There's a "comma" in the duration bracket

Nick: Time left  [ , 2 Years, 8 Months, 1 Weeks, 1 Days ]

How do I remove it?

ServerMessage("[#FF0000][PRIOR BAN]:[#FFFFFF] [ " + player.Name + " ] is banned for Reason: [ " + GetSQLColumnData(q, 8) + " ] ]");
         ServerMessage("[#FF0000][PRIOR BAN]:[#FFFFFF] TimeLeft: [ " + GetBanRemainingTime(GetSQLColumnData(q, 4).tointeger(), GetSQLColumnData(q, 6).tostring()) + " ], Admin: [ " + GetSQLColumnData(q, 7) + " ]");
function GetBanRemainingTime( bantime,  banratio )
{
  local ban_current = time()-bantime;
  local total_time = "";
  local sp = split(banratio,":");
  local ban_Days = 0, ban_Hours = 0, ban_Minutes = 0;
  local ban_Day = sp[ 0 ].tointeger();
  local ban_Hour = sp[ 1 ].tointeger();
  local 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;
  local mints_to_hour = ban_Minute / 60;
  ban_Minute = ban_Minute - (mints_to_hour * 60);
  ban_Hour += mints_to_hour;
  local hours_to_days = ban_Hour / 24;
  ban_Hour = ban_Hour - (hours_to_days * 24);
  ban_Day += hours_to_days;
  local months = ban_Day / 31;
  ban_Day = ban_Day - (months * 31);
  local weeks = ban_Day / 7;
  ban_Day = ban_Day - (weeks * 7);
  local years = months / 12;
  months = months - (years * 12);
  if(years > 0) total_time += ", "+years+" Years";
  if(months > 0){if(total_time != ""){total_time += ", "+months+" Months";}else{total_time += months+" Months";}}
  if(weeks > 0){if(total_time != ""){total_time += ", "+weeks+" Weeks";}else{total_time += weeks+" Weeks";}}
  if(ban_Day > 0){if(total_time != ""){total_time += ", "+ban_Day+" Days";}else{total_time += ban_Day+" Days";}}
  if(ban_Hour > 0){if(total_time != ""){total_time += ", "+ban_Hour+" Hours";}else{total_time += ban_Hour+" Hours";}}
  if(ban_Minute > 0){if(total_time != ""){total_time += ", "+ban_Minute+" Minutes";}else{total_time += ban_Minute+" Minutes";}}
  return total_time;
}

P.S Its only showing command in "years" other wise no comma in months weeks or day

habi

if(years > 0) total_time += years+" Years";