Guest User

Untitled

a guest
May 22nd, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.39 KB | None | 0 0
  1. /*---------------------------------------------------------------------------------------
  2. Includes The Files Needed For This File To Run Correctly.
  3. ---------------------------------------------------------------------------------------*/
  4.  
  5.  
  6.  
  7.  
  8. /*---------------------------------------------------------------------------------------
  9. Gets the player's money.
  10. ---------------------------------------------------------------------------------------*/
  11.  
  12. function GetMoney(ply)
  13.     return ply:GetNWInt("Money")
  14. end
  15.  
  16. /*---------------------------------------------------------------------------------------
  17. Sets the player's money.
  18. ---------------------------------------------------------------------------------------*/
  19.  
  20. function SetMoney(ply, amount)
  21.     ply:SetNWInt("Money", amount)      
  22. end
  23.  
  24. /*---------------------------------------------------------------------------------------
  25. Adds to the player's current money.
  26. ---------------------------------------------------------------------------------------*/
  27.  
  28. function AddMoney(ply, amount)
  29. local current_money = ply:GetNWInt("Money")
  30. local mon = ply:GetNWInt("Money")
  31.     ply:SetNWInt(current_money + amount)
  32.     sql.Query("UPDATE player_data SET money = "..mon.." WHERE STEAM = "..sql.SQLStr(ply:SteamID())..";")
  33. end
  34.  
  35. /*---------------------------------------------------------------------------------------
  36. Gives the player your looking at money.
  37. ---------------------------------------------------------------------------------------*/
  38.  
  39. function GiveMoney(ply, text, public)
  40. local trace = ply:GetEyeTrace()
  41. local trace2 = ply:GetEyeTrace()
  42. local words = string.Explode(" ",text);
  43. local amount = tonumber(words[2]);
  44.    if (string.sub(text, 1, 5) == "/give") then
  45.    
  46.         if ValidEntity(trace.Entity) and trace.Entity:IsPlayer() and trace.Entity:GetPos():Distance(ply:GetPos()) < 150 then
  47.    
  48.         AddMoney( ply, -1 * amount )
  49.         AddMoney( trace.Entity, amount )
  50.    
  51.         ply:ChatPrint("You gave xxx player some money!")
  52.  
  53.    
  54.         end
  55.    end
  56. end
  57. hook.Add("PlayerSay", "/give", GiveMoney)
  58.  
  59. /*---------------------------------------------------------------------------------------
  60. Saves the player's money.
  61. ---------------------------------------------------------------------------------------*/
  62.  
  63. function SaveMoney(ply)
  64. local mon = ply:GetNWInt("Money")
  65.     sql.Query("UPDATE player_data SET money = "..mon.." WHERE STEAM = "..sql.SQLStr(ply:SteamID())..";")      
  66. end
Add Comment
Please, Sign In to add comment