Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local eventupdate = 10 -- Seconds
- local path_img = 'C:\\www\\livetibia2\\public\\images\\' -- this folder will contain image
- local path_json = 'C:\\www\\livetibia2\\public\\javascripts\\' -- this folder will contain json file
- local inf_file = 'information.json' -- name of json file (+extension)
- local pic_name = 'self' -- name of picture
- local chat = {}
- chat.private, chat.default, chat.npc = {}, {}, {}
- Module.New('main', function(mod)
- screenshot(pic_name)
- -- spectators
- local file = io.open(path_json .. inf_file, 'w')
- local string = '{\n\t"spectators":{\n'
- local outfit = Self.Outfit()
- local pos = Self.Position()
- 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'
- for name, creature in Creature.iCreatures() do
- local pos = creature:Position()
- local outfit = creature:Outfit()
- 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'
- end
- string = string.sub(string, 1, -3)
- string = string .. '\n\t},\n\n'
- local hud = HUDGetDimensions()
- string = string .. '\t"hud":{\n'
- string = string .. '\t\t"eqwindowh":' .. hud.eqwindowh .. ',\n'
- string = string .. '\t\t"eqwindoww":' .. hud.eqwindoww .. ',\n'
- string = string .. '\t\t"eqwindowx":' .. hud.eqwindowx .. ',\n'
- string = string .. '\t\t"eqwindowy":' .. hud.eqwindowy .. ',\n'
- string = string .. '\t\t"gamewindowh":' .. hud.gamewindowh .. ',\n'
- string = string .. '\t\t"gamewindoww":' .. hud.gamewindoww .. ',\n'
- string = string .. '\t\t"gamewindowx":' .. hud.gamewindowx .. ',\n'
- string = string .. '\t\t"gamewindowy":' .. hud.gamewindowy .. '\n'
- string = string .. '\t},\n'
- -- self info
- string = string .. '\t"self":{\n'
- string = string .. '\t\t"Skull":' .. Self.Skull() .. ',\n'
- string = string .. '\t\t"PartyStatus":' .. Self.PartyStatus() .. ',\n'
- string = string .. '\t\t"PvPIcon":' .. Self.PvPIcon() .. ',\n'
- string = string .. '\t\t"WarIcon":' .. Self.WarIcon() .. ',\n'
- string = string .. '\t\t"MaxHealth":' .. Self.MaxHealth() .. ',\n'
- string = string .. '\t\t"Health":' .. Self.Health() .. ',\n'
- string = string .. '\t\t"MaxMana":' .. Self.MaxMana() .. ',\n'
- string = string .. '\t\t"Mana":' .. Self.Mana() .. ',\n'
- string = string .. '\t\t"Experience":' .. Self.Experience() .. ',\n'
- string = string .. '\t\t"Level":' .. Self.Level() .. ',\n'
- string = string .. '\t\t"Cap":' .. Self.Cap() .. ',\n'
- string = string .. '\t\t"Stamina":' .. Self.Stamina() .. ',\n'
- string = string .. '\t\t"Soul":' .. Self.Soul() .. '\n'
- string = string .. '\t},\n\n'
- -- flags
- string = string .. '\t"flag":{\n'
- string = string .. '\t\t"isHasted":' .. (Self.isHasted() and 'true' or 'false') .. ',\n'
- string = string .. '\t\t"isManaShielded":' .. (Self.isManaShielded() and 'true' or 'false') .. ',\n'
- string = string .. '\t\t"isParalyzed":' .. (Self.isParalyzed() and 'true' or 'false') .. ',\n'
- string = string .. '\t\t"isPoisoned":' .. (Self.isPoisoned() and 'true' or 'false') .. ',\n'
- string = string .. '\t\t"isBurning":' .. (Self.isBurning() and 'true' or 'false') .. ',\n'
- string = string .. '\t\t"isElectrified":' .. (Self.isElectrified() and 'true' or 'false') .. ',\n'
- string = string .. '\t\t"isCursed":' .. (Self.isCursed() and 'true' or 'false') .. ',\n'
- string = string .. '\t\t"isFreezing":' .. (Self.isFreezing() and 'true' or 'false') .. ',\n'
- string = string .. '\t\t"isDrunk":' .. (Self.isDrunk() and 'true' or 'false') .. ',\n'
- string = string .. '\t\t"isDrowning":' .. (Self.isDrowning() and 'true' or 'false') .. ',\n'
- string = string .. '\t\t"isDazzled":' .. (Self.isDazzled() and 'true' or 'false') .. ',\n'
- string = string .. '\t\t"isBleeding":' .. (Self.isBleeding() and 'true' or 'false') .. ',\n'
- string = string .. '\t\t"isInFight":' .. (Self.isInFight() and 'true' or 'false') .. ',\n'
- string = string .. '\t\t"isPzLocked":' .. (Self.isPzLocked() and 'true' or 'false') .. ',\n'
- string = string .. '\t\t"isInPz":' .. (Self.isInPz() and 'true' or 'false') .. ',\n'
- string = string .. '\t\t"isBuffed":' .. (Self.isBuffed() and 'true' or 'false') .. '\n'
- string = string .. '\t},\n\n'
- -- containers
- string = string .. '\t"containers":{ \n'
- for index = 0, 16 do
- if getContainerOpen(index) then
- local cont = Container.New(index)
- string = string .. '\t"' .. index .. '":{\n'
- string = string .. '\t\t"count":' .. cont:ItemCount() .. ',\n'
- string = string .. '\t\t"name":"' .. cont:Name() .. '",\n'
- string = string .. '\t\t"content":[ \n'
- for slot, data in cont:iItems() do
- string = string .. '\t\t\t{"id":' .. data.id .. ', "count":' .. data.count .. '},\n'
- end
- string = string.sub(string, 1, -3)
- string = string .. '\n\t\t]\n\t},\n'
- end
- end
- string = string.sub(string, 1, -3)
- string = string .. '\n\t},\n\n'
- -- chat
- string = string .. '\t"chat":{\n'
- string = string .. '\t\t\t"default":[ \n'
- for i = 1, #chat['default'] do
- 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'
- end
- string = string.sub(string, 1, -3)
- string = string .. '\n\t\t\t],\n'
- string = string .. '\t\t\t"private":[ \n'
- for i = 1, #chat['private'] do
- 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'
- end
- string = string.sub(string, 1, -3)
- string = string .. '\n\t\t\t],\n'
- string = string .. '\t\t\t"npc":[ \n'
- for i = 1, #chat['npc'] do
- string = string .. '\t\t\t\t{"speaker":"' .. chat['npc'][i]['speaker'] .. '", "text":"' .. chat['npc'][i]['text'] .. '", "time":"' .. chat['npc'][i]['time'] .. '"},\n'
- end
- string = string.sub(string, 1, -3)
- string = string .. '\n\t\t\t]\n'
- string = string .. '\t}\n'
- string = string .. '}'
- file:write(string)
- file:flush()
- file:close()
- -- move optional image to webserver
- 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')
- local content = file:read('*all')
- file:close()
- local file = io.open(path_img .. pic_name .. '.bmp', 'wb')
- file:write(content)
- file:flush()
- file:close()
- mod:Delay(eventupdate*1000)
- end)
- local PRT = PrivateMessageProxy.New('PRT')
- PRT:OnReceive(function(proxy, speaker, level, text)
- local time = os.date('%H:%M')
- local text = string.gsub(text, '"', '\\"')
- table.insert(chat.private, {speaker = speaker, level = level, text = text, time = time})
- end)
- local DFT = LocalSpeechProxy.New('DFT')
- DFT:OnReceive(function(proxy, mtype, speaker, level, text)
- local time = os.date('%H:%M')
- local text = string.gsub(text, '"', '\\"')
- table.insert(chat.default, {speaker = speaker, level = level, text = text, time = time})
- end)
- local NPC = NpcMessageProxy.New('NPC')
- NPC:OnReceive(function(proxy, speaker, text)
- local time = os.date('%H:%M')
- local text = string.gsub(text, '"', '\\"')
- table.insert(chat.npc, {speaker = speaker, text = text, time = time})
- end)
- --[[local loot_list = {
- [0] = {'platinum coin', 3031},
- [2] = {},
- [3] = {}
- }
- for index, loot in pairs(loot_list) do
- for i = 1, #loot do
- loot[i] = Item.GetItemIDFromDualInput(loot[i])
- end
- end
- local target, pos = nil, nil
- Module.New('Looter', function(mod)
- local targetid = target == nil and Self.TargetID()
- if target ~= nil then
- if target:isAlive() then
- pos = target:Position()
- elseif pos ~= nil then
- local cont = nil
- if Item.isCorpse(Map.GetTopUseItem(pos.x, pos.y, pos.z).id) then
- Self.UseItemFromGround(pos.x, pos.y, pos.z)
- wait(2000)
- cont = Container.GetLast()
- else
- Self.BrowseField(pos.x, pos.y, pos.z)
- wait(2000)
- cont = Container.GetLast()
- for slot, data in cont:iItems() do
- if Item.isCorpse(cont:GetItemData(slot).id) then
- cont:UseItem(slot, true)
- wait(2000)
- end
- end
- end
- if cont ~= nil then
- for slot, data in cont:iItems() do -- reverse this or update index after each loop
- breakit = false
- for index, loot in pairs(loot_list) do
- for i = 1, #loot do
- if data.id == loot[i] then
- local desti = Container.New(index)
- cont:MoveItemToContainer(slot, desti:Index(), desti:ItemCount()-1)
- wait(1000)
- breakit = true
- break
- end
- end
- if breakit then
- break
- elseif Item.isFood(data.id) then
- cont:UseItem(slot, false)
- end
- end
- end
- end
- pos = nil
- target = nil
- else
- pos = nil
- target = nil
- end
- elseif targetid ~= 0 then
- target = Creature.New(targetid)
- pos = target:Position()
- end
- end)]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement