Out of curiosity, what are you trying to do exactly? And in what situations do you want this cooldown to kick in?
I ask this because
this, using the previous answer as basis, effectively works like a pseudo-cooldown:
local function DmgRoll(player) --Named it loosely from what I've assumed the code is trying to do.
if player.mo.skin == "movieknux"
and (player.cmd.buttons & BT_CUSTOM1)
and not (player.pflags & PF_SPINNING) then --Having the check here makes it so you cannot do it again until the PF_SPINNING flags are removed from the player.
player.mo.state = S_PLAY_ROLL
player.pflags = $|PF_SPINNING
P_InstaThrust(player.mo, player.mo.angle, 4*FRACUNIT)
end
end
addHook("PlayerThink", DmgRoll)
Admittedly it is not pretty, it's more of a temporary solution than anything but it can be built on top of rather easily for further control logic so you can tweak it to your liking.
If what you want is an honest to god "x-amount-of-time cooldown", you'd have to go about it by creating variables to hold and control the minimum and maximum cooldown values, interval, etc. and
then making the check, using those values, to allow the player to perform the desired action. It's more intricate to work with than the alternative but
depending on what you want is potentially better also.