Author Topic: ProHour  (Read 2242 times)

0 Members and 1 Guest are viewing this topic.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
ProHour
« on: August 16, 2007, 12:25:02 pm »
Script Name: ProHour
Script Description: When ProHour is enabled (done by an admin command /prohour), only people with a certain name may be in the game. Yes, I'm aware that people can spoof other people's names. The main reason for this is so people with dynamic IPs (me) can join a server with a "ip only" or "name only" thing, if that makes sense. The list of allowed people in the server is in Allowed.txt in the main Soldat Server directory. And also there is a command to reload the allowed list, '/reloadallowed'.
Original Authos: Curt
Core Version: 2.6.2
Code:
Code: [Select]
const
  Color = $FF52DD52;

var
  ProHour: boolean;
  Allowed: tstringarray;
  KickPlayer: array[1..32] of boolean;

function Split(const Source: string; const Delimiter: string): tstringarray;
var
  i,x,d: integer;
  s: string;
begin
  d := Length(Delimiter);
  x := 0;
  i := 1;
  SetArrayLength(Result,1);
  while i <= Length(source) do begin
    s := Copy(Source,i,d);
    if s = Delimiter then begin
      Inc(i,d);
      Inc(x,1);
      SetArrayLength(result,x + 1);
    end else begin
      Result[x] := Result[x] + Copy(s,1,1);
      Inc(i,1);
    end;
  end;
end;

procedure ActivateServer();
begin
  Allowed := Split(ReadFile('Allowed.txt'),Chr(13) + Chr(10));
end;

procedure AppOnIdle(Ticks: integer);
var
  i: byte;
begin
  if ProHour then for i := 1 to 32 do if KickPlayer[i] then begin
    WriteConsole(i,'ProHour is currently enabled. You are not in the invitation list.',Color);
    Command('/kick ' + InttoStr(i));
    KickPlayer[i] := false;
  end;
end;

function OnCommand(ID: Byte; Text: string): boolean;
var
  Kick: boolean;
  i,j: byte;
begin
  Result := false;
  Case LowerCase(Text) of
    '/reloadallowed': Allowed := Split(ReadFile('Allowed.txt'),Chr(13) + Chr(10));
    '/prohour': if ProHour then begin
      ProHour := false;
      WriteConsole(0,'ProHour has been disabled by ' + GetPlayerStat(ID,'Name') + '!',Color);
      for i := 1 to 32 do KickPlayer[i] := false;
    end else begin
      ProHour := true;
      WriteConsole(0,'ProHour has been enabled by ' + GetPlayerStat(ID,'Name') + '!',Color);
      Kick := true;
      for i := 1 to 32 do if GetPlayerStat(i,'Active') = true then for j := 0 to GetArrayLength(Allowed) - 1 do if Allowed[i] = GetPlayerStat(ID,'Name') then begin
        Kick := false;
        Break;
      end;
      Command('/kick ' + InttoStr(i));
    end;
  end;
end;

procedure OnJoinGame(ID, Team: byte);
var
  i: byte;
  Kick: boolean;
begin
  Kick := true;
  for i := 0 to GetArrayLength(Allowed) - 1 do if Allowed[i] = GetPlayerStat(ID,'Name') then begin
    Kick := false;
    Break;
  end;
  if Kick then KickPlayer[ID] := true;
end;

procedure OnPlayerSpeak(ID: byte; Text: string);
begin
  if LowerCase(Text) = '!prohour' then if ProHour then WriteConsole(0,'ProHour is currently enabled.',Color) else WriteConsole(0,'ProHour is currently disabled.',Color);
end;
In request from Iq-Unlimited
« Last Edit: August 16, 2007, 12:57:07 pm by DorkeyDear »

Offline miketh2005

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 668
  • What's the URL for www.microsoft.com?
Re: ProHour
« Reply #1 on: August 17, 2007, 11:18:25 am »
kinda cool not used much except for clans or something but couldn't this be done by setting a pass to yr server so only certain people can get in?
Quote from: 'Ando.' pid='12999178' dateline='1309046898'
My new password is secure as shit :)
Mate, I am not sure Shit is even secured nowadays.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: ProHour
« Reply #2 on: August 17, 2007, 11:21:16 am »
You'd have to share the password to everybody.
Do you think I should make it accept wildcards?