Recently I have been working on a message of the day addon for gmod.
In my server's data folder I have a file called motd.txt which contains the html that is displayed when the motd command is run.
I would like to know how to [B]send[/B] this file to the client.
Currently if the client doesn't have motd.txt they just get a bunch of file not found errors.
Here's my code so far:
lua\autorun\client\motd.lua
[code]
function motd()
local motdFrame = vgui.Create("DFrame");
motdFrame:SetSize(1024, 768);
motdFrame:Center();
motdFrame:SetVisible(true);
motdFrame:MakePopup();
motdFrame:SetTitle("Message of the Day")
local motdFrameHtml = vgui.Create("HTML", motdFrame);
motdFrameHtml:SetPos(25, 50);
motdFrameHtml:SetSize( motdFrame:GetWide() - 50, motdFrame:GetTall() - 130 )
motdFrameHtml:SetHTML("")
local button = vgui.Create("DButton", motdFrame);
button:SetSize( 100, 40 )
button:SetPos( (motdFrame:GetWide() - button:GetWide()) / 2, motdFrame:GetTall() - button:GetTall() - 10 )
button:SetText("Close")
button.DoClick = function ()
motdFrame:Close();
end
local htmlFile = file.Read("motd.txt");
local gh = htmlFile;
motdFrameHtml:SetHTML(gh);
end
concommand.Add("motd", motd);
[/code]
lua\autorun\server\sv_motd.lua
[CODE]
AddCSLuaFile("autorun/client/motd.lua")
[/CODE]
data\motd.txt
[HTML]
<h2>place html here</h2>
[/HTML]
addon.txt
[code]
"AddonInfo"
{
"name" "MOTD"
"version" "1.0"
"author_name" "Gamer12594"
"info" "Message of the Day"
}
[/code]
If all you have in the .txt file is a URL string it might be much easier using something like: [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index1cfa.html[/url] since this does not require a download.
[QUOTE=.Tenshi;41291249]If all you have in the .txt file is a URL string it might be much easier using something like: [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index1cfa.html[/url] since this does not require a download.[/QUOTE]
The thing is is that when I'm finished with my addon I want to be able to distribute it. It would be annoying for any server owner who downloaded it to have to go through the lua files and change the URL to wherever they have their motd hosted.
I know that ULX somehow manages to send ulx_motd.txt to the client.
[QUOTE=Gamer12594;41297498]I know that ULX somehow manages to send ulx_motd.txt to the client.[/QUOTE]
Then ask at [url]http://forums.ulyssesmod.net/[/url]. I'm sure they'd be happy to help.
[QUOTE=Internet1001;41314218]Then ask at [URL]http://forums.ulyssesmod.net/[/URL]. I'm sure they'd be happy to help.[/QUOTE]
This isn't a problem with ULX it's a problem with [B]my[/B] lua file.
Although that might be useful, I'll look into it.
Yeah, but they already did it and they might be able to tell you how they did it.
Also why not just put the motd.txt into a net message with file.read, send it to the client, and then write a file on the client? (But note the 64kb (or smth) size limit)
[url]http://wiki.garrysmod.com/page/Using_the_net_library[/url]
Or just read the url in the motd.txt and send it to client, so server owners just have to change that and not a lua file.
[QUOTE=LennyPenny;41314677]Yeah, but they already did it and they might be able to tell you how they did it.
Also why not just put the motd.txt into a net message with file.read, send it to the client, and then write a file on the client? (But note the 64kb (or smth) size limit)
[url]http://wiki.garrysmod.com/page/Using_the_net_library[/url][/QUOTE]
That's the reason I've edited my post.
Anyway this currently Isn't the most important thing I need to get done.
Sorry, you need to Log In to post a reply to this thread.