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.
local meta = FindMetaTable("Player") function meta:AddMoney(amount) local current_cash = self:GetMoney() self:SetMoney(current_cash + amount) end function meta:SetMoney(amount) self:SetNetworkedInt("Money", amount) self:SaveMoney() end function meta:SaveMoney() local cash = self:GetMoney() self:SetPData("money", cash) end function meta:SaveMoneyTXT() file.Write(gmod.GetGamemode().Name .."/Money/".. string.gsub(self:SteamID(), ":", "_") ..".txt", self:GetMoneyString()) end function meta:TakeMoney(amount) --Add money function here self:AddMoney(-amount) end function meta:GetMoney() return self:GetNetworkedInt("Money") end
Don’t use NW anything dude it’ll become quite laggy throughout times. Use something like this:
Then it would just be:
local amt = tonumber(args)
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) ply:AddMoney(amount) end)
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
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 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) if !amount then return end if !ply:IsSuperAdmin() then return end ply:AddMoney(amount) end)