Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. local cooldowns = {};
  2.  
  3. function Player:SetLuaCooldown(seconds, opt_id)
  4.     assert(type(self) == "userdata");
  5.     seconds = assert(tonumber(seconds));
  6.     opt_id = opt_id or 1;
  7.     local guid, source = self:GetGUIDLow(), debug.getinfo(2, 'S').short_src;
  8.  
  9.     if (not cooldowns[guid]) then
  10.         cooldowns[guid] = { [source] = {}; };
  11.     end
  12.  
  13.     cooldowns[guid][source][opt_id] = os.clock() + seconds;
  14. end
  15.  
  16. function Player:GetLuaCooldown(opt_id)
  17.     assert(type(self) == "userdata");
  18.     local guid, source = self:GetGUIDLow(), debug.getinfo(2, 'S').short_src;
  19.     opt_id = opt_id or 1;
  20.  
  21.     if (not cooldowns[guid]) then
  22.         cooldowns[guid] = { [source] = {}; };
  23.     end
  24.  
  25.     local cd = cooldowns[guid][source][opt_id];
  26.     if (not cd or cd < os.clock()) then
  27.         cooldowns[guid][source][opt_id] = 0
  28.         return 0;
  29.     else
  30.         return cooldowns[guid][source][opt_id] - os.clock();
  31.     end
  32. end