Author Topic: /disable a timer  (Read 1020 times)

0 Members and 1 Guest are viewing this topic.

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
/disable a timer
« on: May 05, 2009, 04:05:09 pm »
Hi i modified Rampage's save & load with a timer to make it only a timer.
Now some people tell me the timer is annoying so i want to make a /disable command for it. I made one but it disable all player timers.
How to make it only to the ID ?
Here's script :
Code: [Select]
//Time Recorder created by Rampage - Modified by Vince Bro
//It's only a timer
Const
DisablingCommands = '';
//these are commands that will disable a players timer add any admin commands that may allow them to cheat remember to add the / at the start (only works on admins)
//i woud suggest only using scritpts that allow you to only target your self as this cant monitor if it targets some one else

WeaponsList = '07 10 255';//using the number of the gun i would suggest adding 255 by default as that is fist
//note that each gun whos number is less then 10 MUST have a 0 in front for example 04, 07, 02

RestartTimerOnDeath = True;
//if True the timer will restart on death use this for climb servers WITH OUT a save procedure

DisableTimerOnRecompile = False;
//if True the timer will disable on recompile to stop cheating


Var
LoadedTime: String;
Timer,Timer2: Array[1..32] Of Byte;
TimerDisabled: Boolean;
PlayerDisabled, AutoLoad, IdToLoad: Array[1..32] Of Boolean;
PlayerSaves,PlayerLoads: Array[1..32] Of Integer;                       

Procedure ActivateServer();
Begin
  //disabling timer at recompile
  If DisableTimerOnRecompile = True Then Begin
    TimerDisabled:=True;
    WriteConsole(0, 'Server Recompiled Timer Disabled Untill Map Change', $00FFFFFF);
  End Else TimerDisabled:=False;
End;

Procedure OnPlayerRespawn(ID: Byte);
Begin
  //if restarttimeondeath = true then restart the timer
  If RestartTimerOnDeath = True Then Begin
    Timer[ID]:=0;
    Timer2[ID]:=0;
  End;
End; 
 
Procedure OnJoinGame(ID, Team: byte);
Var
F: Byte;
Begin
//resetting timer disabled and autoload
Timer[ID]:=0;
Timer2[ID]:=0;
//resetting saved points
For F := 1 To 3 Do
End; 
 
Procedure AppOnIdle(Ticks: integer);
Var
Mins,Secs: Array [1..32] Of String;
A,B,F: Byte;
Begin
  If TimerDisabled = False Then Begin
    For B:= 1 To 32 Do
    IF GetPlayerStat(B, 'Human') Then Begin
      //timer increase
      Timer2[B]:=Timer2[B]+1;
      If Timer2[B] = 60 Then Begin
        Timer[B]:=Timer[B]+1
        Timer2[B]:=0;
      End;
      //fix for 00
      If Timer2[B] = 0 Then Secs[B]:='00';
      If Timer[B] = 0 Then Mins[B]:='00';
      For A:= 1 To 9 Do
      Begin
        //fix for 00 to 09 times
        If Timer2[B] = A Then Secs[B]:='0'+IntToStr(A);
        If Timer[B] = A Then Mins[B]:='0'+IntToStr(A);
      End;
      //all times above 9 will activate like normal
      If Timer[B] > 9 Then Mins[B]:=IntToStr(Timer[B]);
      If Timer2[B] > 9 Then Secs[B]:=IntToStr(Timer2[B]);
      DrawText(B,Mins[B]+':'+Secs[B],330,RGB(176,176,176),0.10,260,400);
    End;
  End Else DrawText(0,'Timer Disabled',330,RGB(176,176,176),0.10,200,400);
End;


Function OnCommand(ID: Byte; Text: string):boolean;
Begin
  If RegExpMatch(GetPiece(LowerCase(Text), ' ',0),LowerCase(DisablingCommands)) Then Begin
    PlayerDisabled[ID]:=True;
    WriteConsole(ID, 'Your Timer Has Been Disabled', $00FFFFFF);
  End;
End;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
   if Text = '/disable' then begin
TimerDisabled:=True;
DrawText(0,'Timer Disabled',330,RGB(176,176,176),0.10,200,400); 
end;
end;

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: /disable a timer
« Reply #1 on: May 05, 2009, 11:33:17 pm »
Code: [Select]
TimerDisabled: array[1..32] of boolean;



function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
  if Text = '/disable' then begin
    TimerDisabled[ID]:=True;
    DrawText(ID,'Timer Disabled',330,RGB(176,176,176),0.10,200,400); 
  end;
end;



