Official Soldat Forums

Server Talk => Scripting Releases => Topic started by: DorkeyDear on July 05, 2007, 05:56:26 pm

Title: Master
Post by: DorkeyDear 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
Title: Re: Master
Post by: Shadow G-Unit on July 05, 2007, 06:07:45 pm
Wow, another great script for that all great DorkeyDear (who is not that Dorkey :))
Title: Re: Master
Post by: Mastadi on July 05, 2007, 06:11:29 pm
Yay, nice script!
Title: Re: Master
Post by: Leo on July 07, 2007, 05:17:32 am
And if the first person that joins is an idiot he will screw up your server...  ;)
Title: Re: Master
Post by: urraka on July 07, 2007, 12:11:21 pm
That depends of what commands are on the list.
Title: Re: Master
Post by: DorkeyDear 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
Title: Re: Master
Post by: Mikeman on July 23, 2007, 11:14:23 am
I've added this script to my gatherserver, good work :D
Title: Re: Master
Post by: zyxstand 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*
Title: Re: Master
Post by: DorkeyDear on July 24, 2007, 06:53:48 pm
Uhh, your welcome? Any note of whats going to be in it? I'm curious.
Title: Re: Master
Post by: zyxstand on July 24, 2007, 10:42:57 pm
I'll show you personally when it's testable - I'm sure you'll like it...
Title: Re: Master
Post by: Dizzy So 1337 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.
Title: Re: Master
Post by: DorkeyDear on September 09, 2007, 01:21:01 pm
Update:
Title: Re: Master
Post by: eca jezza 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
Title: Re: Master
Post by: xReaperx on September 09, 2007, 04:18:00 pm
Lol, normal base scripting.
This script is pretty cool to muck around with, nothing serious though.
Title: Re: Master
Post by: DorkeyDear on September 09, 2007, 05:25:45 pm
what program do you use for the scripts?
notepad?
Title: Re: Master
Post by: Avarax on September 09, 2007, 05:27:17 pm
http://www.pspad.com
Title: Re: Master
Post by: mikembm on September 12, 2007, 08:24:59 pm
http://www.flos-freeware.ch/notepad2.html
Title: Re: Master
Post by: DorkeyDear 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.
Title: Re: Master
Post by: sckme 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
Title: Re: Master
Post by: DorkeyDear 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)
Title: Re: Master
Post by: sckme 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.
Title: Re: Master
Post by: Mr 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;
Title: Re: Master
Post by: sckme 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 :)