• Forcing a client to receive a file
    6 replies, posted
So I have this file in my server's data folder, ev_motd.txt I'm trying to send it to the client in a MOTD plugin: [CODE]-- Remember to create the ev_motd.txt in the data folder and add the contents!! local PLUGIN = {} PLUGIN.Title = "MOTD" PLUGIN.Description = "Server Start Message" PLUGIN.Author = "Sting" PLUGIN.ChatCommand = "motd" PLUGIN.Usage = nil PLUGIN.Privileges = nil PLUGIN.MotdPanel = nil function PLUGIN:Call( ply, args ) self:OpenMotd( ply ) end function PLUGIN:PlayerInitialSpawn( ply ) timer.Simple( 1, function() ply:ConCommand("ev_motd") end) end function PLUGIN:OpenMotd( ply ) if (SERVER) then ply:ConCommand("ev_motd") end end if (SERVER) then if (file.Exists("ev_motd.txt", "DATA")) then resource.AddFile("data/ev_motd.txt") else Msg("\n") Msg("====================== \n") Msg("Missing MOTD file! \n") Msg("Make sure the file exists as: ev_motd.txt in data! \n") Msg("====================== \n") Msg("\n") end end if (CLIENT) then function PLUGIN:CreateMenu() local w,h = ScrW() - 200,ScrH() - 200 self.MotdPanel = vgui.Create("DFrame") self.MotdPanel:SetPos( 100,100 ) self.MotdPanel:SetSize( w, h ) self.MotdPanel:SetTitle( "MOTD" ) self.MotdPanel:SetVisible( false ) self.MotdPanel:SetDraggable( true ) self.MotdPanel:ShowCloseButton( true ) self.MotdPanel:SetDeleteOnClose( false ) self.MotdPanel:SetScreenLock( true ) self.MotdPanel:MakePopup() self.MotdBox = vgui.Create("HTML",self.MotdPanel) self.MotdBox:StretchToParent( 4,25,4,4 ) if (file.Exists("ev_motd.txt", "DATA")) then self.MotdBox:SetHTML( file.Read( "ev_motd.txt", "DATA") ) else print("No MOTD Given.") end end timer.Simple( 0.1, function() PLUGIN:CreateMenu() end) concommand.Add("ev_motd",function(ply,cmd,args) if PLUGIN.MotdPanel then PLUGIN.MotdPanel:SetVisible( true ) end end) end evolve:RegisterPlugin( PLUGIN ) [/CODE] However, although the download appears as they try to join, it never appears in their data folder. What am I doing wrong?
You must put it on your FastDL too.
Robotboy, I've already done that. However, I think I've found a solution. I just learned some netcode, and bam, a working MOTD. Let me know if you see any areas for improvement before I mark this as solved. [CODE]-- Remember to create the ev_motd.txt in the data folder and add the contents!! local PLUGIN = {} PLUGIN.Title = "MOTD" PLUGIN.Description = "Server Start Message" PLUGIN.Author = "Sting" PLUGIN.ChatCommand = "motd" PLUGIN.Usage = nil PLUGIN.Privileges = nil EvolveMotdPanel = nil if SERVER then util.AddNetworkString( "MOTDPacket" ) end function PLUGIN:Call( ply, args ) self:OpenMotd( ply ) end function MOTDPlayerInitialSpawn( ply ) if (file.Exists("evolve_motd/ev_motd.txt", "DATA")) then timer.Create("MOTDTimerFor"..ply:Nick(),3,3,function() net.Start( "MOTDPacket" ) local tmpstr = file.Read("evolve_motd/ev_motd.txt", "DATA") if tmpstr then net.WriteString( tmpstr ) else net.WriteString( "Bad MOTD" ) end net.Send( ply) end) else Msg("\n") Msg("====================== \n") Msg("Missing MOTD file! \n") Msg("Make sure the file exists as: ev_motd.txt in data/evolve_motd/! \n") Msg("====================== \n") Msg("\n") end timer.Simple( 7, function() ply:ConCommand("ev_motd") end) end if SERVER then hook.Add("PlayerInitialSpawn", "playerInitialSpawn", MOTDPlayerInitialSpawn) end function PLUGIN:OpenMotd( ply ) if (SERVER) then ply:ConCommand("ev_motd") end end if (SERVER) then if (file.Exists("evolve_motd/ev_motd.txt", "DATA")) then print("Received Valid MOTD") else Msg("\n") Msg("====================== \n") Msg("Missing MOTD file! \n") Msg("Make sure the file exists as: ev_motd.txt in data/evolve_motd/! \n") Msg("====================== \n") Msg("\n") end end if (CLIENT) then net.Receive( "MOTDPacket" , function( length ) local w,h = ScrW() - 200,ScrH() - 200 EvolveMotdPanel = vgui.Create("DFrame") EvolveMotdPanel:SetPos( 100,100 ) EvolveMotdPanel:SetSize( w, h ) EvolveMotdPanel:SetTitle( "MOTD" ) EvolveMotdPanel:SetVisible( false ) EvolveMotdPanel:SetDraggable( true ) EvolveMotdPanel:ShowCloseButton( true ) EvolveMotdPanel:SetDeleteOnClose( false ) EvolveMotdPanel:SetScreenLock( true ) EvolveMotdPanel:MakePopup() EvolveMotdBox = vgui.Create("HTML",EvolveMotdPanel) EvolveMotdBox:StretchToParent( 4,25,4,4 ) local motdstr = net.ReadString() if (tonumber(length)>0) then EvolveMotdBox:SetHTML( motdstr ) print("Valid MOTD Received") else print("No MOTD Given.") end end) concommand.Add("ev_motd",function(ply,cmd,args) if EvolveMotdPanel then EvolveMotdPanel:SetVisible( true ) end end) end evolve:RegisterPlugin( PLUGIN )[/CODE]
im sorry man but why in the world would you do a motd lik that wtf
This is a very....odd way to do an motd..
Here's my old MOTD- which is fully CLIENTSIDE. [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/motd.lua[/url] Edit: Oh, I forgot that I have it hooked into my base dpanel. You may not have some functions like ClosePanel ( which calls OnClose, in addition to recursively removing all elements related to the motd window )
[QUOTE=Acecool;44427922]Here's my old MOTD- which is fully CLIENTSIDE. [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/motd.lua[/url] Edit: Oh, I forgot that I have it hooked into my base dpanel. You may not have some functions like ClosePanel ( which calls OnClose, in addition to recursively removing all elements related to the motd window )[/QUOTE] I designed my MOTD similar to ULX's, so that it'll load from a txt file and send to the client. What did I do wrong here?
Sorry, you need to Log In to post a reply to this thread.