--@name --@author --@server do local function giveMoney(args) local target = core:get_entity(args[1]) if target == nil then return end local amount = tonumber(args[2]) if tonumber(amount) <= 0 then core:log(log.ERROR, "Amount must be a non zero number!") end if darkrp.canGiveMoney(target) then local money = owner():getMoney() target:giveMoney(amount) else core:log(log.ERROR, "Cannot give money due to a cooldown!") end end local function requestMoney(args) local target = core:get_entity(args[1]) if target == nil then return end local amount = tonumber(args[2]) if tonumber(amount) <= 0 then core:log(log.ERROR, "Amount must be a non zero number!") end if darkrp.canMakeMoneyRequest(target) then local money = owner():getMoney() target:requestMoney((#args[3] > 0 and args[3] or ""), amount, function() --Success if owner():getMoney() + amount >= money then core:log(log.INFO, "Successfully received "..darkrp.formatMoney(amount).." from "..target:getName().."!") else -- This probably won't happen here core:log(log.ERROR, "An unknown error occured! Transaction status is unknown.") end end, function() --Failure core:log(log.ERROR, "Money request to "..target:getName().." failed!") end ) core:log(log.INFO, "Requested "..darkrp.formatMoney(amount).." from "..target:getName()..".") else core:log(log.ERROR, "Cannot request money due to a cooldown!") end end core.modules.darkrp = { version = 1, desc = "Provides useful commands for DarkRP servers.", commands = { givemoney = { usage = "givemoney ", desc = "Gives away money to .", func = giveMoney, }, requestmoney = { usage = "requestmoney [message]", desc = "Kindly asks for . Can include an optional message.", func = requestMoney, }, }, } end