Author Topic: /unpause (with countdown) command script[update]  (Read 4017 times)

0 Members and 1 Guest are viewing this topic.

Offline Serial K!ller

  • Camper
  • ***
  • Posts: 408
    • Soldat Mods Archive
/unpause (with countdown) command script[update]
« on: January 31, 2007, 01:57:25 pm »
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):
Code: [Select]
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
Code: [Select]
text := lowercase(Text);
[edit²]
fixed problem that the server think it's still paused after /restart, /loadcon, /gamemode, /map ... commands.
« Last Edit: February 21, 2007, 11:36:05 am by Serial K!ller »

Offline truup

  • Soldier
  • **
  • Posts: 243
Re: /unpause (with countdown) command script
« Reply #1 on: January 31, 2007, 01:59:34 pm »
I made a script like this too, but while testing it on a cw, it appeared unpaused for me while it was counting down for others, so it's not that reliable ;/ GJ though if it works :)

Offline KeYDoN

  • Major
  • *
  • Posts: 60
Re: /unpause (with countdown) command script
« Reply #2 on: February 20, 2007, 04:22:56 pm »
bug-detected :o

if someone performs /restart while the game is paused the server get s unpaused, but the script still thinks its paused.
add
Code: [Select]
if ((Copy(Text,1,8) = '/restart') or (Copy(Text,1,8) = '/nextmap') or (Copy(Text,1,5) = '/map ')) then
begin
   inpause:= 0;
   startunpause:=0;
end;
to OnCommand
« Last Edit: February 20, 2007, 04:26:17 pm by KeYDoN »

Offline Serial K!ller

  • Camper
  • ***
  • Posts: 408
    • Soldat Mods Archive
Re: /unpause (with countdown) command script
« Reply #3 on: February 20, 2007, 05:29:03 pm »
D'oh!
Fixed it,but it's still possible on map changes or problems when using /map command with typing a non-existing map...
will have to wait till 2.6.0 for OnMapChange event to fix those...


[edit]
I think i found a way to solve those problems, I'm gonna try it tomorrow after school.

[edit²]
fixed it.
« Last Edit: February 21, 2007, 11:21:37 am by Serial K!ller »

Offline LeFTeR

  • Major(1)
  • Posts: 4
Re: /unpause (with countdown) command script[update]
« Reply #4 on: March 06, 2007, 08:15:39 am »
i want tooo work PLS FIX IT>....