All pastes #638398 Raw Edit

enable / disable custom commands

public text v1 · immutable
#638398 ·published 2007-07-29 20:10 UTC
rendered paste body
{$VERSION 2.6.0}
const
  MAX_HEALTH = 65; // Set to 150 for non-realistic mode, else set to 65.
  DROP_VALUE = 1;   // Value of each 'drop' of health, def: 5.
const
//Teams
  ALPHA = 1;
  BRAVO = 2;
  CHARLIE = 3;
  DELTA = 4;
  SPECTATOR = 5;
//Game Modes
  DEATHMATCH = 0;
  POINTMATCH = 1;
  TEAMMATCH = 2;
  CTF = 3;
  RAMBO = 4;
  INF = 5;
  HTF = 6;
//Weapons
  DEAGLES = 1;
  HKMP5 = 2;
  AK74 = 3;
  STEYR = 4;
  SPAS = 5;
  RUGER = 6;
  M79 = 7;
  BARRET = 8;
  MINIMI = 9;
  MINIGUN = 10;
  FLAMER = 11;
  BOW = 12;
  FLAMEBOW = 13;
  SOCOM = 0;
  KNIFE = 14;
  CHAINSAW = 15;
  LAW = 16;
var
  Disabled: tstringarray;

procedure ActivateServer();
var
  Text: string;
begin
end;

procedure AppOnIdle(Ticks: integer);
var i: byte;
begin
  if Ticks mod (60 * 1) = 0 then begin
  for  i := 1 to 32 do
    if (GetPlayerStat(i,'Health') < (MAX_HEALTH - (DROP_VALUE - 1))) then begin
      DoDamage(i,-DROP_VALUE);
    end else begin
      DoDamage(i,-(MAX_HEALTH - (GetPlayerStat(i,'Health'))));
    end;
  end;
end;

function OnCommand(ID: Byte; Text: string): boolean;
var
  good: boolean;
  i,Line: integer;
  Name: string;
