SHARE
TWEET

scrisot skull

a guest Nov 22nd, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getPlayerFrags(cid)
  2.     local time = os.time()
  3.     local times = {today = (time - 86400), week = (time - (7 * 86400))}
  4.  
  5.     local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
  6.     if(result:getID() ~= -1) then
  7.         repeat
  8.             local content = {date = result:getDataInt("date")}
  9.             if(content.date > times.today) then
  10.                 table.insert(contents.day, content)
  11.             elseif(content.date > times.week) then
  12.                 table.insert(contents.week, content)
  13.             else
  14.                 table.insert(contents.month, content)
  15.             end
  16.         until not result:next()
  17.         result:free()
  18.     end
  19.  
  20.     local size = {
  21.         day = table.maxn(contents.day),
  22.         week = table.maxn(contents.week),
  23.         month = table.maxn(contents.month)
  24.     }
  25.     return size.day + size.week + size.month
  26. end
  27.  
  28. local fragSkulls = {
  29.     { from = 10, to = 20, skull = SKULL_YELLOW },
  30.     { from = 21, to = 50, skull = SKULL_GREEN },
  31.     { from = 51, to = 100, skull = SKULL_WHITE },
  32.     { from = 101, to = 200, skull = SKULL_RED },
  33.     { from = 201, to = 300, skull = SKULL_BLACK }
  34. }
  35.  
  36. function onThink(cid, interval)
  37.     if not isPlayer(cid) then
  38.         return
  39.     end
  40.  
  41.     local accountManager = getPlayerAccountManager(cid)
  42.     if accountManager == MANAGER_NONE then
  43.         local frags = getPlayerFrags(cid)
  44.         local skull = getPlayerSkullType(cid)
  45.         for index, skullInfo in pairs(fragSkulls) do
  46.             if frags >= skullInfo.from and frags <= skullInfo.to then
  47.                 doCreatureSetSkullType(cid, skullInfo.skull)
  48.                 return
  49.             end
  50.         end
  51.         doCreatureSetSkullType(cid, SKULL_NONE)
  52.     end
  53.  
  54. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top