No errors are produced when running this program, but the server does not recieve the written string fully. Running this program just prints "nil" serverside. On the client "Sending...Soldier" is successfully printed. "Soldier" should be printed serverside, but nothing happens. In the actual mod this is what is happening to clients that ask for the server to send them a copy of a class based on name, but "nil" is recieved from the client so it doesn't work. I don't understand why - looking that the wiki I keep checking and I am trying my hardest to make sure it conforms exactly to how the tutorials put it.
Clientside:
function RequestClass(ClassName)
net.Start("ClassRequest")
net.WriteString(ClassName)
print("Sending..."..ClassName)
net.SendToServer()
end
RequestClass("Soldier")
Serverside:
function SendClass()
local Class = net.ReadString()
print(Class)
end
net.Receive("ClassRequest", SendClass())
At the top of the server-side code there is an add network string.
util.AddNetworkString("ClassRequest")
When you net.receive you dont need () and the end of sendclass
net.Receive("ClassRequest", SendClass) <--- like this
Removing "()" from SendClass did the trick. Huge thanks!
I'm surprised that didn't give you any errors.. that's a syntax issue
The function ran, and returned nil.
The nil is then passed into net.Receive. No syntax errors because that is valid syntax in Lua.
Sorry, you need to Log In to post a reply to this thread.