begin
  Result := false;
  Text := LowerCase(Text);
  if (GetPiece(Text,' ',0) = '/disable') and (GetPiece(Text,' ',1) <> 'disable') and (GetPiece(Text,' ',1) <> 'enable') and (GetPiece(Text,' ',1) <> 'kill') and (GetPiece(Text,' ',1) <> 'brutalkill') and (GetPiece(Text,' ',1) <> 'smoke') and (GetPiece(Text,' ',1) <> 'tabac') and (GetPiece(Text,' ',1) <> 'takeoff') and (GetPiece(Text,' ',1) <> 'victory') and (GetPiece(Text,' ',1) <> 'pause') and (GetPiece(Text,' ',1) <> 'unpause') and (GetPiece(Text,' ',1) <> 'addbot') and (GetPiece(Text,' ',1) <> 'kick') and (GetPiece(Text,' ',1) <> 'ban') and (GetPiece(Text,' ',1) <> 'banip') and (GetPiece(Text,' ',1) <> 'unban') and (GetPiece(Text,' ',1) <> 'map') and (GetPiece(Text,' ',1) <> 'restart') and (GetPiece(Text,' ',1) <> 'nextmap') and (GetPiece(Text,' ',1) <> 'adm') and (GetPiece(Text,' ',1) <> 'admip') and (GetPiece(Text,' ',1) <> 'unadm') and (GetPiece(Text,' ',1) <> 'kicklast') and (GetPiece(Text,' ',1) <> 'respawntime') and (GetPiece(Text,' ',1) <> 'maxrespawntime') and (GetPiece(Text,' ',1) <> 'limit') and (GetPiece(Text,' ',1) <> 'timelimit') and (GetPiece(Text,' ',1) <> 'password') and (GetPiece(Text,' ',1) <> 'setteam') and (GetPiece(Text,' ',1) <> 'addbot') and (GetPiece(Text,' ',1) <> 'friendlyfire') and (GetPiece(Text,' ',1) <> 'vote%') and (GetPiece(Text,' ',1) <> 'bonus') and (GetPiece(Text,' ',1) <> 'maxplayers') and (GetPiece(Text,' ',1) <> 'loadcon') and (GetPiece(Text,' ',1) <> 'loadlist') and (GetPiece(Text,' ',1) <> 'loadwep') and (GetPiece(Text,' ',1) <> 'gamemode') and (GetPiece(Text,' ',1) <> 'realistic') and (GetPiece(Text,' ',1) <> 'advance') and (GetPiece(Text,' ',1) <> 'survival') and (GetPiece(Text,' ',1) <> 'banlast') and (GetPiece(Text,' ',1) <> 'unbanlast') and (GetPiece(Text,' ',1) <> 'lobby') and (GetPiece(Text,' ',1) <> 'say') and (GetPiece(Text,' ',1) <> 'adminlog') and (GetPiece(Text,' ',1) <> 'info') and (GetPiece(Text,' ',1) <> 'mute') and (GetPiece(Text,' ',1) <> 'unmute') and (GetPiece(Text,' ',1) <> 'gmute') and (GetPiece(Text,' ',1) <> 'ungmute') and (GetPiece(Text,' ',1) <> 'record') and (GetPiece(Text,' ',1) <> 'stop') then begin
    if GetPiece(Text,' ',1) = 'all' then begin
      SetArrayLength(Disabled,GetArrayLength(Disabled) + 23);
      for i := 0 to 22 do Case i of
        0: Disabled[GetArrayLength(Disabled) - i] := 'deagles'
        1: Disabled[GetArrayLength(Disabled) - i] := 'hkmp5'
        2: Disabled[GetArrayLength(Disabled) - i] := 'ak74'
        3: Disabled[GetArrayLength(Disabled) - i] := 'steyr'
        4: Disabled[GetArrayLength(Disabled) - i] := 'spaz'
        5: Disabled[GetArrayLength(Disabled) - i] := 'ruger'
        6: Disabled[GetArrayLength(Disabled) - i] := 'm79'
        7: Disabled[GetArrayLength(Disabled) - i] := 'barret'
        8: Disabled[GetArrayLength(Disabled) - i] := 'minimi'
        9: Disabled[GetArrayLength(Disabled) - i] := 'minigun'
        10: Disabled[GetArrayLength(Disabled) - i] := 'socom'
        11: Disabled[GetArrayLength(Disabled) - i] := 'knife'
        12: Disabled[GetArrayLength(Disabled) - i] := 'saw'
        13: Disabled[GetArrayLength(Disabled) - i] := 'law'
        14: Disabled[GetArrayLength(Disabled) - i] := 'stat'
        15: Disabled[GetArrayLength(Disabled) - i] := 'medic'
        16: Disabled[GetArrayLength(Disabled) - i] := 'nade'
        17: Disabled[GetArrayLength(Disabled) - i] := 'flame'
        18: Disabled[GetArrayLength(Disabled) - i] := 'armor'
        19: Disabled[GetArrayLength(Disabled) - i] := 'pred'
        20: Disabled[GetArrayLength(Disabled) - i] := 'berserk'
        21: Disabled[GetArrayLength(Disabled) - i] := 'cluster'
        22: Disabled[GetArrayLength(Disabled) - i] := 'test'
      end;
      WriteConsole(0,GetPlayerStat(ID,'Name') + ' has disabled all custom commands.',$FFFFFFFF);
    end else begin
      SetArrayLength(Disabled,GetArrayLength(Disabled) + 1);
      Disabled[GetArrayLength(Disabled) - 1] := Copy(Text,10,Length(Text));
      WriteConsole(0,GetPlayerStat(ID,'Name') + ' has disabled the ''/' + GetPiece(Text,' ',1) + ''' command.',$FFFFFFFF);
    end;
  end;
  if GetPiece(Text,' ',0) = '/enable' then begin
    if GetPiece(Text,' ',1) = 'all' then SetArrayLength(Disabled,0) else begin
      While good do begin
        Line := -1;
        for i := 0 to GetArrayLength(Disabled) - 1 do if Copy(Text,9,Length(Text)) = Disabled[i] then begin
          Line := i;
          Break;
        end;
        if Line <> -1 then begin
          for i := Line to GetArrayLength(Disabled) - 2 do Disabled[i] := Disabled[i + 1];
          SetArrayLength(Disabled,GetArrayLength(Disabled) - 1);
          good := true
        end else good := false;
      end;
      WriteConsole(0,GetPlayerStat(ID,'Name') + ' has enabled the ''/' + GetPiece(Text,' ',1) + ''' command.',$FFFFFFFF);
    end;
  end;
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
  Allow: boolean;
  i: integer;
begin
  Allow := true;
  for i := 0 to GetArrayLength(Disabled) - 1 do if Copy(Text,2,Length(Disabled[i])) = Disabled[i] then begin
    Allow := false;
    Break;
  end;
  if Allow then Result := false else Result := true;
  if Result = false then Case Text of
    '/deagles': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),1);
    '/hkmp5': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),2);
    '/ak74': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),3);
    '/steyr': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),4);
    '/spaz': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),5);
    '/ruger': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),6);
    '/m79': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),7);
    '/barret': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),8);
    '/minimi': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),9);
    '/minigun': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),10);
    '/socom': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),11);
    '/knife': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),12);
    '/saw': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),13);
    '/law': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),14);
    '/stat': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),15);
    '/medic': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),16);
    '/nade': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),17);
    '/flame': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),18);
    '/armor': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),19);
    '/pred': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),20);
    '/berserk': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),21);
    '/cluster': SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),22);
    '/commands': begin
      WriteConsole(ID,'Commands: /deagles /hkmp5 /ak74 /steyr /spaz /ruger /m79 /barret /minimi /minigun',$EE81FAA1);
      WriteConsole(ID,'/socom /knife /saw /law /stat',$EE81FAA1);
      WriteConsole(ID,'/medic /nade /flame /armor /pred /berserk /cluster',$EE81FAA1);
    end;
    '/test': DrawText(0,'Master Chief43',330,RGB(255,255,255),0.20,40,240);
  end;
end;

procedure OnException(ErrorMessage: string);
begin
//  WriteFile('ErrorLog.txt', ErrorMessage);
end;