Advertisement
Guest User

sadasd

a guest
Dec 12th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. local function isPlayer(ply)
  2.  
  3. return (IsValid(ply) and ply:IsPlayer())
  4.  
  5. end
  6.  
  7. function SWRP:GetMoney(ply)
  8.  
  9. return ply:GetPData("money", 0)
  10.  
  11. end
  12.  
  13. if SERVER then
  14.  
  15. function SWRP:InitMoney(ply)
  16.  
  17. end
  18.  
  19. for k, v in next, player.GetAll() do
  20.  
  21. SWRP:InitMoney(v)
  22.  
  23. end
  24.  
  25. function SWRP:SaveMoney(ply, amount)
  26. local players = player.GetAll()
  27.  
  28. for k, v in pairs(players) do
  29.  
  30. local amount = v:GetPData("money", -1 )
  31.  
  32. end
  33. end
  34.  
  35. function SWRP:LoadMoney(ply)
  36.  
  37. self:InitMoney(ply)
  38. if not IsValid(ply) then return end
  39.  
  40. local players = player.GetAll()
  41.  
  42. for k, v in pairs(players) do
  43. v:GetPData("money", 0)
  44. end
  45.  
  46. ply:SetNWString("money", v:GetPData("money", -1))
  47. end
  48.  
  49. end
  50.  
  51. function SWRP:SetMoney(ply, amount)
  52. local amount = (amount)
  53.  
  54. if not isnumber(amount) or amount < 0 then amount = (SWRP.Config.StartMoney) end
  55. if amount ~= amount then amount = (SWRP.Config.StartMoney) end
  56.  
  57. amount = math.Round(amount)
  58. ply:SetPData("money", amount )
  59.  
  60. ply:SetNWString("money", amount)
  61.  
  62. end
  63.  
  64.  
  65. function SWRP:GiveMoney(ply, amount)
  66.  
  67. self:SetMoney(ply, self:GetMoney(ply) + amount)
  68.  
  69. end
  70.  
  71. function SWRP:TakeMoney(ply, amount)
  72.  
  73. self:SetMoney(ply, self:GetMoney(ply) - amount)
  74.  
  75. end
  76.  
  77. function SWRP:TransferMoney(ply1, amount, ply2)
  78.  
  79. self:TakeMoney(ply1, amount)
  80. self:GiveMoney(ply2, amount)
  81.  
  82. end
  83.  
  84. --hook.Add("GetPData", "money", SWRP:LoadMoney(ply))
  85. --hook.Add("PlayerDisconnected","SaveMoney", SWRP:SaveMoney(ply, amount))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement