When I just open the file trough lua_openscript_cl it works fine however when I make it autorun on server start I get this error spammed in console:
[CODE]
[ERROR] lua/handsignals.lua:102: attempt to index global 'input' (a nil value)
1. v - lua/handsignals.lua:102
2. unknown - lua/includes/modules/hook.lua:84
[/CODE]
This is the code the uses it:
[CODE]
hook.Add("Think", "MenuKeyListener", function()
if (input.IsButtonDown(KEY_G) and !keyDown) then
ActMenu()
end
keyDown = input.IsButtonDown(KEY_G)
end);[/CODE]
Derma and input are both client-side. [URL="https://facepunch.com/showthread.php?t=1540243"]You didn't need to make a new thread either.[/URL]
The input library doesn't exist on the server. If you want to do something with keys per-player serverside, do it in a StartCommand hook with the Player.KeyDown function.
[QUOTE=code_gs;51301222]The input library doesn't exist on the server. If you want to do something with keys per-player serverside, do it in a StartCommand hook with the Player.KeyDown function.[/QUOTE]
But Player.KeyDown uses IN Enumerations wich doesn't contain all they keyboard keys instead only already set keys by GMOD. But I must be able to use the exact same code? HUDs are clientsided and they work? I just want it so that whenever a person on the server presses that key it will open the menu, and that the menu is toggleable so that if it's open and you press the key again it closes. It works just that not when I make it autorun
[editline]3rd November 2016[/editline]
How do I have this on a server but still call it clientsided
[QUOTE=Flaow;51301308]How do I have this on a server but still call it clientsided[/QUOTE]
Use [url=http://wiki.garrysmod.com/page/Category:net]net[/url] and send data from client to server?
[QUOTE=Flaow;51301308]But Player.KeyDown uses IN Enumerations wich doesn't contain all they keyboard keys instead only already set keys by GMOD. But I must be able to use the exact same code? HUDs are clientsided and they work? I just want it so that whenever a person on the server presses that key it will open the menu, and that the menu is toggleable so that if it's open and you press the key again it closes. It works just that not when I make it autorun
[editline]3rd November 2016[/editline]
How do I have this on a server but still call it clientsided[/QUOTE]
Those specific keys aren't networked to the server, so you'll have to do it yourself.
[QUOTE=code_gs;51301414]Those specific keys aren't networked to the server, so you'll have to do it yourself.[/QUOTE]
What do you mean by I'll have to do it myself? What will I have to do myself?
You will have to network it yourself. Use the net library. The server only knows about IN_ key's keypresses to minimize network load. If you want to know about KEY_ keypresses serverside, you have to send it yourself.
I don't understand, what part of this code is serversided, isn't it all clientsided?
[QUOTE=Flaow;51301496]I don't understand, what part of this code is serversided, isn't it all clientsided?[/QUOTE]
Your current code is running server side, that's why you're getting this error, put it in a client side file.
[QUOTE=bigdogmat;51301554]Your current code is running server side, that's why you're getting this error, put it in a client side file.[/QUOTE]
Is that just doing cl_NAME.lua?
[QUOTE=Flaow;51301641]Is that just doing cl_NAME.lua?[/QUOTE]
If this is in lua/autorun then place it in
lua/autorun/client
it is not going to work in lua/autorun/server because it will be ran as a serverside file and like everyone else has stated it does [I][U]NOT[/U][/I] work serverside.
tl;dr put in client folder in autorun and network movement using net library to server
[QUOTE=QuackDuck;51301648]If this is in lua/autorun then place it in
lua/autorun/client
it is not going to work in lua/autorun/server because it will be ran as a serverside file and like everyone else has stated it does [I][U]NOT[/U][/I] work serverside.
tl;dr put in client folder in autorun and network movement using net library to server[/QUOTE]
OMG THANK YOU IT WORKS
Sorry, you need to Log In to post a reply to this thread.