Procedure AppOnIdle(Ticks: integer);
[...]
var i: byte;
Begin
  For i:= 1 to 32 do If TimerDisabled[i] = False Then Begin
    For B:= 1 To 32 Do
    IF GetPlayerStat(B, 'Human') Then Begin
      //timer increase
      Timer2[B]:=Timer2[B]+1;
      If Timer2[B] = 60 Then Begin
        Timer[B]:=Timer[B]+1
        Timer2[B]:=0;
      End;
      //fix for 00
      If Timer2[B] = 0 Then Secs[B]:='00';
      If Timer[B] = 0 Then Mins[B]:='00';
      For A:= 1 To 9 Do
      Begin
        //fix for 00 to 09 times
        If Timer2[B] = A Then Secs[B]:='0'+IntToStr(A);
        If Timer[B] = A Then Mins[B]:='0'+IntToStr(A);
      End;
      //all times above 9 will activate like normal
      If Timer[B] > 9 Then Mins[B]:=IntToStr(Timer[B]);
      If Timer2[B] > 9 Then Secs[B]:=IntToStr(Timer2[B]);
      DrawText(B,Mins[B]+':'+Secs[B],330,RGB(176,176,176),0.10,260,400);
    End;
  End Else DrawText(i,'Timer Disabled',330,RGB(176,176,176),0.10,200,400);
End;

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: /disable a timer
« Reply #2 on: May 06, 2009, 03:59:54 pm »
Mmhhh it doesn't work..
I get semicolon expected after TimerDisable[ i] = False then begin

Sorry for the space before i, it does italic
« Last Edit: May 06, 2009, 04:02:28 pm by VinceBros »

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: /disable a timer
« Reply #3 on: May 07, 2009, 06:03:08 am »
I just showed you how to do it.

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: /disable a timer
« Reply #4 on: May 07, 2009, 03:26:57 pm »
I can't do it anyway =/
I'm not good in scripts, so just put what you did in what i gave you in first post.
« Last Edit: May 07, 2009, 03:28:28 pm by VinceBros »

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: /disable a timer
« Reply #5 on: May 07, 2009, 11:55:24 pm »
Code: [Select]
//Time Recorder created by Rampage - Modified by Vince Bro
//It's only a timer
Const
DisablingCommands = '';
//these are commands that will disable a players timer add any admin commands that may allow them to cheat remember to add the / at the start (only works on admins)
//i woud suggest only using scritpts that allow you to only target your self as this cant monitor if it targets some one else

WeaponsList = '07 10 255';//using the number of the gun i would suggest adding 255 by default as that is fist
//note that each gun whos number is less then 10 MUST have a 0 in front for example 04, 07, 02

RestartTimerOnDeath = True;
//if True the timer will restart on death use this for climb servers WITH OUT a save procedure

DisableTimerOnRecompile = False;
//if True the timer will disable on recompile to stop cheating


Var
LoadedTime: String;
Timer,Timer2: Array[1..32] Of Byte;
TimerDisabled: array[1..32] of boolean;
PlayerDisabled, AutoLoad, IdToLoad: Array[1..32] Of Boolean;
PlayerSaves,PlayerLoads: Array[1..32] Of Integer;                       

Procedure ActivateServer();
var i: byte;
Begin
  //disabling timer at recompile
  If DisableTimerOnRecompile = True Then Begin
    for i:= 1 to 32 do TimerDisabled[i]:=True;
    WriteConsole(0, 'Server Recompiled Timer Disabled Untill Map Change', $00FFFFFF);
  End;
End;

Procedure OnPlayerRespawn(ID: Byte);
Begin
  //if restarttimeondeath = true then restart the timer
  If RestartTimerOnDeath = True Then Begin
    Timer[ID]:=0;
    Timer2[ID]:=0;
  End;
End; 
 
Procedure OnJoinGame(ID, Team: byte);
Begin
//resetting timer disabled and autoload
  Timer[ID]:=0;
  Timer2[ID]:=0;
//resetting saved points
End; 
 
Procedure AppOnIdle(Ticks: integer);
Var
  Mins,Secs: Array [1..32] Of String;
  A,B,F: Byte;
Begin
  for F:= 1 to 32 do If not TimerDisabled[F] Then Begin
    For B:= 1 To 32 Do
    IF GetPlayerStat(B, 'Human') Then Begin
      //timer increase
      Timer2[B]:=Timer2[B]+1;
      If Timer2[B] = 60 Then Begin
        Timer[B]:=Timer[B]+1
        Timer2[B]:=0;
      End;
      //fix for 00
      If Timer2[B] = 0 Then Secs[B]:='00';
      If Timer[B] = 0 Then Mins[B]:='00';
      For A:= 1 To 9 Do
      Begin
        //fix for 00 to 09 times
        If Timer2[B] = A Then Secs[B]:='0'+IntToStr(A);
        If Timer[B] = A Then Mins[B]:='0'+IntToStr(A);
      End;
      //all times above 9 will activate like normal
      If Timer[B] > 9 Then Mins[B]:=IntToStr(Timer[B]);
      If Timer2[B] > 9 Then Secs[B]:=IntToStr(Timer2[B]);
      DrawText(B,Mins[B]+':'+Secs[B],330,RGB(176,176,176),0.10,260,400);
    End;
  End Else DrawText(0,'Timer Disabled',330,RGB(176,176,176),0.5,200,400);
End;


