Author Topic: Master  (Read 7758 times)

0 Members and 1 Guest are viewing this topic.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Master
« on: July 05, 2007, 05:56:26 pm »
Script Name: Master
Script Description: The first player to do /master becomes master. He may do the admin commands listed in Commands.txt. Good for public servers where the first person to claim master is fair. When AutoMaster is enabled, the first person who joins automatically claims master. The content of Commands.txt are excluding the '/' and are only the first part of the text. When a master enters a command that starts off with one of the lines in Commands.txt, but then has other text, the command will still attempt to execute. (Ex: /passworddddd where "password" is in Commands.txt)
Original Author: Curt
Core Version: 2.6.2
Suggested Commands.txt: (for a public private server)
Quote from: Commands.txt
say
kill
kick
password
setteam
map
restart
pause
unpause
gmute
ungmute
« Last Edit: November 12, 2007, 06:35:39 am by DorkeyDear »

Offline Shadow G-Unit

  • Veteran
  • *****
  • Posts: 1101
  • IRC: S[Ex]eh-Legend
    • Fractured Forums
Re: Master
« Reply #1 on: July 05, 2007, 06:07:45 pm »
Wow, another great script for that all great DorkeyDear (who is not that Dorkey :))


Ingame: King Legend.10- | Clan: In10sitY | Prev. Clan: OXiD | M79 Slag

Offline Mastadi

  • Camper
  • ***
  • Posts: 263
  • What makes me a good demoman!?
Re: Master
« Reply #2 on: July 05, 2007, 06:11:29 pm »
Yay, nice script!

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: Master
« Reply #3 on: July 07, 2007, 05:17:32 am »
And if the first person that joins is an idiot he will screw up your server...  ;)

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Master
« Reply #4 on: July 07, 2007, 12:11:21 pm »
That depends of what commands are on the list.
urraka

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Master
« Reply #5 on: July 08, 2007, 11:53:03 am »
And if the first person that joins is an idiot he will screw up your server...  ;)

Well, if he screws up the server, then everybody who dislikes it would probably leave, and if he is by himself, he probably isn't having much fun and would leave, and then master is then available to anybody now...
Plus, if the master script on the server is well known, it is most likely already being used by somebody if there are many people in the server.

Date Posted: July 07, 2007, 02:40:56 PM
UPDATE
  • Fixed 'maser' typo
  • Fixed the 'master has already been claimed by _.' message coming up on all admin commands

    Date Posted: July 07, 2007, 05:30:55 PM
    UPDATE
  • Fixed admins with master doing listed commands twice.
  • Added an example server
« Last Edit: October 24, 2007, 05:10:16 pm by DorkeyDear »

Offline Mikeman

  • Soldier
  • **
  • Posts: 150
    • Nuke Corruption
Re: Master
« Reply #6 on: July 23, 2007, 11:14:23 am »
I've added this script to my gatherserver, good work :D

Offline zyxstand

  • Veteran
  • *****
  • Posts: 1106
  • Mother of all Bombs
Re: Master
« Reply #7 on: July 24, 2007, 11:04:27 am »
Hey DD, I hope you don't mind, but I've been working on a far more extensive script that is meant especially for gather servers - it's based on this idea but far more complex XD
It SHOULD be a hit... I hope...
Thnx for the inspiration*
Can't think of anything original to put here...

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Master
« Reply #8 on: July 24, 2007, 06:53:48 pm »
Uhh, your welcome? Any note of whats going to be in it? I'm curious.

Offline zyxstand

  • Veteran
  • *****
  • Posts: 1106
  • Mother of all Bombs
Re: Master
« Reply #9 on: July 24, 2007, 10:42:57 pm »
I'll show you personally when it's testable - I'm sure you'll like it...
Can't think of anything original to put here...

Offline Dizzy So 1337

  • Soldier
  • **
  • Posts: 246
