So, I have made a 3D2D button which is great! (This is in cl_init.lua). I have also used the Net library to be able to run a function in the init.lua from the cl_init.lua button which is great! The cl_init.lua looks like this:
if (player:KeyDown(IN_USE)) then net.Start("Collect") net.SendToServer() --Below will change the color of the button when it is pressed surface.SetDrawColor(0, 0, 0, 240) end
So this what happens when the button is pressed, it then goes over to init.lua which is:
function collectBtn() self:addMoney(300); end net.Receive("Collect", collectBtn)
NOTE: I know the function works because I can do a print(“test”) and I can see it in console. So, how would I go about adding money to the player?
This “self:addMoney()” does not work, is this because it is client side. I have been told I can achieve what I am trying to do with net.WiteEntity however I am not sure how to use it?
Normally, I would of used:
function ENT:Use(activator) if(activator:IsPlayer()) then activator:addMoney(300); end end
This will give the player $300 when they press E on the printer. But obviously I have the button now.
Thanks in advance!