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: 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