Setmoney Command?

Ok, I already have a money system setup and everything. I just need an example of a ‘setmoney’ command. Thanks!

/setmoney USER AMOUNT ??
Isn’t that good enough?

Show your money commands, such as AddMoney, SetMoney, TakeMoney, just show what you have and it shouldn’t be hard to make a concommand or chat command.

Current system

local meta = FindMetaTable("Player") 
function meta:AddMoney(amount)
	local current_cash = self:GetMoney()
	self:SetMoney(current_cash + amount)
function meta:SetMoney(amount)
	self:SetNetworkedInt("Money", amount)
function meta:SaveMoney()
	local cash = self:GetMoney()
	self:SetPData("money", cash)
function meta:SaveMoneyTXT()
	file.Write(gmod.GetGamemode().Name .."/Money/".. string.gsub(self:SteamID(), ":", "_") ..".txt", self:GetMoneyString())
function meta:TakeMoney(amount)
   --Add money function here
function meta:GetMoney()
	return self:GetNetworkedInt("Money")

Don’t use NW anything dude it’ll become quite laggy throughout times. Use something like this:

Then it would just be:
concommand.Add(“set_money”, function(ply,cmd,args)
local amt = tonumber(args[1])
if !IsValid(ply) or !amt then return end

This is why you shouldn’t use NW anything:

No, dammit, why!

How do I contact Maruits to get some of my old tutorials stripped, some of them are pretty shite, old and outdated. Anybody have his steam id?

At least you contributed!

KillerLUA you helped through a couple things, thank you. And Brandon thank you!

Ok this command doesn’t work. It doesn’t say invalid command, it just doesn’t do anything.

Show your code.

What gamemode are you planning on needing this command for?

Leo why the fuck did you just post on every single forum for Garry’s mod?

Ok guys I want know how I could add the player argument to a command like this:

concommand.Add("bw_addmoney", function(ply, cmd, args)
	local amount = tonumber(args[1])

I’m kinda new to commands to I’m clueless as of now. Also, how would I make this command “superadmin” or “admin” team only? Something like?:

if ply:Team() == 3

Thanks guys.

Question, if your not suppose to use NetworkVars would it be more efficent to use PData or Usermessages? Because I know Usermessages are used in NetworkVars

Use none.

Use the all new super easy net library.
So efficient and the amount of data you can pack it with easily.

You have to check it there is a first argument in the console command or else if you try and use it AddMoney will try and give the player a nil value of money that will spit them an error.

concommand.Add("bw_addmoney", function(ply, cmd, args)
	local amount = tonumber(args[1])
	if !amount then return end
	if !ply:IsSuperAdmin() then return end