cl_init.lua :
[code]
local submit = vgui.Create("DButton", bg)
submit:SetSize(bg:GetWide()-20, 50)
submit:SetPos(10, 325)
submit:SetText("Submit")
submit.DoClick = function()
net.Start("CreateLicenseInfo")
net.WriteString(LocalPlayer():SteamID())
net.WriteString(add:GetValue())
net.WriteString(city:GetValue())
net.WriteString(state:GetValue())
net.WriteString(EyeColorOption)
net.WriteString(HairColorOption)
net.WriteString(SexOption)
net.WriteString(Weight:GetValue())
net.WriteString(Height:GetValue())
net.WriteString(DonorOption)
net.SendToServer()
end
[/code]
init.lua
[code]
net.Receive("CreateLicenseInfo", CreateInfo)
function CreateInfo()
sql.Query("INSERT into license_info3 ( player, address, city, state, eyecolor, haircolor, sex, weight, height, donor) VALUES ( "..net.ReadString()..", "..net.ReadString()..", "..net.ReadString()..", "..net.ReadString()..", "..net.ReadString()..", "..net.ReadString()..", "..net.ReadString()..", "..net.ReadString()..", "..net.ReadString()..", "..net.ReadString().." );")
print("MESSAGE RECIEVED")
end
[/code]
When you click the button, it does send the message to the server, but it doesn't appear to be saving. The first net.ReadString() that is read is the players SteamID since you can't use arguments in a net.Receive function. Also, I'm running this on singleplayer if that has anything to do with it. Is there a better way to send the info from the client to the server? I tried using RunConsoleCommand with the values as arguments but it returned a bunch of nil values.. If anyone could help, that would be great. Thanks.
First of all you should be doing the serverside function:
[lua]
net.Receive("CreateLicenseInfo", function(len, client)
-- Code. The "client" argument is the player who sends the message to the server.
end)
[/lua]
-snip-
Ok I'll try that.
EDIT: Did what you said and it still isn't working.
Sorry, you need to Log In to post a reply to this thread.