Guest User

Moneycommand

a guest
Apr 12th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. CATEGORY_NAME = "Money"
  2. -- Coded by syst3M4TiK; Director of RVNsoftware & Head of ProUnpro
  3. -- http://steamcommunity.com/id/Officialsyst3M4TiK
  4. -- Visit us at http://unpro.rvnsoftware.cf !
  5. -- WARNING: This will ONLY work on DarkRP. Any damage done to your server for not following this warning is your own doing.
  6.  
  7. -- The 'Give Money' function. Use the format below (without <>) to give (x) money to the target player.
  8. //!givemoney <name> <amount>
  9. function ulx.givemoney( calling_ply, target_ply, money )
  10.  
  11. target_ply:addMoney(money)
  12. ulx.fancyLogAdmin( calling_ply, "#A gave $#i to #T", money, target_ply) -- Change "$" to whatever currency you want to use.
  13.  
  14. end
  15.  
  16. local givemoney = ulx.command( CATEGORY_NAME, "ulx givemoney", ulx.givemoney, "!givemoney" )
  17. givemoney:defaultAccess( ULib.ACCESS_SUPERADMIN )
  18. givemoney:addParam{ type=ULib.cmds.PlayerArg }
  19. givemoney:addParam{ type=ULib.cmds.NumArg, min=0, default=1000, hint="give how much?", ULib.cmds.optional, ULib.cmds.round }
  20. givemoney:help( "Give players the chosen amount of cash" )
  21.  
  22.  
  23. -- The 'Take Money' function. Use the format below (without <>) to take away (x) money from the target player.
  24. //!takemoney <name> <amount>
  25. function ulx.takemoney( calling_ply, target_ply, money )
  26.  
  27. target_ply:addMoney(-money)
  28. ulx.fancyLogAdmin( calling_ply, "#A took $#i from #T", money, target_ply) -- Change "$" to whatever currency you want to use.
  29.  
  30. end
  31.  
  32. local takemoney = ulx.command( CATEGORY_NAME, "ulx takemoney", ulx.takemoney, "!takemoney" )
  33. takemoney:defaultAccess( ULib.ACCESS_SUPERADMIN )
  34. takemoney:addParam{ type=ULib.cmds.PlayerArg }
  35. takemoney:addParam{ type=ULib.cmds.NumArg, min=0, default=1000, hint="take how much?", ULib.cmds.optional, ULib.cmds.round }
  36. takemoney:help( "Take away the chosen amount of cash from players" )
  37.  
  38. -- The 'Set Money' function. Use the format below (without <>) to set the target player's money to (x).
  39. //!setmoney <name> <amount>
  40.  
  41. function ulx.setmoney( calling_ply, target_ply, amount )
  42.  
  43. target_ply:setDarkRPVar("money", amount)
  44. ulx.fancyLogAdmin( calling_ply, "#A set #T's money to $#i", money, target_ply) -- Change "$" to whatever currency you want to use.
  45.  
  46. end
  47. local setmoney = ulx.command( CATEGORY_NAME, "ulx setmoney", ulx.setmoney, "!setmoney" )
  48. setmoney:defaultAccess( ULib.ACCESS_SUPERADMIN )
  49. setmoney:addParam{ type=ULib.cmds.PlayerArg }
  50. setmoney:addParam{ type=ULib.cmds.NumArg, min=0, default=1000, hint="set to what?", ULib.cmds.optional, ULib.cmds.round }
  51. setmoney:help( "Set the money of the target" )
  52.  
  53. -- The 'Get Money' function. Use the format below (without <>) to get the player's current wallet amount.
  54. -- Submitted by XxLMM13xXgaming; edited by syst3M4TiK
  55. //!getmoney <player>
  56. function ulx.getmoney( calling_ply, target_ply )
  57.  
  58. -- This function will make it so 10000 will be 10,000
  59. local function formatNumber(n)
  60. if not n then return "" end
  61.  
  62. if n >= 1e14 then return tostring(n) end
  63.  
  64. n = tostring(n)
  65. local sep = sep or ","
  66. local dp = string.find(n, "%.") or #n+1
  67. for i=dp-4, 1, -3 do
  68. n = n:sub(1, i) .. sep .. n:sub(i+1)
  69. end
  70. return n
  71.  
  72. end
  73.  
  74. local plymoney = formatNumber(target_ply:getDarkRPVar("money") or 0)
  75. ULib.tsayError( calling_ply, "This player currently has $"..plymoney, true )
  76.  
  77. end
  78. local getmoney = ulx.command( CATEGORY_NAME, "ulx getmoney", ulx.getmoney, "!getmoney", true )
  79. getmoney:addParam{ type=ULib.cmds.PlayerArg }
  80. getmoney:defaultAccess( ULib.ACCESS_ADMIN )
  81. getmoney:help( "Prints the players money in chat." )
Add Comment
Please, Sign In to add comment