Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function isPlayer(ply)
- return (IsValid(ply) and ply:IsPlayer())
- end
- function SWRP:GetMoney(ply)
- return ply:GetPData("money", 0)
- end
- if SERVER then
- function SWRP:InitMoney(ply)
- end
- for k, v in next, player.GetAll() do
- SWRP:InitMoney(v)
- end
- function SWRP:SaveMoney(ply, amount)
- local players = player.GetAll()
- for k, v in pairs(players) do
- local amount = v:GetPData("money", -1 )
- end
- end
- function SWRP:LoadMoney(ply)
- self:InitMoney(ply)
- if not IsValid(ply) then return end
- local players = player.GetAll()
- for k, v in pairs(players) do
- v:GetPData("money", 0)
- end
- ply:SetNWString("money", v:GetPData("money", -1))
- end
- end
- function SWRP:SetMoney(ply, amount)
- local amount = (amount)
- if not isnumber(amount) or amount < 0 then amount = (SWRP.Config.StartMoney) end
- if amount ~= amount then amount = (SWRP.Config.StartMoney) end
- amount = math.Round(amount)
- ply:SetPData("money", amount )
- ply:SetNWString("money", amount)
- end
- function SWRP:GiveMoney(ply, amount)
- self:SetMoney(ply, self:GetMoney(ply) + amount)
- end
- function SWRP:TakeMoney(ply, amount)
- self:SetMoney(ply, self:GetMoney(ply) - amount)
- end
- function SWRP:TransferMoney(ply1, amount, ply2)
- self:TakeMoney(ply1, amount)
- self:GiveMoney(ply2, amount)
- end
- --hook.Add("GetPData", "money", SWRP:LoadMoney(ply))
- --hook.Add("PlayerDisconnected","SaveMoney", SWRP:SaveMoney(ply, amount))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement