Try putting this somewhere on the server.
local r1 = 300 – The lowest possible amount of time between interest payouts
local r2 = 600 – The highest amount of time between interest payouts
local mult = 0.10 – The percent gain for regular players
local vipmult = 0.15 – The percent gain for VIP players
– DONT EDIT PAST THIS (Unless you want!)
hook.Add(“Think”, “PayInterest”, function()
– Loop through all the players. We want to account everybody!
for _, ply in pairs(player.GetAll()) do
– If they don’t have a time set to get their interest payment, lets set one! 300 to 600 seconds in the future.
if (!ply.nextInterest) then ply.nextInterest = CurTime() + math.random(r1, r2) end
-- If it's not time for them to get paid yet, then lets skip this player and check the next.
if (ply.nextInterest <= CurTime()) then continue end
-- If we got here, then it's time to pay them. Lets start by setting the next payment time to nil so it'll reset when we come back to them in the loop.
ply.nextInterest = nil
-- Store the player's bank amount locally. I don't know if this function is intensive, so we're only going to call it once to be safe.
local plybank = ply:GetBank()
-- Setup the multiplyer.
local percent = mult
if (ply:IsVIP()) then
percent = vipmult -- VIP member percent gain
-- Figure out how much they should gain given their current bank amount
local amount = plybank * percent
-- Update their bank with the latest amount of money they should have
ply:SetBank(plybank + amount)
-- Lets notify the player, they wanna know they got the dosh!
ply:Notify( "$"..amount.." Interest was added to your existing $"..plybank)
That’s a lot better than what you’re doing.
(it should work…)
[editline]11th August 2012[/editline]
If it doesn’t let me know, but I was sure to comment it out nice for you! <3