Author Topic: WhoIs  (Read 165 times)

0 Members and 1 Guest are viewing this topic.

Offline Savage

  • Soldier
  • **
  • Posts: 129
WhoIs
« on: November 09, 2017, 06:24:32 pm »
Script Name: WhoIs
Script Description: Shows connected admins on "!whois" command - Works with ARSSE
Original Author(s): Savage
Compilation: Passed
Core Version: 2.8.1 (SC3)
Set these variables to True or False
Code: [Select]
COUNT_TCP_ADMINS := True;
COUNT_INGAME_ADMINS := True;
Code: [Select]
//WhoIs 2.0 by Savage //Core Version: 2.8.1 (SC3)

const
MSG_COLOR = $6495ed; //Color to display connected admins
COUNT_TIME = 5; //Time needed to count connected admins

var
Timer: Byte;
AdminsList: TStringList;
COUNT_TCP_ADMINS, COUNT_INGAME_ADMINS: Boolean;

procedure OnPlayerSpeak(Player: TActivePlayer; Text: String);
begin
if Text = '!whois' then
if Timer = 0 then begin
Players.WriteConsole('WhoIs: Counting connected admins...', MSG_COLOR);
Timer := COUNT_TIME;
if COUNT_TCP_ADMINS then
WriteLn('/clientlist');
end else
Players.WriteConsole('WhoIs: Already counting - please wait...', MSG_COLOR);
end;

procedure OnTCPMessage(Ip: string; Port: Word; Text: string);
begin
if (COUNT_TCP_ADMINS) and (Timer > 0) and (Copy(Text, 1, 1) = '[') and (Copy(Text, 3, 1) = ']') then
AdminsList.Append(Text);
end;

procedure Clock(Ticks: Integer);
var
i: Byte;
begin
if Timer > 0 then begin
Dec(Timer, 1);
if Timer = 0 then begin

if COUNT_TCP_ADMINS then
if AdminsList.Count = 0 then
Players.WriteConsole('WhoIs: There''s no TCP admin connected', MSG_COLOR)
else begin
if AdminsList.Count = 1 then
Players.WriteConsole('WhoIs: There''s 1 TCP admin connected:', MSG_COLOR)
else
Players.WriteConsole('WhoIs: There''re '+IntToStr(AdminsList.Count)+' TCP admins connected:', MSG_COLOR);

for i := 0 to AdminsList.Count-1 do
Players.WriteConsole(AdminsList[i], MSG_COLOR);

AdminsList.Clear;
end;

if COUNT_INGAME_ADMINS then begin
for i := 1 to 32 do
if players[i].IsAdmin then
AdminsList.Append(players[i].Name);

if AdminsList.Count = 0 then
Players.WriteConsole('WhoIs: There''s no In-Game admin connected', MSG_COLOR)
else begin
if AdminsList.Count = 1 then
Players.WriteConsole('WhoIs: There''s 1 In-Game admin connected:', MSG_COLOR)
else
Players.WriteConsole('WhoIs: There''re '+IntToStr(AdminsList.Count)+' In-Game admins connected:', MSG_COLOR);

for i := 0 to AdminsList.Count-1 do
Players.WriteConsole(AdminsList[i], MSG_COLOR);

AdminsList.Clear;
end;
end;

end;
end;
end;

procedure Init;
var
i: Byte;
begin
COUNT_TCP_ADMINS := True;
COUNT_INGAME_ADMINS := True;
AdminsList := File.CreateStringList;

for i := 1 to 32 do
Players[i].OnSpeak := @OnPlayerSpeak;

Game.OnTCPMessage := @OnTCPMessage;
Game.OnClockTick := @Clock;
end;

begin
Init;
end.
« Last Edit: November 14, 2017, 10:57:41 am by Savage »

Offline Savage

  • Soldier
  • **
  • Posts: 129
Re: WhoIs
« Reply #1 on: November 13, 2017, 11:21:01 pm »
Added counting for In_Game admins and 2 Boolean variables COUNT_TCP_ADMINS, COUNT_INGAME_ADMINS