Script Name: MOTDscript
Script Description: Displays a customable MOTD (saved in you server dir) to joining players.
Original Author(s): Maff^
Core Version: 2.6.1
Requirements: parseVarStringCode: (best placed in Core.pas)
const
MOTD_DELAY=500; // how long to show the MOTD (500 = 5s)
MOTD_FILENAME='motd.txt';
procedure displayMOTD(ID: byte);
var
MOTD: String;
begin
// make sure the file excists
if (FileExists(MOTD_FILENAME)) then begin
MOTD := ReadFile(MOTD_FILENAME);
MOTD := parseVarString(MOTD);
DrawText(ID,MOTD,MOTD_DELAY,$FFfff5b1,0.10,5,50);
end;
end;
Placed in NetworkCore.pas
procedure OnJoinGame(ID, Team: byte);
begin
displayMOTD(ID);
end;
Optional code in Core.pas (If a player sends the /motd command, it will show him the motd again)
function OnPlayerCommand(ID: Byte; Text: string): boolean;
var Command:String;
begin
//NOTE: This function will be called when [_ANY_] player types a / command.
if (ContainsString(Text,' ')) then Command := GetPiece(Text,' ',1) else Command := Text;
case LowerCase(Command) of
'/motd': displayMOTD(ID);
end;
Result := false; //Return true if you want disable the command typed.
end;
Example motd.txt:Welcome to {ServerName}!
{NumPlayers} playing {GameStyle} on {CurrentMap}.
Next map wil be {NextMap} in max {TimeLeft}s.
Player commands:
/stats :displays your ZitroStats rank
/motd :displays this message
Don't forget to visit
www.brokenliquid.net/zitrostats/
Admins: Goudvis, Frggl & Maff^
Server: {ServerVersion} dedicated on {System}.
Localtime: {Time} {Date}
Result:Notes:
- Only tested it on 2.6.1 dedicated Windows server.
- Initially I wanted to make the message scale if the text was to big for the screen, but I found it to hard, and pretty useless exactly.
- You could change te position and color of the MOTD by chaning the
DrawText() parameters.
- I (or someone else) should write some code to format the TiemLeft var.