Author Topic: WhoIs  (Read 3946 times)

0 Members and 1 Guest are viewing this topic.

Offline Savage

  • Soldier
  • **
  • Posts: 155
WhoIs
« on: November 09, 2017, 06:24:32 pm »
Script Name: WhoIs
Script Description: Shows connected admins on "!whois" command
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.1 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 (127.0.0.1)');
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: March 10, 2018, 12:39:56 pm by Savage »

Offline Savage

  • Soldier
  • **
  • Posts: 155
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

Offline Irlandec

  • Soldier
  • **
  • Posts: 176
Re: WhoIs
« Reply #2 on: March 05, 2018, 01:47:08 pm »
I'd like to inform that this doesn't work with Baka Admin for some reason.
It sends the "/clientlist" command to the remote console but nothing happens - TCP admin isn't counted in.
Used the script on Windows server(beta 4 release by Shoozza).

Tried to figure out what can be wrong, maybe should change the check command for Baka.
« Last Edit: March 05, 2018, 05:30:27 pm by Irlandec »

Offline Savage

  • Soldier
  • **
  • Posts: 155
Re: WhoIs
« Reply #3 on: March 06, 2018, 05:32:56 am »
Description says "works with ARSSE" for a reason ;p
It uses WriteLn procedure to send /clientlist message to receive connected admins which seems to work with ARSSE, if I would like from it to work with baka I would have to send a command and there is no way to do that in SC3 afaik. ARSSE is better than baka anyway.

Offline Irlandec

  • Soldier
  • **
  • Posts: 176
Re: WhoIs
« Reply #4 on: March 06, 2018, 04:52:37 pm »
Description says "works with ARSSE" for a reason ;p
It uses WriteLn procedure to send /clientlist message to receive connected admins which seems to work with ARSSE, if I would like from it to work with baka I would have to send a command and there is no way to do that in SC3 afaik. ARSSE is better than baka anyway.

Yeah, I didn't misread, I just wanted to understand if there is a possible workaround for Baka :)
I could just ask you over Discord but at the time I was looking through my code, phone was away and I had firewall :P
Thanks for a reply!

Offline Savage

  • Soldier
  • **
  • Posts: 155
Re: WhoIs
« Reply #5 on: March 10, 2018, 12:44:15 pm »
Uploaded new version which works now also with Baka Admin. Big thanks to XvayS for the tip.