Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.73 KB | None | 0 0
  1. local eventupdate   = 10                                                -- Seconds
  2.  
  3. local path_img      = 'C:\\www\\livetibia2\\public\\images\\'           -- this folder will contain image
  4. local path_json     = 'C:\\www\\livetibia2\\public\\javascripts\\'      -- this folder will contain json file
  5. local inf_file      = 'information.json'                                -- name of json file (+extension)
  6. local pic_name      = 'self'                                            -- name of picture
  7.  
  8.  
  9. local chat = {}
  10. chat.private, chat.default, chat.npc = {}, {}, {}
  11. Module.New('main', function(mod)
  12.     screenshot(pic_name)
  13.  
  14.     -- spectators
  15.     local file = io.open(path_json .. inf_file, 'w')
  16.     local string = '{\n\t"spectators":{\n'
  17.     local outfit = Self.Outfit()
  18.     local pos = Self.Position()
  19.     string = string .. '\t\t"' .. Self.Name() .. '":{"posx":' .. pos.x .. ', "posy":' .. pos.y .. ', "posz":' .. pos.z .. ', "healthpercent":' .. math.ceil(math.abs(Self.Health() / (Self.MaxHealth() * 0.01))) .. ', "manapercent":' .. math.ceil(math.abs(Self.Mana() / (Self.MaxMana() * 0.01))) .. ', "lookdirection":' .. (Self.LookDirection() + 1) .. ', "outfitid":' .. outfit.id .. ', "outfithead":' .. outfit.head .. ', "outfitlegs":' .. outfit.legs .. ', "outfitfeet":' .. outfit.feet .. ', "outfitaddons":' .. outfit.addons .. ', "outfitmount":' .. outfit.mount .. '},\n'
  20.     for name, creature in Creature.iCreatures() do
  21.         local pos = creature:Position()
  22.         local outfit = creature:Outfit()
  23.         string = string .. '\t\t"' .. name .. '":{"posx":' .. pos.x .. ', "posy":' .. pos.y .. ', "posz":' .. pos.z .. ', "healthpercent":' .. creature:HealthPercent() .. ', "lookdirection":' .. (creature:LookDirection()+1) .. ', "outfitid":' .. outfit.id .. ', "outfithead":' .. outfit.head .. ', "outfitlegs":' .. outfit.legs .. ', "outfitfeet":' .. outfit.feet .. ', "outfitaddons":' .. outfit.addons .. ', "outfitmount":' .. outfit.mount .. '},\n'
  24.     end
  25.     string = string.sub(string, 1, -3)
  26.     string = string .. '\n\t},\n\n'
  27.  
  28.     local hud = HUDGetDimensions()
  29.     string = string .. '\t"hud":{\n'
  30.     string = string .. '\t\t"eqwindowh":' .. hud.eqwindowh .. ',\n'
  31.     string = string .. '\t\t"eqwindoww":' .. hud.eqwindoww .. ',\n'
  32.     string = string .. '\t\t"eqwindowx":' .. hud.eqwindowx .. ',\n'
  33.     string = string .. '\t\t"eqwindowy":' .. hud.eqwindowy .. ',\n'
  34.     string = string .. '\t\t"gamewindowh":' .. hud.gamewindowh .. ',\n'
  35.     string = string .. '\t\t"gamewindoww":' .. hud.gamewindoww .. ',\n'
  36.     string = string .. '\t\t"gamewindowx":' .. hud.gamewindowx .. ',\n'
  37.     string = string .. '\t\t"gamewindowy":' .. hud.gamewindowy .. '\n'
  38.     string = string .. '\t},\n'
  39.  
  40.     -- self info
  41.     string = string .. '\t"self":{\n'
  42.     string = string .. '\t\t"Skull":'           .. Self.Skull() .. ',\n'
  43.     string = string .. '\t\t"PartyStatus":'     .. Self.PartyStatus() .. ',\n'
  44.     string = string .. '\t\t"PvPIcon":'         .. Self.PvPIcon() .. ',\n'
  45.     string = string .. '\t\t"WarIcon":'         .. Self.WarIcon() .. ',\n'
  46.     string = string .. '\t\t"MaxHealth":'       .. Self.MaxHealth() .. ',\n'
  47.     string = string .. '\t\t"Health":'          .. Self.Health() .. ',\n'
  48.     string = string .. '\t\t"MaxMana":'         .. Self.MaxMana() .. ',\n'
  49.     string = string .. '\t\t"Mana":'            .. Self.Mana() .. ',\n'
  50.     string = string .. '\t\t"Experience":'      .. Self.Experience() .. ',\n'
  51.     string = string .. '\t\t"Level":'           .. Self.Level() .. ',\n'
  52.     string = string .. '\t\t"Cap":'             .. Self.Cap() .. ',\n'
  53.     string = string .. '\t\t"Stamina":'         .. Self.Stamina() .. ',\n'
  54.     string = string .. '\t\t"Soul":'            .. Self.Soul() .. '\n'
  55.     string = string .. '\t},\n\n'
  56.  
  57.     -- flags
  58.     string = string .. '\t"flag":{\n'
  59.     string = string .. '\t\t"isHasted":'        .. (Self.isHasted() and 'true' or 'false') .. ',\n'
  60.     string = string .. '\t\t"isManaShielded":'  .. (Self.isManaShielded() and 'true' or 'false') .. ',\n'
  61.     string = string .. '\t\t"isParalyzed":'     .. (Self.isParalyzed() and 'true' or 'false') .. ',\n'
  62.     string = string .. '\t\t"isPoisoned":'      .. (Self.isPoisoned() and 'true' or 'false') .. ',\n'
  63.     string = string .. '\t\t"isBurning":'       .. (Self.isBurning() and 'true' or 'false') .. ',\n'
  64.     string = string .. '\t\t"isElectrified":'   .. (Self.isElectrified() and 'true' or 'false') .. ',\n'
  65.     string = string .. '\t\t"isCursed":'        .. (Self.isCursed() and 'true' or 'false') .. ',\n'
  66.     string = string .. '\t\t"isFreezing":'      .. (Self.isFreezing() and 'true' or 'false') .. ',\n'
  67.     string = string .. '\t\t"isDrunk":'         .. (Self.isDrunk() and 'true' or 'false') .. ',\n'
  68.     string = string .. '\t\t"isDrowning":'      .. (Self.isDrowning() and 'true' or 'false') .. ',\n'
  69.     string = string .. '\t\t"isDazzled":'       .. (Self.isDazzled() and 'true' or 'false') .. ',\n'
  70.     string = string .. '\t\t"isBleeding":'      .. (Self.isBleeding() and 'true' or 'false') .. ',\n'
  71.     string = string .. '\t\t"isInFight":'       .. (Self.isInFight() and 'true' or 'false') .. ',\n'
  72.     string = string .. '\t\t"isPzLocked":'      .. (Self.isPzLocked() and 'true' or 'false') .. ',\n'
  73.     string = string .. '\t\t"isInPz":'          .. (Self.isInPz() and 'true' or 'false') .. ',\n'
  74.     string = string .. '\t\t"isBuffed":'        .. (Self.isBuffed() and 'true' or 'false') .. '\n'
  75.     string = string .. '\t},\n\n'
  76.  
  77.     -- containers
  78.     string = string .. '\t"containers":{  \n'
  79.     for index = 0, 16 do
  80.         if getContainerOpen(index) then
  81.             local cont = Container.New(index)
  82.             string = string .. '\t"' .. index .. '":{\n'
  83.             string = string .. '\t\t"count":' .. cont:ItemCount() .. ',\n'
  84.             string = string .. '\t\t"name":"' .. cont:Name() .. '",\n'
  85.             string = string .. '\t\t"content":[  \n'
  86.             for slot, data in cont:iItems() do
  87.                 string = string .. '\t\t\t{"id":' .. data.id .. ', "count":' .. data.count .. '},\n'
  88.             end
  89.             string = string.sub(string, 1, -3)
  90.             string = string .. '\n\t\t]\n\t},\n'
  91.         end
  92.     end
  93.     string = string.sub(string, 1, -3)
  94.     string = string .. '\n\t},\n\n'
  95.  
  96.     -- chat
  97.     string = string .. '\t"chat":{\n'
  98.  
  99.     string = string .. '\t\t\t"default":[  \n'
  100.     for i = 1, #chat['default'] do
  101.         string = string .. '\t\t\t\t{"speaker":"' .. chat['default'][i]['speaker'] .. '", "level":' .. chat['default'][i]['level'] .. ', "text":"' .. chat['default'][i]['text'] .. '", "time":"' .. chat['default'][i]['time'] .. '"},\n'
  102.     end
  103.     string = string.sub(string, 1, -3)
  104.     string = string .. '\n\t\t\t],\n'
  105.  
  106.     string = string .. '\t\t\t"private":[  \n'
  107.     for i = 1, #chat['private'] do
  108.         string = string .. '\t\t\t\t{"speaker":"' .. chat['private'][i]['speaker'] .. '", "level":' .. chat['private'][i]['level'] .. ', "text":"' .. chat['private'][i]['text'] .. '", "time":"' .. chat['private'][i]['time'] .. '"},\n'
  109.     end
  110.     string = string.sub(string, 1, -3)
  111.     string = string .. '\n\t\t\t],\n'
  112.  
  113.     string = string .. '\t\t\t"npc":[  \n'
  114.     for i = 1, #chat['npc'] do
  115.         string = string .. '\t\t\t\t{"speaker":"' .. chat['npc'][i]['speaker'] .. '", "text":"' .. chat['npc'][i]['text'] .. '", "time":"' .. chat['npc'][i]['time'] .. '"},\n'
  116.     end
  117.     string = string.sub(string, 1, -3)
  118.     string = string .. '\n\t\t\t]\n'
  119.  
  120.     string = string .. '\t}\n'
  121.  
  122.     string = string .. '}'
  123.     file:write(string)
  124.     file:flush()
  125.     file:close()
  126.  
  127.     -- move optional image to webserver
  128.     local file = io.open(pic_name .. '.bmp', 'rb') or io.open('\\Screenshots\\' .. pic_name .. '.bmp', 'rb') or io.open('..\\Screenshots\\' .. pic_name .. '.bmp', 'rb') or io.open('..\\..\\Screenshots\\' .. pic_name .. '.bmp', 'rb')
  129.     local content = file:read('*all')
  130.     file:close()
  131.     local file = io.open(path_img .. pic_name .. '.bmp', 'wb')
  132.     file:write(content)
  133.     file:flush()
  134.     file:close()
  135.  
  136.     mod:Delay(eventupdate*1000)
  137. end)
  138.  
  139. local PRT = PrivateMessageProxy.New('PRT')
  140.  
  141. PRT:OnReceive(function(proxy, speaker, level, text)
  142.     local time = os.date('%H:%M')
  143.     local text = string.gsub(text, '"', '\\"')
  144.     table.insert(chat.private, {speaker = speaker, level = level, text = text, time = time})
  145. end)
  146.  
  147. local DFT = LocalSpeechProxy.New('DFT')
  148.  
  149. DFT:OnReceive(function(proxy, mtype, speaker, level, text)
  150.     local time = os.date('%H:%M')
  151.     local text = string.gsub(text, '"', '\\"')
  152.     table.insert(chat.default, {speaker = speaker, level = level, text = text, time = time})
  153. end)
  154.  
  155. local NPC = NpcMessageProxy.New('NPC')
  156.  
  157. NPC:OnReceive(function(proxy, speaker, text)
  158.     local time = os.date('%H:%M')
  159.     local text = string.gsub(text, '"', '\\"')
  160.     table.insert(chat.npc, {speaker = speaker, text = text, time = time})
  161. end)
  162.  
  163.  
  164. --[[local loot_list = {
  165.     [0] = {'platinum coin', 3031},
  166.     [2] = {},
  167.     [3] = {}
  168. }
  169.  
  170. for index, loot in pairs(loot_list) do
  171.     for i = 1, #loot do
  172.         loot[i] = Item.GetItemIDFromDualInput(loot[i])
  173.     end
  174. end
  175.  
  176. local target, pos = nil, nil
  177.  
  178. Module.New('Looter', function(mod)
  179.     local targetid = target == nil and Self.TargetID()
  180.     if target ~= nil then
  181.         if target:isAlive() then
  182.             pos = target:Position()
  183.         elseif pos ~= nil then
  184.             local cont = nil
  185.             if Item.isCorpse(Map.GetTopUseItem(pos.x, pos.y, pos.z).id) then
  186.                 Self.UseItemFromGround(pos.x, pos.y, pos.z)
  187.                 wait(2000)
  188.                 cont = Container.GetLast()
  189.             else
  190.                 Self.BrowseField(pos.x, pos.y, pos.z)
  191.                 wait(2000)
  192.                 cont = Container.GetLast()
  193.                 for slot, data in cont:iItems() do
  194.                     if Item.isCorpse(cont:GetItemData(slot).id) then
  195.                         cont:UseItem(slot, true)
  196.                         wait(2000)
  197.                     end
  198.                 end
  199.             end
  200.             if cont ~= nil then
  201.                 for slot, data in cont:iItems() do -- reverse this or update index after each loop
  202.                     breakit = false
  203.                     for index, loot in pairs(loot_list) do
  204.                         for i = 1, #loot do
  205.                             if data.id == loot[i] then
  206.                                 local desti = Container.New(index)
  207.                                 cont:MoveItemToContainer(slot, desti:Index(), desti:ItemCount()-1)
  208.                                 wait(1000)
  209.                                 breakit = true
  210.                                 break
  211.                             end
  212.                         end
  213.                         if breakit then
  214.                             break
  215.                         elseif Item.isFood(data.id) then
  216.                             cont:UseItem(slot, false)
  217.                         end
  218.                     end
  219.                 end
  220.             end
  221.             pos = nil
  222.             target = nil
  223.         else
  224.             pos = nil
  225.             target = nil
  226.         end
  227.     elseif targetid ~= 0 then
  228.         target = Creature.New(targetid)
  229.         pos = target:Position()
  230.     end
  231. end)]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement