Random MOTD code

For all mod-related questions and custom code.
Post Reply
Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

Random MOTD code

Post by Jonty800 »

would it be possible to make the MOTD random by reading a random line from a .txt file?

Where abouts is the motd code part? lol
You cannot use certain BBCodes: [img].

User avatar
Hellenion
Offline
Posts: 220
Joined: October 20th, 2011, 9:20 am
Location: Subnet
Contact:

Re: Random MOTD code

Post by Hellenion »

for a Message Of The Day, it is being changed surprisingly little indeed.
A = {x ∈ P(U) | x ∉ x}
Mods:
  1. /Su - Allows players to temporarily become a different rank
  2. /Snap - Like /Line but only draws straight or diagonal lines.
  3. pre-0.630 skip/none block

Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

Re: Random MOTD code

Post by Jonty800 »

it all seems complicated because of the /env womid stuff.

I basically want to add a

Code: Select all

if file exists... read random line from motd.txt
else, use normal behaviour
I know how to do this, just not sure where.
You cannot use certain BBCodes: [img].

User avatar
Hellenion
Offline
Posts: 220
Joined: October 20th, 2011, 9:20 am
Location: Subnet
Contact:

Re: Random MOTD code

Post by Hellenion »

I'm guessing it's in Player.Networking around line 665, but I could be wrong.

Hold on...
Commit by fragmer :: r1219 /branch-0.60x/fCraft/ (2 files in 2 dirs):
Moved Player.Networking.cs from Player/ to Networking/. Derp.
I'm using old revisions...
A = {x ∈ P(U) | x ∉ x}
Mods:
  1. /Su - Allows players to temporarily become a different rank
  2. /Snap - Like /Line but only draws straight or diagonal lines.
  3. pre-0.630 skip/none block

Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

Re: Random MOTD code

Post by Jonty800 »

I did the usual "search the entire project for motd"

each result looked confusing.

I'll look at it again tomorrow, and post any success I have
You cannot use certain BBCodes: [img].

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Random MOTD code

Post by fragmer »

Here's how MOTD works.
For the initial connection:
  • If WoM extensions are enabled (ConfigKey.WoMEnableEnvExtensions), everyone is sent the WoM configuration link (&0cfg=IP:Prt/WorldName~motd"). WoM users have that replaced by the actual MOTD when they download the config from the server (produced by World.GenerateWoMConfig method).
  • If WoM extensions are not enabled, everyone gets to see the MOTD (produced by Player.LoginSequence method).
For world changes, everyone gets to see "Loading world <WorldName>", but it's produced in different ways.
  • If WoM extensions are enabled AND the player is using WoM, that message is produced by World.GenerateWoMConfig, from a separate thread.
  • For everyone else, that message is produced by Player.JoinWorldNow, from the player's i/o thread.
There is also a Player.JoiningWorld event which allows changing those two lines of text that are shown during joining/loading. Note that if WoM extensions are enabled, the initial connection's MOTD must contain the config link. And if WoM extensions are enabled AND the player is using WoM, there is currently no easy event-based way to edit that message produced by World.GenerateWoMConfig. WoM complicates things :<

Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

Re: Random MOTD code

Post by Jonty800 »

Thanks for the support, not worth the hassle :P
You cannot use certain BBCodes: [img].

Post Reply