Advertisement
Guest User

Foereapers Cooldown Mehtod

a guest
Jun 6th, 2015
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. --Scripted by Foereaper, assited by Alex and Laurea
  2.  
  3. local cooldowns = {};
  4.  
  5. function Player:SetLuaCooldown(seconds, opt_id)
  6.         assert(type(self) == "userdata");
  7.         seconds = assert(tonumber(seconds));
  8.         opt_id = opt_id or 1;
  9.         local guid, source = self:GetGUIDLow(), debug.getinfo(2, 'S').short_src;
  10.  
  11.         if (not cooldowns[guid]) then
  12.                 cooldowns[guid] = { [source] = {}; };
  13.         end
  14.  
  15.         cooldowns[guid][source][opt_id] = os.clock() + seconds;
  16. end
  17.  
  18. function Player:GetLuaCooldown(opt_id)
  19.         assert(type(self) == "userdata");
  20.         local guid, source = self:GetGUIDLow(), debug.getinfo(2, 'S').short_src;
  21.         opt_id = opt_id or 1;
  22.  
  23.         if (not cooldowns[guid]) then
  24.                 cooldowns[guid] = { [source] = {}; };
  25.         end
  26.  
  27.         local cd = cooldowns[guid][source][opt_id];
  28.         if (not cd or cd < os.clock()) then
  29.                 cooldowns[guid][source][opt_id] = 0
  30.                 return 0;
  31.         else
  32.                 return cooldowns[guid][source][opt_id] - os.clock();
  33.         end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement