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