Making a server delay for a single player

  1. What do you want to achieve? Keep it simple and clear!
    So i have a cooldown between player can get currency for click. And for security reasons i’m doing delay on server. And just realised i have delay of server in code, so i want to make it in a single script. As i understand i should do time ticker or should i calculate math like
os.clock() + cooldown

and save it to server table named like CD?
Here is some code with os.time:

local CooldownLevel = ValueFixer(PlayerManager.GetUpgrade(player, "PhotonUpgrades", "Cooldown", "CurrLevel"))
local CooldownTime = InfiniteMath.new(Formulas:UpgradeFormulas(player, "Cooldown", CooldownLevel))

if table.find(PhotonGainCD, player) then return end

local CD = os.clock() + CooldownTime
		
		table.insert(PhotonGainCD, player)
		table.insert(PhotonGainCD[player], CD)

blind guess …

local CooldownLevel = ValueFixer(PlayerManager.GetUpgrade(player, "PhotonUpgrades", "Cooldown", "CurrLevel"))

if not table.find(PhotonGainCD, player) then
    local CooldownTime = os.clock() + InfiniteMath.new(Formulas:UpgradeFormulas(player, "Cooldown", CooldownLevel))
    table.insert(PhotonGainCD, player)
    PhotonGainCD[player] = CooldownTime
end

This should calculating the cooldown time and insert it if it’s not there.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.