Don't like ads? PRO users don't see any ads ;-)
Guest

newlook

By: a guest on Aug 17th, 2012  |  syntax: None  |  size: 3.15 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. function onLogin(cid)
  29.     registerCreatureEvent(cid, "newlook")
  30.     return true
  31. end
  32.  
  33. function onLook(cid, thing, position, lookDistance)
  34.     if isPlayer(thing.uid) and thing.uid ~= cid then
  35.         doPlayerSetSpecialDescription(thing.uid,'\n[Frags: '..getPlayerFrags(thing.uid)..']')
  36.         return true
  37.     elseif thing.uid == cid then
  38.         doPlayerSetSpecialDescription(cid,'\n[Frags: '..getPlayerFrags(cid)..']')
  39.         local string = 'You see yourself.'
  40.         if getPlayerFlagValue(cid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION) then
  41.             string = string..' You are '.. getPlayerGroupName(cid) ..'.'
  42.         elseif getPlayerVocation(cid) ~= 0 then
  43.             string = string..' You are '.. getPlayerVocationName(cid) ..'.'
  44.         else
  45.             string = string..' You have no vocation.'
  46.         end
  47.         string = string..getPlayerSpecialDescription(cid)..'\n'
  48.  
  49.         if getPlayerGuildId(cid) > 0 then
  50.             string = string..' You are ' .. (getPlayerGuildRank(cid) == '' and 'a member' or getPlayerGuildRank(cid)) ..' of the '.. getPlayerGuildName(cid)
  51.             string = getPlayerGuildNick(cid) ~= '' and string..' ('.. getPlayerGuildNick(cid) ..').' or string..'.'
  52.         end
  53.  
  54.         if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS) then
  55.             string = string..'\nHealth: ['.. getCreatureHealth(cid) ..' / '.. getCreatureMaxHealth(cid) ..'], Mana: ['.. getCreatureMana(cid) ..' / '.. getCreatureMaxMana(cid) ..'].'
  56.             string = string..'\nIP: '.. doConvertIntegerToIp(getPlayerIp(cid)) ..'.'
  57.         end
  58.  
  59.         if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION) then
  60.             string = string..'\nPosition: [X:'.. position.x..'] [Y:'.. position.y..'] [Z:'.. position.z..'].'
  61.         end
  62.         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string)  
  63.         return false
  64.     end
  65.     return true
  66. end