IntroductionI believe we really need 2-3 things to be added to Script Core 3 before we can start scripting more seriously with it (Player.Admin, OnAdminCommand, OnTCPAdminCommand). I decided to make a unit implementing one of those:
OnAdminCommand.
DescriptionUnit splits OnCommand into
ScriptOnPlayerCommand and
ScriptOnAdminCommand. It remembers the admins (HWID), so once logged they stay logged.
Notes- There is a line in file (25th), which is "ONPLAYERTWICE=FALSE;" change false to true if you want OnPlayerCommand to be triggered by admins as well
- Line 27: "FILEPATH='~/AdminScript_List.txt';" this is the path of the file used to store admin HWIDs. I recommend leaving it as is.
- Requires Sandbox=0 or Sandbox=1 with AllowIniEdit=1. It will tell you if something's wrong
- Setting the right Result might be sometimes tricky I think
DownloadAttachmentExampleuses Admin;
function OnAdmCmd(p: TActivePlayer; cmd: string): boolean;
begin
Result := FALSE;
WriteLn('ADMIN CMD');
end;
begin
ScriptOnAdminCommand := @OnAdmCmd;
end.
EpilogueI wanted to make it array IsAdmin[1..32] of Bool but that requires taking at least one from Game.OnLeave and Game.OnJoin, which I wanted to avoid.