Author Topic: MOTD (message of the day) script  (Read 4139 times)

0 Members and 1 Guest are viewing this topic.

Offline Maff^

  • Major(1)
  • Posts: 20
    • Personal page
MOTD (message of the day) script
« on: June 06, 2007, 09:53:44 am »
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: parseVarString
Code: (best placed in Core.pas)
Code: [Select]
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
Code: [Select]
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)
Code: [Select]
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:
Code: [Select]
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.
Live server info for Zitro-Stats: topic | brokenliquid.net/zitrostats/
Brokenliquid.net DM Serv (soldat://130.89.164.52:23073/) (1.4.2)
now playing: Jungle (2/32) next: Krab

sig updated on 06-10-2008 23:28:45 (GMT+1)

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: MOTD (message of the day) script
« Reply #1 on: June 06, 2007, 09:57:46 am »
For {timeleft}, you should do TimeLeft div 60.... That will return the timeleft in minutes.

Offline Maff^

  • Major(1)
  • Posts: 20
    • Personal page
Re: MOTD (message of the day) script
« Reply #2 on: June 06, 2007, 10:05:57 am »
I know, but I would like it to be like '3m24s'.

(Floor(TimeLeft/60)+'m'+(TimeLeft % 60)+'s') .. only it needs to be in Pascal :P
Live server info for Zitro-Stats: topic | brokenliquid.net/zitrostats/
Brokenliquid.net DM Serv (soldat://130.89.164.52:23073/) (1.4.2)
now playing: Jungle (2/32) next: Krab

sig updated on 06-10-2008 23:28:45 (GMT+1)

Offline KeYDoN

  • Major
  • *
  • Posts: 60
Re: MOTD (message of the day) script
« Reply #3 on: June 07, 2007, 09:00:27 am »
str:= IntToStr(Timeleft div 60)+'m'+IntToStr(Timeleft mod 60)+'s';

Offline miketh2005

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 668
  • What's the URL for www.microsoft.com?
Re: MOTD (message of the day) script
« Reply #4 on: August 23, 2007, 05:52:55 pm »
can someone zip this one too? :( thanx
Quote from: 'Ando.' pid='12999178' dateline='1309046898'
My new password is secure as shit :)
Mate, I am not sure Shit is even secured nowadays.

Offline Kitty

  • Major
  • *
  • Posts: 60
Re: MOTD (message of the day) script
« Reply #5 on: September 10, 2007, 03:18:50 pm »
Could someone Zip this or something cause when it comes to editing diff files i screw it all up xD
-A female soldat player.


Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: MOTD (message of the day) script
« Reply #6 on: September 11, 2007, 06:58:20 pm »
2.6.2 ZIP attached.