I can't found any solution to this, someone can help me please?
[QUOTE]
[ERROR] lua/test/autorun/server/sv_test.lua:2: attempt to call field 'AddNetworkString' (a nil value)
1. unknown - lua/test/autorun/server/sv_test.lua:2
[/QUOTE]
[CODE]
util.AddNetworkString("send_info_to_server")
net.Receive("send_info_to_server", function()
local name = net.ReadString()
RunConsoleCommand("say","adduser",name)
end)
[/CODE]
You have to send info with net.Start.
Where are you getting that error?
[QUOTE=Skere_;49275701]You have to send info with net.Start.[/QUOTE]
Client side code:
local SetButton = vgui.Create( "DButton", PlayerList )
SetButton:SetPos( PlayerList:GetWide()/2-50,PlayerList:GetTall()/2+125 )
SetButton:SetSize( 100, 50 )
SetButton:SetTextColor( Color( 0, 255, 0 ) )
SetButton:SetText( "Submit" )
SetButton:SetFont( "Buttons_Text" )
SetButton.Paint = function()
draw.RoundedBox( 0, 0, 0, PlayerList:GetWide(), PlayerList:GetTall(), Color( 42, 42, 42 ) )
end
SetButton.DoClick = function()
net.Start( "send_info_to_server" )
net.WriteString( PlayerName,PlayerRank )
net.SendToServer()
end
SetButton.OnCursorEntered = function( self )
self.hover = true
self:SetTextColor( Color(100, 255, 255) )
end
SetButton.OnCursorExited = function( self )
self.hover = false
self:SetTextColor( Color(0, 255, 0) )
end
[editline]9th December 2015[/editline]
[QUOTE=Coffeee;49275725]Where are you getting that error?[/QUOTE]
I get that error when i run the script
But where? What console? Because there's nothing wrong in the code as far as I can see
[QUOTE=Coffeee;49275824]But where? What console? Because there's nothing wrong in the code as far as I can see[/QUOTE]
Im running it on the console, theres the logs:
[QUOTE]] lua_openscript test/autorun/server/sv_test.lua
Running script test/autorun/server/sv_test.lua...
] lua_openscript test/autorun/client/cl_test.lua
Running script test/autorun/client/cl_test.lua...
] test1
[ERROR] lua/test/autorun/client/cl_test.lua:85: Calling net.Start with unpooled message name! [[url]http://goo.gl/qcx0y][/url]
1. Start - [C]:-1
2. DoClick - lua/test/autorun/client/cl_test.lua:85
3. unknown - lua/vgui/dlabel.lua:218
[lRoberth™ (Doing jobs for GMo|7|STEAM_0:0:64662999] Lua Error:
[ERROR] lua/test/autorun/client/cl_test.lua:85: Calling net.Start with unpooled message name! [[url]http://goo.gl/qcx0y][/url]
1. Start - [C]:-1
2. DoClick - lua/test/autorun/client/cl_test.lua:85
3. unknown - lua/vgui/dlabel.lua:218
[/QUOTE]
[code]] lua_openscript test/autorun/server/sv_test.lua
Running script test/autorun/server/sv_test.lua...
] lua_openscript test/autorun/client/cl_test.lua
Running script test/autorun/client/cl_test.lua...[/code]
You must be opening serverside scripts with lua_openscript and clientside with lua_openscript_cl.
I'd recommend you just get rid of the test/ folder and have the scripts load automatically.
[QUOTE=Robotboy655;49275877][code]] lua_openscript test/autorun/server/sv_test.lua
Running script test/autorun/server/sv_test.lua...
] lua_openscript test/autorun/client/cl_test.lua
Running script test/autorun/client/cl_test.lua...[/code]
You must be opening serverside scripts with lua_openscript and clientside with lua_openscript_cl.
I'd recommend you just get rid of the test/ folder and have the scripts load automatically.[/QUOTE]
I'm still getting the same error
[QUOTE=lRoberth;49275961]I'm still getting the same error[/QUOTE]
Make a addon folder and do this
Addon_name/lua/autorun/autorun.lua
inside autorun.lua
[CODE]
if SERVER then
include("sv_code.lua")
AddCSLuaFile("cl_code.lua")
elseif CLIENT then
include("cl_code.lua")
end
[/CODE]
then place the files sv_code and cl_code at directory
Addon_name/lua/ HERE
[QUOTE=DiscoKnight;49276184]Make a addon folder and do this
Addon_name/lua/autorun/autorun.lua
inside autorun.lua
[CODE]
if SERVER then
include("sv_code.lua")
AddCSLuaFile("cl_code.lua")
elseif CLIENT then
include("cl_code.lua")
end
[/CODE]
then place the files sv_code and cl_code at directory
Addon_name/lua/ HERE[/QUOTE]
Starting the server i got this error:
[QUOTE][lRoberth™ (Doing jobs for GMo|2|STEAM_0:0:64662999] Lua Error:
[ERROR] addons/test/lua/autorun/sv_test.lua:2: attempt to call field 'AddNetworkString' (a nil value)
1. unknown - addons/test/lua/autorun/sv_test.lua:2
[/QUOTE]
And when i type the command to open the menu i get this error:
[QUOTE]] getrektaddon
[ERROR] addons/test/lua/autorun/cl_test.lua:6: attempt to index global 'vgui' (a nil value)
1. unknown - addons/test/lua/autorun/cl_test.lua:6
2. unknown - lua/includes/modules/concommand.lua:54
[/QUOTE]
You are running clientside code on server and serverside code on client.
[QUOTE=Robotboy655;49276330]You are running clientside code on server and serverside code on client.[/QUOTE]
This is exactly i did: i create a folder on addons/ and i called it "test", then i created another folder inside addons/test/ called lua, and again i created a new folder inside addons/test/lua/ and i called it autorun.
Inside i pasted my two .lua, sv_test.lua and cl_test.lua and i created another lua called autorun.lua and the code what is inside of it it's:
[QUOTE]if SERVER then
include("sv_test.lua")
AddCSLuaFile("cl_test.lua")
elseif CLIENT then
include("cl_test.lua")
end[/QUOTE]
Now i started it from another way, and now im just getting this error (The same as the second one)
[QUOTE][ERROR] addons/test/lua/autorun/client/cl_test.lua:85: Calling net.Start with unpooled message name! [[url]http://goo.gl/qcx0y][/url]
1. Start - [C]:-1
2. DoClick - addons/test/lua/autorun/client/cl_test.lua:85
3. unknown - lua/vgui/dlabel.lua:218
[/QUOTE]
[QUOTE][/QUOTE]
File structure should go like this
[IMG]http://i.imgur.com/NVMfmYx.png[/IMG]
[IMG]http://i.imgur.com/ty8hW4y.png[/IMG]
[IMG]http://i.imgur.com/BhIwAXC.png[/IMG]
inside autorun.lua put this
[lua]
if SERVER then
include("sv_code.lua")
AddCSLuaFile("cl_code.lua")
elseif CLIENT then
include("cl_code.lua")
end
[/lua]
[QUOTE=DiscoKnight;49276858] -snip-[/QUOTE]
Bretty good tute for newbies, save this and reuse it
Why not just do this?:
[IMG]http://puu.sh/lPruM.png[/IMG]
With the way Disco posted, since it's in the base of the autorun folder, it's just a more complicated way of doing what GMod can do on its own.
Putting them in the respective folders inside autorun automatically does what your 'autorun.lua' script is doing, and seems to be slightly more organized.
Though, if you have a larger project with many files, and specific load orders, then perhaps Disco's way is better.
[QUOTE=DiscoKnight;49276858]File structure should go like this
[IMG]http://i.imgur.com/NVMfmYx.png[/IMG]
[IMG]http://i.imgur.com/ty8hW4y.png[/IMG]
[IMG]http://i.imgur.com/BhIwAXC.png[/IMG]
inside autorun.lua put this
[lua]
if SERVER then
include("sv_code.lua")
AddCSLuaFile("cl_code.lua")
elseif CLIENT then
include("cl_code.lua")
end
[/lua][/QUOTE]
Still not working
[QUOTE=lRoberth;49276292]
[ERROR] addons/test/lua/autorun/sv_test.lua:2: attempt to call field 'AddNetworkString' (a nil value)
1. unknown - addons/test/lua/autorun/sv_test.lua:2
[/QUOTE]
util.AddNetworkString only exists on the sever .. you tried to run it on the client or something have overwritten the "util." module-table.
[QUOTE=lRoberth;49276292]
[ERROR] addons/test/lua/autorun/cl_test.lua:6: attempt to index global 'vgui' (a nil value)
1. unknown - addons/test/lua/autorun/cl_test.lua:6
2. unknown - lua/includes/modules/concommand.lua:54
[/QUOTE]
vgui only exists on the client .. you tried to run it on the server or something have overwritten the "vgui." module-table.
[QUOTE=lRoberth;49276383]
[ERROR] addons/test/lua/autorun/client/cl_test.lua:85: Calling net.Start with unpooled message name! [[url]http://goo.gl/qcx0y][/url]
1. Start - [C]:-1
2. DoClick - addons/test/lua/autorun/client/cl_test.lua:85
3. unknown - lua/vgui/dlabel.lua:218
[/QUOTE]
util.AddNetworkString have to be executed on the server before the client can send net-messages.
Try add these lines to the top of the files, to debug the problem:
sv_code.lua
[lua]
if !SERVER then
print("[sv_code] Cant run on client!")
return
else
print("[sv_code] I ran the on server :D")
end
[/lua]
cl_code.lua
[lua]
if !CLIENT then
print("[cl_code] Cant run on server!")
return
else
print("[cl_code] I ran on the client :D")
end
[/lua]
Also when puting find on autorun even if the name is cl_ or sv_ will run the files clientside and serverside.
What you should do to fix it is put them in autorun/server or autorun/client respectively
Sorry, you need to Log In to post a reply to this thread.