Function OnCommand(ID: Byte; Text: string):boolean;
Begin
  If RegExpMatch(GetPiece(LowerCase(Text), ' ',0),LowerCase(DisablingCommands)) Then Begin
    PlayerDisabled[ID]:=True;
    WriteConsole(ID, 'Your Timer Has Been Disabled', $00FFFFFF);
  End;
End;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
  if Text = '/disable' then begin
    TimerDisabled[ID]:=True;
    DrawText(ID,'Timer Disabled',330,RGB(176,176,176),0.10,200,400); 
  end;
end;
« Last Edit: May 07, 2009, 11:57:59 pm by Gizd »

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: /disable a timer
« Reply #6 on: May 08, 2009, 02:13:05 pm »
It counts 32 seconds per seconds =]

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: /disable a timer
« Reply #7 on: May 09, 2009, 08:04:06 am »
Sorry for double post, but i found its this part
Code: [Select]
for F:= 1 to 32 do If not TimerDisabled[F] Then Begin Why does it modify the timer and it's supposed to be a boolean do disable the timer ?

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: /disable a timer
« Reply #8 on: May 09, 2009, 08:42:32 am »
Damn, I'm so stupid...

Code: [Select]
//Time Recorder created by Rampage - Modified by Vince Bro
//It's only a timer
Const
DisablingCommands = '';
//these are commands that will disable a players timer add any admin commands that may allow them to cheat remember to add the / at the start (only works on admins)
//i woud suggest only using scritpts that allow you to only target your self as this cant monitor if it targets some one else

WeaponsList = '07 10 255';//using the number of the gun i would suggest adding 255 by default as that is fist
//note that each gun whos number is less then 10 MUST have a 0 in front for example 04, 07, 02

RestartTimerOnDeath = True;
//if True the timer will restart on death use this for climb servers WITH OUT a save procedure

DisableTimerOnRecompile = False;
//if True the timer will disable on recompile to stop cheating


Var
LoadedTime: String;
Timer,Timer2: Array[1..32] Of Byte;
TimerDisabled: array[1..32] of boolean;
PlayerDisabled, AutoLoad, IdToLoad: Array[1..32] Of Boolean;
PlayerSaves,PlayerLoads: Array[1..32] Of Integer;                       

Procedure ActivateServer();
var i: byte;
Begin
  //disabling timer at recompile
  If DisableTimerOnRecompile = True Then Begin
    for i:= 1 to 32 do TimerDisabled[i]:=True;
    WriteConsole(0, 'Server Recompiled Timer Disabled Untill Map Change', $00FFFFFF);
  End;
End;

Procedure OnPlayerRespawn(ID: Byte);
Begin
  //if restarttimeondeath = true then restart the timer
  If RestartTimerOnDeath = True Then Begin
    Timer[ID]:=0;
    Timer2[ID]:=0;
  End;
End; 
 
Procedure OnJoinGame(ID, Team: byte);
Begin
//resetting timer disabled and autoload
  Timer[ID]:=0;
  Timer2[ID]:=0;
//resetting saved points
End; 
 
Procedure AppOnIdle(Ticks: integer);
Var
  Mins,Secs: Array [1..32] Of String;
  A,B: Byte;
Begin
  For B:= 1 To 32 Do If not TimerDisabled[B] Then Begin
    IF GetPlayerStat(B, 'Human') Then Begin
      //timer increase
      Timer2[B]:=Timer2[B]+1;
      If Timer2[B] = 60 Then Begin
        Timer[B]:=Timer[B]+1
        Timer2[B]:=0;
      End;
      //fix for 00
      If Timer2[B] = 0 Then Secs[B]:='00';
      If Timer[B] = 0 Then Mins[B]:='00';
      For A:= 1 To 9 Do
      Begin
        //fix for 00 to 09 times
        If Timer2[B] = A Then Secs[B]:='0'+IntToStr(A);
        If Timer[B] = A Then Mins[B]:='0'+IntToStr(A);
      End;
      //all times above 9 will activate like normal
      If Timer[B] > 9 Then Mins[B]:=IntToStr(Timer[B]);
      If Timer2[B] > 9 Then Secs[B]:=IntToStr(Timer2[B]);
      DrawText(B,Mins[B]+':'+Secs[B],330,RGB(176,176,176),0.10,260,400);
    End;
  End Else DrawText(0,'Timer Disabled',330,RGB(176,176,176),0.5,200,400);
End;


Function OnCommand(ID: Byte; Text: string):boolean;
Begin
  If RegExpMatch(GetPiece(LowerCase(Text), ' ',0),LowerCase(DisablingCommands)) Then Begin
    PlayerDisabled[ID]:=True;
    WriteConsole(ID, 'Your Timer Has Been Disabled', $00FFFFFF);
  End;
End;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
  if Text = '/disable' then begin
    TimerDisabled[ID]:=True;
    DrawText(ID,'Timer Disabled',330,RGB(176,176,176),0.10,200,400); 
  end;
end;
« Last Edit: May 09, 2009, 08:45:09 am by Gizd »

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: /disable a timer
« Reply #9 on: May 09, 2009, 08:55:41 am »
Thanks alot =D, it works now ^^