Re: Master
« Reply #10 on: August 02, 2007, 01:19:37 am »
Personally I would love to be able to give out 'limited' admin powers to clanmates on clan servers.  Is this currently the best hope for this kind of thing?  Except, in my version it would be granted by a password instead of a /master command.

Looking forward to further news on this.
xfire - todhostetler
"There's nothing I wouldn't do to win. But I never hurt anyone except to stick a dogskull on a stake."

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Master
« Reply #11 on: September 09, 2007, 01:21:01 pm »
Update:
  • Script now supports 2.6.2
  • Adding admin-only (excluding master) command /loadmasterfile
  • Color constant available for change
  • Removed MasterFile constant for no need of choosing where the file is / is named
  • Master now can do custom commands within this script, excluding /loadmasterfile

Offline eca jezza

  • Major(1)
  • Posts: 37
  • {+ECA+} is recruiting!
    • {+ECA+}
Re: Master
« Reply #12 on: September 09, 2007, 01:32:41 pm »
Not bad script! that would be AWESOME! for a clan server if you edit it a tiny bit, what program do you use for the scripts? O.o

Offline xReaperx

  • Major(1)
  • Posts: 45
Re: Master
« Reply #13 on: September 09, 2007, 04:18:00 pm »
Lol, normal base scripting.
This script is pretty cool to muck around with, nothing serious though.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Master
« Reply #14 on: September 09, 2007, 05:25:45 pm »
what program do you use for the scripts?
notepad?

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: Master
« Reply #15 on: September 09, 2007, 05:27:17 pm »
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline mikembm

  • Soldier
  • **
  • Posts: 210
Re: Master
« Reply #16 on: September 12, 2007, 08:24:59 pm »

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Master
« Reply #17 on: October 24, 2007, 05:20:45 pm »
For those who want this to work with other scripts with custom commands, do this:
1. open Master.pas file
2. do "find" and find "Break;"
3. on the line BEFORE THIS LINE, add this:
Quote
CrossFunc([ID, MasterCmds], 'SCRIPTNAME.OnCommand');
where as "SCRIPTNAME" is the name of the folder that the script is in..
if u want it to work with more than 1 script, juts add the exact same thing under this... but with a different SCRIPTNAME.

Offline sckme

  • Major(1)
  • Posts: 33
Re: Master
« Reply #18 on: September 29, 2008, 03:22:27 pm »
For those who want this to work with other scripts with custom commands, do this:
1. open Master.pas file
2. do "find" and find "Break;"
3. on the line BEFORE THIS LINE, add this:
Quote
CrossFunc([ID, MasterCmds], 'SCRIPTNAME.OnCommand');
where as "SCRIPTNAME" is the name of the folder that the script is in..
if u want it to work with more than 1 script, juts add the exact same thing under this... but with a different SCRIPTNAME.

Hello!

I think it's dont work. I install on my dedicadec server script "Infi Pred" and i would like use this script as command when i am master, not an admin. Look on my script.

Quote
const
  AutoMaster = false;
  Color = $0000FF;

var
  Master: byte;
  MasterCmds: tstringarray;

function Split(const Source: string; const Delimiter: string): tstringarray;
var
  i,x,d: integer;
  s: string;
begin
  if Source <> '' then 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
  • := Result
  • + Copy(s,1,1);

        Inc(i,1);
      end;
    end;
  end else SetArrayLength(Result,0);
end;

procedure ActivateServer();
begin
  MasterCmds := Split(ReadFile('scripts/Master/Commands.txt'),Chr(13) + Chr(10));
end;

function OnCommand(ID: Byte; Text: string): boolean;
var
  i: integer;
begin
  Result := false;
  if Text = '/loadmasterfile' then MasterCmds := Split(ReadFile('scripts/Master/Commands.txt'),Chr(13) + Chr(10));
  if Master = ID then for i := 0 to ArrayHigh(MasterCmds) - 1 do if MasterCmds = Copy(Text,2,Length(MasterCmds)) then Result := true;
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
  i: integer;
