I have one question that I couldn’t find an explanation with the search button, i think i’m not the only one asking:
What is the difference between making some money system clientside, serverside, shared?
For example here is a bit of code: (simple money system)
function cnr_getmoney(ply) return ply:GetNWInt("money") end function cnr_setmoney(ply,amount) ply:SetNWInt("money",amount) cnr_saveply(ply) -- Sql save end function cnr_addmoney(ply,amount) if amount > 0 then cnr_setmoney(ply,cnr_getmoney(ply) + amount) else cnr_error(ply,"amount invalid") -- ply:ChatPrint the error to the player end end function cnr_pay(giver,receiver,amount) if cnr_getmoney(giver) >= amount then cnr_rmvmoney(giver,amount) -- cnr_rmvmoney is the same as cnr_addmoney cnr_addmoney(receiver,amount) else cnr_error(giver,"not enough money") end end concommand.Add("givemoney", cnr_ply_pay) function cnr_firsttime(ply) cnr_setmoney(ply,money_start) end
Why should some function be run only by server, player or shared? Which one? And why?
My cnr_error should be clientside, but if it is in serverside code how does it work?
Should I better use ply:SetPData? What is the difference between NWInt and PData?