When trying to run my script i keep getting this error:
[ERROR] addons/moneymanagement/lua/autorun/derma.init.lua:7: attempt to index a string value with bad
key ('addMoney' is not part of the string library)
1. error - [C]:-1
2. __index - lua/includes/extensions/string.lua:297
3. func - addons/moneymanagement/lua/autorun/derma.init.lua:7
4. unknown - lua/includes/extensions/net.lua:32
Server side:
util.AddNetworkString("add_money")
net.Receive("add_money", function()
local currentplayer = net.ReadString()
local moneyamount = net.ReadUInt(24)
currentplayer:addMoney(moneyamount)
end)
Client side:
--add_money
addbutton = vgui.Create("DButton", f)
addbutton:Center()
addbutton:SetText("Add Money")
addbutton:SetSize(220, 80)
addbutton:SetPos(450, 65)
function addbutton:DoClick()
--Include net function here
--https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index1b73.html
print("Sent playername " .. SelectedPlayer .. " and amount " .. input:GetValue() .. " to server") --debug
print(SelectedPlayer) --debug
net.Start("add_money")
net.WriteString(SelectedPlayer)
net.WriteUInt(input:GetValue(), 24)
net.SendToServer()
-- Still need to add server side net
-- Remember to define
end
If you're confused as to where some integers are coming from it's from other parts of the script. Though i've already tested whether they work. Simply need some help with the networking.
Thanks in advance!