So I'm 100% I'm stupid, but I'm using the Net Library, and when I test my code on my source server it works fine, but when I go and run it on a hosted server, it doesn't work.
(Clientside )
LoansSend.DoClick = function()
local x = tonumber(Amount:GetValue())
local y = tonumber(Interest:GetValue())
local z = tonumber(Period:GetValue())
if x and y and z and x <= MaxMoney and y <= MaxInterest and z <= MaxTime then
net.Start("EditTable")
net.WriteInt(1, 4)
net.WriteInt(0, 4)
net.WriteTable({ ply, x, y, z })
net.WriteBool(false)
net.SendToServer()
print("Sending")
Amount:SetValue("")
Interest:SetValue("")
Period:SetValue("")
end
end
(Serverside)
util.AddNetworkString("EditTable")
hook.Add('Think', "ThisBeTheUniqueID", function()
net.Receive("EditTable", function(len, ply)
local cur = net.ReadInt(4)
local index = net.ReadInt(4)
local newTable = net.ReadTable()
local remove = net.ReadBool()
ply:PrintMessage(HUD_PRINTTALK, "You sent stuff")
if cur == 1 then
ply:PrintMessage(HUD_PRINTTALK, "Your stuff sent")
editTable(BankerRequestedLoans, index, newTable, remove)
elseif cur == 2 then
editTable(RequestedLoans, index, newTable, remove)
elseif cur == 3 then
editTable(AcceptedLoans, index, newTable, remove)
elseif cur == 4 then
editTable(PaidMoney, index, newTable, remove)
end
end)
end)
I've confirmed that on the hosted server, that the code in the DoClick executes but the code serverside doesn't at all.
Hello
If the code isn't running at all :
Did you put your server lua script in this folder like this ?
Addonsname/lua/autorun/server/YourScript.lua
hook.Add('Think', "ThisBeTheUniqueID", function()
net.Receive("EditTable", function(len, ply)
end)
end)
I could try to explain why this isn't logical, but I'll paste this message that is very tough to miss which can be found in the wiki section of the Receive function:
https://i.gyazo.com/4d743257c0d76fb090f08ecb41cb36f1.png
Source: net.Receive
You're writing 2 ints but only reading one.
Sorry, you need to Log In to post a reply to this thread.