begin
  if Master = 0 then begin
    if (ID <> 255) and (LowerCase(Text) = '/master') then if Master = 0 then begin
      Master := ID;
      WriteConsole(0,GetPlayerStat(ID,'Name') + ' VIP zaktualizowany!.',Color);
    end else WriteConsole(ID,'Master has already been claimed by ' + GetPlayerStat(Master,'Name') + '.',Color);
  end else if Master = ID then for i := 0 to ArrayHigh(MasterCmds) - 1 do if MasterCmds = Copy(Text,2,Length(MasterCmds)) then begin
    Command(Text);
    if Text <> '/loadmasterfile' then OnCommand(ID,Text);
   CrossFunc([ID, MasterCmds], 'InfiPred.OnCommand'); Break;
  end;
end;

procedure OnJoinGame(ID, Team: byte);
begin
  if (AutoMaster) and (Master = 0) then OnPlayerCommand(ID,'/master');
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
  if ID = Master then Master := 0;
end;

what's wrong with this? Sry for my sucks english.

Ave

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Master
« Reply #19 on: September 29, 2008, 04:55:43 pm »
Ave: please use [.code][/.code] tags (w/out the .s)
but at a first chance, it seems right; except the InfiPred should be Infi Pred, although im not 100% sure if spaces works.. to be on the safe side, make sure the folder name for the infipred script is "InfiPred" (w/out quotes) and using this Master code:
Code: [Select]
const
  AutoMaster = false;
  Color = $FFFFFF;

var
  Master: byte;
  MasterCmds: tstringarray;

function Split(const Source: string; const Delimiter: string): tstringarray;
var
  i,x,d: integer;
  s: string;
begin
  if Source <> '' then 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 else SetArrayLength(Result,0);
end;

procedure ActivateServer();
begin
  MasterCmds := Split(ReadFile('scripts/Master/Commands.txt'),Chr(13) + Chr(10));
end;

function OnCommand(ID: Byte; Text: string): boolean;
var
  i: integer;
begin
  Result := false;
  if Text = '/loadmasterfile' then MasterCmds := Split(ReadFile('scripts/Master/Commands.txt'),Chr(13) + Chr(10));
  if Master = ID then for i := 0 to ArrayHigh(MasterCmds) - 1 do if MasterCmds[i] = Copy(Text,2,Length(MasterCmds[i])) then Result := true;
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
  i: integer;
begin
  if Master = 0 then begin
    if (ID <> 255) and (LowerCase(Text) = '/master') then if Master = 0 then begin
      Master := ID;
      WriteConsole(0,GetPlayerStat(ID,'Name') + ' has claimed master for the server.',Color);
    end else WriteConsole(ID,'Master has already been claimed by ' + GetPlayerStat(Master,'Name') + '.',Color);
  end else if Master = ID then for i := 0 to ArrayHigh(MasterCmds) - 1 do if MasterCmds[i] = Copy(Text,2,Length(MasterCmds[i])) then begin
    Command(Text);
    if Text <> '/loadmasterfile' then OnCommand(ID,Text);
    CrossFunc([ID, MasterCmds[i]], 'InfiPred.OnCommand');
    Break;
  end;
end;

procedure OnJoinGame(ID, Team: byte);
begin
  if (AutoMaster) and (Master = 0) then OnPlayerCommand(ID,'/master');
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
  if ID = Master then Master := 0;
end;
(probably not different)

Offline sckme

  • Major(1)
  • Posts: 33
Re: Master
« Reply #20 on: September 30, 2008, 02:16:34 am »
it's dont work. i wrote in cmd /setpred 1 (1 is my ID, i wrote this in game), and    
nothing happens ;f before when i start my server i edit file commands.txt in folder Master and i wrote command setpred and its sucks, dont work.

Offline Mr

  • Inactive Soldat Developer
  • Soldier
  • ******
  • Posts: 166
