Chat command for money balance?
Wait, your amendments have worked Livaco.
Thank you so much for all your help guys. You two are legends
It is a easy thing. I did not understand you at the beginning, so I choosed OnPlayerCha to process this on the cleint, not the server t. In your case, as Livaco said, PlayerSay is better in this case. His code is alright, except the two things I mentioned above, here is a fixed version:
hook.Add("PlayerSay", "ohmygoodnessgraciousisthatlivacodoingsomethingforonce", function(ply, text)
-- Check if it's our command or not. If not, stop.
if(!string.StartWith(text, "/balance")) then return end
-- Get the balance and store it in a hook to prevent multiple getDarkRPVar calls.
local bal = ply:getDarkRPVar("money")
-- Loop through every entity within x radius. Change this value to what you want.
for k,v in ipairs(ents.FindInSphere(ply:GetPos(), 500)) do
if !v:IsPlayer() then continue end
-- Send a message with the player's balance.
v:ChatPrint(ply:Name() .. " has a balance of $" .. bal .. ".")
end
end)
For formatting the balance use formatmoney instead, it will include commas in the string as well as adding the currency formatting: