Author Topic: upTime  (Read 3412 times)

0 Members and 1 Guest are viewing this topic.

Offline cooz

  • Soldier
  • **
  • Posts: 187
  • BANNED
upTime
« on: November 07, 2006, 04:56:27 am »
Script Name: upTime
Script Description: another simple script, it shows how long server is already running in %%days:%%hours:%%minutes:%%seconds format on !uptime or /uptime command
Original Author: cooz
Core Version: 2.5.2

Code: [Select]
const
  ADMIN_UPTIME_ON=1; //turns off/on /uptime script
  PLAYER_UPTIME_ON=1; //turns off/on !uptime script

var
  up: integer;

procedure ActivateServer();
begin
  up:=0;
end;

procedure AppOnIdle(Ticks: integer);
begin
  up:=up+1;
end;

function formatTime():string;
var d,h,m,s: integer;
begin
  d:= up/86400;
  h:= up/3600 mod 24;
  m:= up/60 mod 60;
  s:= up mod 60;

  if((d=0) and (h=0)) then begin result:=inttostr(m)+'m:'+inttostr(s)+'s'; end
    else if d=0 then begin result:=inttostr(h)+'h:'+inttostr(m)+'m:'+inttostr(s)+'s'; end
      else result:=inttostr(d)+'d:'+inttostr(h)+'h:'+inttostr(m)+'m:'+inttostr(s)+'s';
end;

procedure OnPlayerSpeak(Name,Text: string);
begin
 if((Text='!uptime')and(PLAYER_UPTIME_ON=1)) then begin
   saytoplayer(NametoID(Name),'server is running for: '+formatTime());
 end;
end;

procedure OnCommand(ID: integer;Text: string);
begin
  if((Text='/uptime')and(ADMIN_UPTIME_ON=1)) then begin
    saytoplayer(ID,'server is running for: '+formatTime());
  end;
end;
« Last Edit: November 29, 2006, 04:04:26 pm by cooz »
Dead man! Dead man walking! We got a dead man walking here! Banned man crawling more like

Offline Frenchie

  • Camper
  • ***
  • Posts: 358
  • SoldatHQ
Re: upTime
« Reply #1 on: November 07, 2006, 05:12:24 am »
Good work on getting this scripts forum up and running with your scripts. Can't wait to see the other scripts which will come out of here.

I especially like this script, I don't really know why... Well Done  ;D

Edit: Don't know if you used the right bb code, from the sticky it states
Quote
(use the [ CODE=Pascal ] [ /CODE ] tags around your code!)
« Last Edit: November 07, 2006, 05:14:54 am by Frenchie »
Soldat Lobby Avec Players -New Release! - Updated AGAIN!


Offline cooz

  • Soldier
  • **
  • Posts: 187
  • BANNED
Re: upTime
« Reply #2 on: November 07, 2006, 05:21:00 am »
i tried to use code=pascal, but this forum seems to not understand it,

we all know that it's pascal anyway  ;)
Dead man! Dead man walking! We got a dead man walking here! Banned man crawling more like

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: upTime
« Reply #3 on: November 07, 2006, 06:13:10 am »
The [ code = pascal] thing is there because I copied the post template from my forum, which supports the GeSHI SMF Mod, but soldatforums doesnt... hopefully it will soon though.