Script Name:/unpause (with countdown) command script
Script Description: Script that adds a /unpause command with a countdown and also made it so that can not unpause with /pause command (can be useful in clan wars with several admins) .
Original Author(s):Serial K!ller
Core Version:2.5.2
Code(core.pas):
const
UNP_CNTDOWNLENGTH = 5; //unpause countdown length in seconds
var
//-----/pause and /unpause variables-----
inpause: integer;
startunpause : integer;
timeleftonpause : integer;
maponpause : string;
F_TT : integer;
F_CNT : integer;
procedure ActivateServer();
begin
inpause:= 0;
startunpause:=0;
end;
procedure AppOnIdle(Ticks: integer);
begin
// unpause procedure after /unpause command
if (startunpause = 1) then begin
if (StrToInt(FormatDate('ss'))) = F_TT then begin
if F_CNT <> 0 then
// countdown output
command('/say '+IntToStr(F_CNT))
else begin
// unpausing
command('/say Go!');
command('/pause');
inpause := 0;
startunpause := 0;
end
if F_TT < 59 then inc(F_TT,1) else F_TT := 0;
F_CNT := F_CNT-1;
end;
end;
end;
procedure handle_pausecommand(Text: string);
begin
text := lowercase(text);
//the /pause command
if Copy(Text,1,6) = '/pause' then begin
if inpause = 0 then begin
command('/say pausing server...');
inpause := 1;
timeleftonpause:=timeleft;
maponpause:=currentmap;
end
else if ((timeleftonpause = timeleft) and (maponpause=currentmap)) then begin
command('/pause');
timeleftonpause:=timeleft;
end
if ((timeleftonpause <> timeleft) or (maponpause <> currentmap))then begin
command('/say pausing server...');
inpause := 1;
startunpause := 0;
timeleftonpause:=timeleft;
maponpause:=currentmap;
end;
end;
//the /unpause command
if Copy(Text,1,8) = '/unpause' then begin
if inpause = 1 then begin
if ((timeleftonpause = timeleft) and (maponpause=currentmap)) then begin
command('/say unpausing server in '+IntToStr(UNP_CNTDOWNLENGTH)+' seconds');
startunpause := 1;
if StrToInt(FormatDate('ss')) <> 59 then F_TT := StrToInt(FormatDate('ss'))+1 else F_TT := 0;
F_CNT := UNP_CNTDOWNLENGTH;
end
else begin
inpause:= 0;
startunpause:=0;
end;
end;
end;
if ((Copy(Text,1,8) = '/restart') or (Copy(Text,1,5+length(maponpause)) = '/map '+maponpause) or (Copy(Text,1,8) = '/nextmap') or ((Copy(Text,1,9) = '/gamemode') and ((Copy(Text,11,1) = '1') or (Copy(Text,11,1) = '2') or (Copy(Text,11,1) = '3') or (Copy(Text,11,1) = '4') or (Copy(Text,11,1) = '5') or (Copy(Text,11,1) = '6')))) then begin
inpause:= 0;
startunpause:=0;
end;
end;
procedure OnCommand(ID: integer;Text: string);
begin
text := lowercase(Text);
handle_pausecommand(text);
end;
[edit]
added some code to make it non case sensative
text := lowercase(Text);
[edit²]
fixed problem that the server think it's still paused after /restart, /loadcon, /gamemode, /map ... commands.