• How to make a clientsided script to serversided as well?
    5 replies, posted
Hi, I'm currently making an Administration Panel but I have no idea how to make it serversided. I started with coding two days ago so the coding isn't exactly any good... It's Dermal and it will be some functions soon. I only have a lua file in my gmod files. [CODE] surface.CreateFont( "title", { font = "Default", size = 23, weight = 500, } ) surface.CreateFont( "max", { font = "Default", size = 15, weight = 500, } ) local mainframe = vgui.Create("DFrame") mainframe:SetSize(800,600) mainframe:Center(true) mainframe:SetVisible(true) mainframe:SetTitle("") mainframe:MakePopup() mainframe:ShowCloseButton(false) mainframe.Paint = function(s, w, h) draw.RoundedBox(5, 0, 0, w, h,Color(160,160,160)) end local topframe = vgui.Create("DFrame", mainframe) topframe:SetSize(820,25) topframe:SetPos(-1,0) topframe:ShowCloseButton(false) topframe:SetTitle("") topframe.Paint = function(s, w, h) draw.RoundedBox(5, 0, 0, w, h,Color(0,128,255)) end local middleframe = vgui.Create("DFrame", mainframe) middleframe:SetSize(5,800) middleframe:SetPos(390,25) middleframe:SetTitle("") middleframe:SetVisible(true) middleframe:ShowCloseButton(false) middleframe.Paint = function(s, w, h) draw.RoundedBoxEx(5, 0, 0, w, h,Color(0,128,255)) end local middlevertictframe = vgui.Create("DFrame", mainframe) middlevertictframe:SetSize(395,5) middlevertictframe:SetPos(0,320) middlevertictframe:SetTitle("") middlevertictframe:SetVisible(true) middlevertictframe:ShowCloseButton(false) middlevertictframe.Paint = function(s, w, h) draw.RoundedBoxEx(5, 0, 0, w, h,Color(0,128,255)) end local rightframe = vgui.Create("DFrame", mainframe) rightframe:SetSize(415,575) rightframe:SetPos(395,25) rightframe:SetVisible(true) rightframe:SetTitle("") rightframe:ShowCloseButton(false) rightframe.Paint = function(s, w, h) draw.RoundedBoxEx(5, 0, 0, w, h,Color(160,160,160)) end local leftframe = vgui.Create("DFrame", mainframe) leftframe:SetSize(5,800) leftframe:SetPos(0,24) leftframe:SetTitle("") leftframe:SetVisible(true) leftframe:ShowCloseButton(false) leftframe.Paint = function(s, w, h) draw.RoundedBoxEx(5, 0, 0, w, h,Color(0,128,255)) end local rightrightframe = vgui.Create("DFrame", mainframe) rightrightframe:SetSize(5,800) rightrightframe:SetPos(795,24) rightrightframe:SetTitle("") rightrightframe:SetVisible(true) rightrightframe:ShowCloseButton(false) rightrightframe.Paint = function(s, w, h) draw.RoundedBoxEx(5, 0, 0, w, h,Color(0,128,255)) end local downverdictframe = vgui.Create("DFrame", mainframe) downverdictframe:SetSize(850,5) downverdictframe:SetPos(-5,595) downverdictframe:SetTitle("") downverdictframe:SetVisible(true) downverdictframe:ShowCloseButton(false) downverdictframe.Paint = function(s, w, h) draw.RoundedBoxEx(5, 0, 0, w, h,Color(0,128,255)) end local closebutton = vgui.Create("DButton", mainframe) closebutton:SetSize(10,15) closebutton:SetPos(780,5) closebutton:SetText("X") closebutton:SetVisible(true) closebutton.DoClick = function() mainframe:Close() end closebutton.Paint = function(s, w, h) draw.RoundedBox(5, 0, 0, w, h,Color(255,255,255)) end local toptext = vgui.Create("DLabel", mainframe) toptext:SetPos(300,1) toptext:SetFont("title") toptext:SetText("Administration Panel") toptext:SizeToContents() toptext:SetTextColor( Color(255,255,255)) local cloak = vgui.Create("DNumSlider", mainframe) cloak:SetPos(400,50) cloak:SetSize(300,20) cloak:SetText("") cloak:SetMin(0) cloak:SetMax(256) cloak:SetDecimals(0) local cloaktext = vgui.Create("DLabel", mainframe) cloaktext:SetPos(450,50) cloaktext:SetFont("max") cloaktext:SetText("Cloak") cloaktext:SizeToContents() cloaktext:SetTextColor( Color(255,255,255)) local health = vgui.Create("DNumSlider", mainframe) health:SetPos(400,100) health:SetSize(300,20) health:SetText("") health:SetMin(1) health:SetMax(100) health:SetDecimals(0) local healthtext = vgui.Create("DLabel", mainframe) healthtext:SetPos(450,100) healthtext:SetFont("max") healthtext:SetText("Health") healthtext:SizeToContents() healthtext:SetTextColor( Color(255,255,255)) local tplist = vgui.Create("DComboBox", mainframe); tplist:SetPos(100,348) tplist:SetSize(100,20) tplist:SetValue("Player") tplist:AddChoice("Player1") tplist:AddChoice("Player2") tplist:AddChoice("Player3") local tptext = vgui.Create("DLabel", mainframe) tptext:SetPos(50,350) tptext:SetFont("max") tptext:SetText("Goto") tptext:SizeToContents() tptext:SetTextColor( Color(255,255,255)) [/CODE]
[i]"how to make it serversided"[/i] - what exactly do you mean?
[QUOTE=Nickolay;51779434]Hi, I'm currently making an Administration Panel but I have no idea how to make it serversided. I started with coding two days ago so the coding isn't exactly any good... It's Dermal and it will be some functions soon. I only have a lua file in my gmod files. [CODE] surface.CreateFont( "title", { font = "Default", size = 23, weight = 500, } ) surface.CreateFont( "max", { font = "Default", size = 15, weight = 500, } ) local mainframe = vgui.Create("DFrame") mainframe:SetSize(800,600) mainframe:Center(true) mainframe:SetVisible(true) mainframe:SetTitle("") mainframe:MakePopup() mainframe:ShowCloseButton(false) mainframe.Paint = function(s, w, h) draw.RoundedBox(5, 0, 0, w, h,Color(160,160,160)) end local topframe = vgui.Create("DFrame", mainframe) topframe:SetSize(820,25) topframe:SetPos(-1,0) topframe:ShowCloseButton(false) topframe:SetTitle("") topframe.Paint = function(s, w, h) draw.RoundedBox(5, 0, 0, w, h,Color(0,128,255)) end local middleframe = vgui.Create("DFrame", mainframe) middleframe:SetSize(5,800) middleframe:SetPos(390,25) middleframe:SetTitle("") middleframe:SetVisible(true) middleframe:ShowCloseButton(false) middleframe.Paint = function(s, w, h) draw.RoundedBoxEx(5, 0, 0, w, h,Color(0,128,255)) end local middlevertictframe = vgui.Create("DFrame", mainframe) middlevertictframe:SetSize(395,5) middlevertictframe:SetPos(0,320) middlevertictframe:SetTitle("") middlevertictframe:SetVisible(true) middlevertictframe:ShowCloseButton(false) middlevertictframe.Paint = function(s, w, h) draw.RoundedBoxEx(5, 0, 0, w, h,Color(0,128,255)) end local rightframe = vgui.Create("DFrame", mainframe) rightframe:SetSize(415,575) rightframe:SetPos(395,25) rightframe:SetVisible(true) rightframe:SetTitle("") rightframe:ShowCloseButton(false) rightframe.Paint = function(s, w, h) draw.RoundedBoxEx(5, 0, 0, w, h,Color(160,160,160)) end local leftframe = vgui.Create("DFrame", mainframe) leftframe:SetSize(5,800) leftframe:SetPos(0,24) leftframe:SetTitle("") leftframe:SetVisible(true) leftframe:ShowCloseButton(false) leftframe.Paint = function(s, w, h) draw.RoundedBoxEx(5, 0, 0, w, h,Color(0,128,255)) end local rightrightframe = vgui.Create("DFrame", mainframe) rightrightframe:SetSize(5,800) rightrightframe:SetPos(795,24) rightrightframe:SetTitle("") rightrightframe:SetVisible(true) rightrightframe:ShowCloseButton(false) rightrightframe.Paint = function(s, w, h) draw.RoundedBoxEx(5, 0, 0, w, h,Color(0,128,255)) end local downverdictframe = vgui.Create("DFrame", mainframe) downverdictframe:SetSize(850,5) downverdictframe:SetPos(-5,595) downverdictframe:SetTitle("") downverdictframe:SetVisible(true) downverdictframe:ShowCloseButton(false) downverdictframe.Paint = function(s, w, h) draw.RoundedBoxEx(5, 0, 0, w, h,Color(0,128,255)) end local closebutton = vgui.Create("DButton", mainframe) closebutton:SetSize(10,15) closebutton:SetPos(780,5) closebutton:SetText("X") closebutton:SetVisible(true) closebutton.DoClick = function() mainframe:Close() end closebutton.Paint = function(s, w, h) draw.RoundedBox(5, 0, 0, w, h,Color(255,255,255)) end local toptext = vgui.Create("DLabel", mainframe) toptext:SetPos(300,1) toptext:SetFont("title") toptext:SetText("Administration Panel") toptext:SizeToContents() toptext:SetTextColor( Color(255,255,255)) local cloak = vgui.Create("DNumSlider", mainframe) cloak:SetPos(400,50) cloak:SetSize(300,20) cloak:SetText("") cloak:SetMin(0) cloak:SetMax(256) cloak:SetDecimals(0) local cloaktext = vgui.Create("DLabel", mainframe) cloaktext:SetPos(450,50) cloaktext:SetFont("max") cloaktext:SetText("Cloak") cloaktext:SizeToContents() cloaktext:SetTextColor( Color(255,255,255)) local health = vgui.Create("DNumSlider", mainframe) health:SetPos(400,100) health:SetSize(300,20) health:SetText("") health:SetMin(1) health:SetMax(100) health:SetDecimals(0) local healthtext = vgui.Create("DLabel", mainframe) healthtext:SetPos(450,100) healthtext:SetFont("max") healthtext:SetText("Health") healthtext:SizeToContents() healthtext:SetTextColor( Color(255,255,255)) local tplist = vgui.Create("DComboBox", mainframe); tplist:SetPos(100,348) tplist:SetSize(100,20) tplist:SetValue("Player") tplist:AddChoice("Player1") tplist:AddChoice("Player2") tplist:AddChoice("Player3") local tptext = vgui.Create("DLabel", mainframe) tptext:SetPos(50,350) tptext:SetFont("max") tptext:SetText("Goto") tptext:SizeToContents() tptext:SetTextColor( Color(255,255,255)) [/CODE][/QUOTE] I'd assume you'd use net messages to network the server sided stuff and also use if ( CLIENT ) then and also if ( SERVER ) then to ensure it all stays in the one document...just my 2 cents
[QUOTE=CupCakeR;51779468][i]"how to make it serversided"[/i] - what exactly do you mean?[/QUOTE] The current lua is only Client Sided, so I can not run Server Sided stuff. So I need to make a script, not only a lua file.
[QUOTE=Nickolay;51780912]The current lua is only Client Sided, so I can not run Server Sided stuff. So I need to make a script, not only a lua file.[/QUOTE] I think network stuff would be valid in this situation then, cause everyone makes their stuff clientside then networks it with this and that. I could b wrong but I heavily doubt it.
[QUOTE=Nickolay;51780912]The current lua is only Client Sided, so I can not run Server Sided stuff. So I need to make a script, not only a lua file.[/QUOTE] [url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url]
Sorry, you need to Log In to post a reply to this thread.