Ok after my previous forums I have finished my beautiful creation! However, it only works in single player?!?!? wtf. Because data files are only made in the server from the init.lua and in my vgui file when net.receives it is all player sided. Help!
[CODE]AddCSLuaFile()
include( "jobs.lua" )
include( "vgui.lua" )
local function Init()
if not file.Exists( "data/the-creator-logs", "GAME" ) then
file.CreateDir( "the-creator-logs" )
file.CreateDir( "the-creator-logs/jobs" )
file.Write( "the-creator-logs/read.txt", 'DO NOT DELETE THIS FILE, UNLESS YOU DO NOT WANT YOUR CUSTOM, SWEPS/WEAPONS, JOBS and MORE!' )
end
end
hook.Add( "Initialize", "init", Init )
if SERVER then
util.AddNetworkString( "cstudio" )
end
hook.Add( "PlayerSay", "CStudios", function( ply, text, team )
if ( text == "!c-s" ) then
if ply:IsAdmin() then
net.Start( "cstudio" )
net.Send( ply )
return "";
else
ply:ChatPrint( "You dont have access!" )
end
end
end );[/CODE]
/\ WORKS (Init.lua)
[CODE]net.Receive( "cstudio",
function() end)[/CODE]
/\ this works, but sends the jobs to the local players data files...
I know it is net.Send( ply ) because its a vgui. Anyway I can work around it?
Can you show the full client code? Not exactly sure what you're trying to do.
Because youre running the code on client too? Thats why its saving in the players data too.
[QUOTE=Klaes4Zaugen;51397050]Because youre running the code on client too? Thats why its saving in the players data too.[/QUOTE]
Yes. I know this! :P just the fact is I wan't an easier way... to file.write thats why I said I need help working my way around net messages because I don't know how to send these data files back to server, file and then its done there?
[editline]20th November 2016[/editline]
[QUOTE=jacobcooper18;51397226]Yes. I know this! :P just the fact is I wan't an easier way... to file.write thats why I said I need help working my way around net messages because I don't know how to send these data files back to server, file and then its done there?[/QUOTE]
Would Console Commands work? Like concommand add in init.lua then run it in vgui/client.lua
[editline]20th November 2016[/editline]
[QUOTE=code_gs;51395268]Can you show the full client code? Not exactly sure what you're trying to do.[/QUOTE]
[CODE]AddCSLuaFile()
local files, directories = file.Find( "the-creator-logs/jobs/*", "DATA" )
net.Receive( "cstudio",
function()
local frame = vgui.Create( "DFrame" )
frame:SetSize( 500, 600 )
frame:SetTitle( "Creator Studio" )
frame:MakePopup()
frame:Center()
local Scroll = vgui.Create( "DScrollPanel", frame ) //Create the Scroll panel
Scroll:SetSize( 355, 200 )
Scroll:SetPos( 50, 100 )
local List = vgui.Create( "DIconLayout", Scroll )
List:SetSize( 340, 200 )
List:SetPos( 0, 0 )
List:SetSpaceY( 5 ) //Sets the space in between the panels on the X Axis by 5
List:SetSpaceX( 5 ) //Sets the space in between the panels on the Y Axis by 5
local DButton1 = vgui.Create( "DButton", frame )
DButton1:SetPos( 50, 40 )
DButton1:SetText( "Add" )
DButton1:SetSize( 120, 60 )
DButton1.DoClick = function()
local frame2 = vgui.Create( "DFrame" )
frame2:SetSize( 500, 600 )
frame2:SetTitle( "Creator Studio - Add" )
frame2:MakePopup()
frame2:Center()
-- Name
local name = vgui.Create( "DTextEntry", frame2 ) -- create the form as a child of frame
name:SetPos( 80, 25 )
name:SetSize( 360, 15 )
name:SetText( "" )
local namepanel = vgui.Create( "DPanel", frame2 )
namepanel:SetPos( 25, 25 ) -- Set the position of the panel
namepanel:SetSize( 50, 15 ) -- Set the size of the panel
local nametext = vgui.Create( "DLabel", namepanel )
nametext:SetPos( 10, 0 )
nametext:SetText( "Name" ) -- Set the text of the label
nametext:SizeToContents()
nametext:SetDark( 1 )
-- Color
local colors = vgui.Create( "DTextEntry", frame2 ) -- create the form as a child of frame
colors:SetPos( 75, 50 )
colors:SetSize( 155, 15 )
colors:SetText( "255 255 255" )
local colorpanel = vgui.Create( "DPanel", frame2 )
colorpanel:SetPos( 25, 50 ) -- Set the position of the panel
colorpanel:SetSize( 50, 20 ) -- Set the size of the panel
local colortext = vgui.Create( "DLabel", colorpanel )
colortext:SetPos( 10, 0 )
colortext:SetText( "Color" ) -- Set the text of the label
colortext:SizeToContents()
colortext:SetDark( 1 )
-- Player Model
local model = vgui.Create( "DTextEntry", frame2 ) -- create the form as a child of frame
model:SetPos( 85, 75 )
model:SetSize( 360, 15 )
model:SetText( "ex: models/player/alyx.mdl, models/player/breen.mdl" )
local modelpanel = vgui.Create( "DPanel", frame2 )
modelpanel:SetPos( 25, 75 ) -- Set the position of the panel
modelpanel:SetSize( 50, 15 ) -- Set the size of the panel
local modeltext = vgui.Create( "DLabel", modelpanel )
modeltext:SetPos( 10, 0 )
modeltext:SetText( "Models" ) -- Set the text of the label
modeltext:SizeToContents()
modeltext:SetDark( 1 )
-- Description
local description = vgui.Create( "DTextEntry", frame2 ) -- create the form as a child of frame
description:SetPos( 110, 100 )
description:SetSize( 350, 15 )
description:SetText( "" )
local descriptionpanel = vgui.Create( "DPanel", frame2 )
descriptionpanel:SetPos( 25, 100 ) -- Set the position of the panel
descriptionpanel:SetSize( 75, 15 ) -- Set the size of the panel
local descriptiontext = vgui.Create( "DLabel", descriptionpanel )
descriptiontext:SetPos( 10, 0 )
descriptiontext:SetText( "Description" ) -- Set the text of the label
descriptiontext:SizeToContents()
descriptiontext:SetDark( 1 )
-- Max Players
local max = vgui.Create( "DTextEntry", frame2 ) -- create the form as a child of frame
max:SetPos( 75, 125 )
max:SetSize( 50, 15 )
max:SetText( "" )
local maxpanel = vgui.Create( "DPanel", frame2 )
maxpanel:SetPos( 25, 125 ) -- Set the position of the panel
maxpanel:SetSize( 50, 15 ) -- Set the size of the panel
local maxtext = vgui.Create( "DLabel", maxpanel )
maxtext:SetPos( 10, 0 )
maxtext:SetText( "Max" ) -- Set the text of the label
maxtext:SizeToContents()
maxtext:SetDark( 1 )
-- Must be voted for option
local vote = vgui.Create( "DCheckBox", frame2 )// Create the checkbox
vote:SetPos( 25, 225 )// Set the position
vote:SetValue( 0 )// Initial value ( will determine whether the box is ticked too )
local votepanel = vgui.Create( "DPanel", frame2 )
votepanel:SetPos( 50, 225 ) -- Set the position of the panel
votepanel:SetSize( 300, 15 ) -- Set the size of the panel
local votetext = vgui.Create( "DLabel", votepanel )
votetext:SetPos( 10, 0 )
votetext:SetText( "Tick to make the job vote only (like police)" ) -- Set the text of the label
votetext:SizeToContents()
votetext:SetDark( 1 )
-- Weapons
local weapon = vgui.Create( "DTextEntry", frame2 ) -- create the form as a child of frame
weapon:SetPos( 100, 150 )
weapon:SetSize( 360, 15 )
weapon:SetText( "like this: weapon_shotgun, weapon_crossbow, weapon_bugbait" )
local weaponpanel = vgui.Create( "DPanel", frame2 )
weaponpanel:SetPos( 25, 150 ) -- Set the position of the panel
weaponpanel:SetSize( 75, 15 ) -- Set the size of the panel
local weapontext = vgui.Create( "DLabel", weaponpanel )
weapontext:SetPos( 10, 0 )
weapontext:SetText( "Weapons" ) -- Set the text of the label
weapontext:SizeToContents()
weapontext:SetDark( 1 )
-- Salary
local salary = vgui.Create( "DTextEntry", frame2 ) -- create the form as a child of frame
salary:SetPos( 100, 175 )
salary:SetSize( 50, 15 )
salary:SetText( "" )
local salarypanel = vgui.Create( "DPanel", frame2 )
salarypanel:SetPos( 25, 175 ) -- Set the position of the panel
salarypanel:SetSize( 75, 15 ) -- Set the size of the panel
local salarytext = vgui.Create( "DLabel", salarypanel )
salarytext:SetPos( 10, 0 )
salarytext:SetText( "Salary" ) -- Set the text of the label
salarytext:SizeToContents()
salarytext:SetDark( 1 )
-- Category
local category = vgui.Create( "DTextEntry", frame2 ) -- create the form as a child of frame
category:SetPos( 100, 200 )
category:SetSize( 360, 15 )
category:SetText( "Category name aka Citizens, Civil Protection" )
local categorypanel = vgui.Create( "DPanel", frame2 )
categorypanel:SetPos( 25, 200 ) -- Set the position of the panel
categorypanel:SetSize( 75, 15 ) -- Set the size of the panel
local categorytext = vgui.Create( "DLabel", categorypanel )
categorytext:SetPos( 10, 0 )
categorytext:SetText( "Category" ) -- Set the text of the label
categorytext:SizeToContents()
categorytext:SetDark( 1 )
-- admin
local admin = vgui.Create( "DTextEntry", frame2 ) -- create the form as a child of frame
admin:SetPos( 100, 250 )
admin:SetSize( 360, 15 )
admin:SetText( "0 = Access for all, 1 = Admin and over, 2 = Superadmin and over" )
local adminpanel = vgui.Create( "DPanel", frame2 )
adminpanel:SetPos( 25, 250 ) -- Set the position of the panel
adminpanel:SetSize( 75, 15 ) -- Set the size of the panel
local admintext = vgui.Create( "DLabel", adminpanel )
[QUOTE=jacobcooper18;51397226]-snip-[/QUOTE]
[quote]
Just it only sends to players files.
[/quote]
Well of course. You are just having the server open the panel when the client types in something in chat. Which is why this part works. If you want the changes the client makes to be changed on the server then you need to use more net messages to indicate that, i'm confused as to how this doesn't make sense?
[QUOTE=Keosan;51397596]Well of course. You are just having the server open the panel when the client types in something in chat. Which is why this part works. If you want the changes the client makes to be changed on the server then you need to use more net messages to indicate that, i'm confused as to how this doesn't make sense?[/QUOTE]
I know, I tried running COnsole Commands it works but errors when I try to use tostring or table.tostring for vgui elements like name:GetValue() GetValue() errors with console commands..
[QUOTE=jacobcooper18;51397866]I know, I tried running COnsole Commands it works but errors when I try to use tostring or table.tostring for vgui elements like name:GetValue() GetValue() errors with console commands..[/QUOTE]
You could try writing those changes to a table(clientside) then sending to server and reading AND writing that table to the correct file.(serverside)
[QUOTE=Keosan;51397893]You could try writing those changes to a table(clientside) then sending to server and reading AND writing that table to the correct file.(serverside)[/QUOTE]
I have, but how would I use net.ReadTable? because I have it setup, perfectly now. Just I do this:
[CODE]function GotTable()
for k,v in pairs( net.ReadTable() ) do
file.CreateDir( "the-creator-logs/jobs/"..v.name )
file.Write( "the-creator-logs/jobs/"..v.name.."/color.txt", v.color )
file.Write( "the-creator-logs/jobs/"..v.name.."/model.txt", v.model )
file.Write( "the-creator-logs/jobs/"..v.name.."/description.txt", v.description )
file.Write( "the-creator-logs/jobs/"..v.name.."/weapon.txt", v.salary )
file.Write( "the-creator-logs/jobs/"..v.name.."/category.txt", v.category )
file.Write( "the-creator-logs/jobs/"..v.name.."/max.txt", v.max )
file.Write( "the-creator-logs/jobs/"..v.name.."/admin.txt", v.admin )
file.Write( "the-creator-logs/jobs/"..v.name.."/vote.txt", v.vote )
file.Write( "the-creator-logs/jobs/"..v.name.."/license.txt", v.license )
file.Write( "the-creator-logs/jobs/"..v.name.."/demote.txt", v.demote )
file.Write( "the-creator-logs/jobs/"..v.name.."/vip.txt", v.vip )
file.Write( "the-creator-logs/jobs/"..v.name.."/medic.txt", v.medic )
file.Write( "the-creator-logs/jobs/"..v.name.."/chief.txt", v.chief )
file.Write( "the-creator-logs/jobs/"..v.name.."/cook.txt", v.cook )
file.Write( "the-creator-logs/jobs/"..v.name.."/mayor.txt", v.mayor )
file.Write( "the-creator-logs/jobs/"..v.name.."/weapons.txt", v.weapon )
file.Write( "the-creator-logs/jobs/"..v.name.."/hobo.txt", v.hobo )
end
end
net.Receive( "CreateJob", GotTable )[/CODE]
Sorry, you need to Log In to post a reply to this thread.