Re: Master
« Reply #21 on: September 30, 2008, 06:14:59 am »
it's dont work. i wrote in cmd /setpred 1 (1 is my ID, i wrote this in game), and    
nothing happens ;f before when i start my server i edit file commands.txt in folder Master and i wrote command setpred and its sucks, dont work.

Wait... let's try to translate this to english:
Quote
Sorry, but your script won't work for me. I wrote "/setpred 1" in Soldat's cmd, but nothing happens. Bevore I started my server I edited the commands.txt file in the script's directory. Can you fix this problem, please?

Let's replay to this post :)


Maybe this will help you: http://www.enesce.com/help/index.html?Functions/CrossFunc.html
I don't know the InfPred script, but I guess that this will fix your problem:

Replace this:
Code: [Select]
CrossFunc([ID, MasterCmds[i]], 'InfiPred.OnCommand'); Break;
With this code:
Code: [Select]
CrossFunc([ID, Text], 'InfiPred.OnCommand');
Break;
« Last Edit: September 30, 2008, 06:22:22 am by Mr »

Offline sckme

  • Major(1)
  • Posts: 33
Re: Master
« Reply #22 on: September 30, 2008, 07:27:03 am »
infi pred code:

Code: [Select]
  const
  Color = $FFFFFFFF;

var
  IsPred, AfterRespawn: array[1..32] of boolean;

procedure AppOnIdle(Ticks: cardinal);
var
  i: byte;
begin
  for i := 1 to 32 do if AfterRespawn[i] then begin
    if IsPred[i] then begin
      GiveBonus(i, 1);
      DrawText(i, '  ', 0, $00000000, 0, 0, 0);
    end;
    AfterRespawn[i] := false;
  end;
  if (Ticks mod 600) = 0 then begin
    for i := 1 to 32 do if GetPlayerStat(i, 'Active') = true then if IsPred[i] and (GetPlayerStat(i, 'Alive') = true) then begin
      GiveBonus(i, 1);
      DrawText(i, '  ', 0, $00000000, 0, 0, 0);
    end;
  end;
end;

procedure OnJoinGame(Id, Team: byte);
begin
  IsPred[Id] := false;
end;

function OnCommand(Id: byte; Text: string): boolean;
var
  Who: byte;
begin
  if Text[1] = '/' then begin
    Delete(Text, 1, 1);
    if LowerCase(GetPiece(Text, ' ', 0)) = 'setpred' then begin
      try
        Who := StrtoInt(Copy(Text, 9, Length(Text)));
        if not GetPlayerStat(Who, 'Active') then StrtoInt(' ');
        IsPred[Who] := true;
        if GetPlayerStat(Who, 'Alive') = true then begin
          GiveBonus(Who, 1);
          DrawText(Who, '  ', 0, $00000000, 0, 0, 0);
        end;
        if Id <> Who then WriteConsole(Id, 'You have given ' + GetPlayerStat(Who, 'Name') + ' infinite predator', Color);
        WriteConsole(Who, 'An admin has given you infinite predator', Color);
      except
        WriteConsole(Id, 'Invalid player', Color);
      end;
    end else if LowerCase(GetPiece(Text, ' ', 0)) = 'delpred' then begin
      try
        Who := StrtoInt(Copy(Text, 9, Length(Text)));
        if not GetPlayerStat(Who, 'Active') then StrtoInt(' ');
        IsPred[Who] := false;
        if Id <> Who then WriteConsole(Id, 'You have taken infinite predator from ' + GetPlayerStat(Who, 'Name'), Color);
        WriteConsole(Who, 'An admin has taken your infinite predator', Color);
      except
        WriteConsole(Id, 'Invalid player', Color);
      end;
    end;
  end;
end;

procedure OnPlayerRespawn(Id: byte);
begin
  AfterRespawn[Id] := true;
end;

ur suggestion don't work :)