Official Soldat Forums
Server Talk => Scripting Releases => Topic started 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)
say
kill
kick
password
setteam
map
restart
pause
unpause
gmute
ungmute
-
Wow, another great script for that all great DorkeyDear (who is not that Dorkey :))
-
Yay, nice script!
-
And if the first person that joins is an idiot he will screw up your server... ;)
-
That depends of what commands are on the list.
-
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
-
I've added this script to my gatherserver, good work :D
-
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*
-
Uhh, your welcome? Any note of whats going to be in it? I'm curious.
-
I'll show you personally when it's testable - I'm sure you'll like it...
-
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.
-
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
-
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
-
Lol, normal base scripting.
This script is pretty cool to muck around with, nothing serious though.
-
what program do you use for the scripts?
notepad?
-
http://www.pspad.com
-
http://www.flos-freeware.ch/notepad2.html
-
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:
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.
-
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:
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.
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
    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
-
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:
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)
-
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.
-
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:
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:
CrossFunc([ID, MasterCmds[i]], 'InfiPred.OnCommand'); Break;
With this code:
CrossFunc([ID, Text], 'InfiPred.OnCommand');
Break;
-
infi pred code:
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 :)