Here’s what I have :
[release]autorun/money.lua[/release]
[lua]AddCSLuaFile(“autorun/client/cl_money.lua”)
local Meta = FindMetaTable(“Player”)
function Meta:Money(money)
return self:GetNWInt(“Money”)
end
function Meta:SetMoney(money)
self:SetPData(“Money”, money)
self:SetNWInt(“Money”, money)
end
function Meta:CanAfford(cost)
return (self:Money() - cost) >= 0
end
hook.Add(“PlayerInitialSpawn”,“DataRetrieving”, function(ply)
if !ply:GetPData(“Money”) then ply:SetPData(“Money”,0) end
ply:SetNWInt(“Money”, ply:GetPData(“Money”) )
end)
function ChangeMoney(ply,cmd,args)
local target, amount = FindPlayer(args[1]),tonumber(args[2])
if !ply:IsSuperAdmin() then ply:ChatPrint(“You don’t have access to that command!”) end
if !target then ply:ChatPrint(“No player found with a matching name!”) end
if amount < 0 then ply:ChatPrint(“You can’t use a negative number!”) end
target:SetMoney(amount)
end
concommand.Add(“setmoney”,ChangeMoney)
function GiveMoney(ply,cmd,args)
local target = ply:GetEyeTrace().Entity
if !target:IsPlayer() or !ply:CanAfford(args[1]) then return end
target:SetMoney(target:Money() + args[1])
ply:SetMoney(ply:Money() - args[1])
target:ChatPrint("Received "..tostring(args[1]).."$ from "..ply:Nick().."!")
ply:ChatPrint("Gave "..tostring(args[1]).."$ to "..target:Nick().."!")
end
concommand.Add(“givemoney”,GiveMoney)
function FindPlayer(info)
local players = player.GetAll()
for k, v in pairs(players) do
if string.find(string.lower(v:Nick()), string.lower(tostring(info))) ~= nil then
return v
end
end
return nil
end[/lua]
[release]autorun/client/cl_money.lua[/release]
[lua]local Meta = FindMetaTable(“Player”)
function Meta:Money(money)
return self:GetNWInt(“Money”)
end
hook.Add(“HUDPaint”,“DrawMoney”,function()
draw.RoundedBox( 2, 25, ScrH() - 100, 130, 23, Color( 128, 255, 128, 255 ) )
draw.DrawText("Money: "…LocalPlayer():Money(), “ScoreboardText”, 30, ScrH() - 97, Color(255,255,255,255),0)
end)
[/lua]
It’s pretty basic, not really done. Might have bugs too. Right now it uses only console commands so if you want chat commands you’ll have to make them yourself. Sorry that it isn’t commented, hope this helps! 