Author Topic: [Unit] OnAdminCommand SC3  (Read 1098 times)

0 Members and 1 Guest are viewing this topic.

Offline Mighty

  • Camper
  • ***
  • Posts: 276
[Unit] OnAdminCommand SC3
« on: August 28, 2013, 11:11:58 am »
Introduction
I 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.

Description
Unit 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
Download
Attachment

Example
Code: [Select]
uses Admin;

function OnAdmCmd(p: TActivePlayer; cmd: string): boolean;
begin
Result := FALSE;
WriteLn('ADMIN CMD');
end;

begin
ScriptOnAdminCommand := @OnAdmCmd;
end.

Epilogue
I 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.
« Last Edit: August 29, 2013, 03:23:37 am by Mighty »
xFire: macmil        e-mail: macekmil@gmail.com
My scripts: Accuracy Script       Flashbang       Punishments GUID
            CatchMe Gamemod       AntiFake
            CW System             AntiFakeGUID

Offline Falcon`

  • Flagrunner
  • ****
  • Posts: 792
  • A wanted lagger
Re: [Unit] OnAdminCommand SC3
« Reply #1 on: August 28, 2013, 11:53:51 am »
OnTCPAdminCommand is planned. IsAdmin as well. The idea is that IsAdmin eliminates the need for OnAdminCommand so it won't be implemented.
If you're not paying for something, you're not the customer; you're the product being sold.
- Andrew Lewis

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

Offline Mighty

  • Camper
  • ***
  • Posts: 276
Re: [Unit] OnAdminCommand SC3
« Reply #2 on: August 28, 2013, 12:01:20 pm »
Yeah, I know, I'm just being a little impatient ;)
xFire: macmil        e-mail: macekmil@gmail.com
My scripts: Accuracy Script       Flashbang       Punishments GUID
            CatchMe Gamemod       AntiFake
            CW System             AntiFakeGUID