PHP Code:
HUDPing = HUD.New(20, 10, "Ping:", titleColor.r, titleColor.g, titleColor.b)
HUD.New(70, 30, "BrutaMinaHUD 0.2", HUDColor.r, HUDColor.g, HUDColor.b)
HUDLootList = HUD.New(10, 50, "Loot List:", titleColor.r, titleColor.g, titleColor.b)
HUDSuppliesList = HUD.New(10, 90, "Supplies List:", titleColor.r, titleColor.g, titleColor.b)
HUD.img = HUD.New (05, 140, "", itemColor.r, itemColor.g, itemColor.b)
HUDEarned = HUD.New(10, 70, "Earned:", itemTotalColor.r, itemTotalColor.g, itemTotalColor.b)
HUDWasted = HUD.New(10, 110, "Spent:", itemTotalColor.r, itemTotalColor.g, itemTotalColor.b)
HUDProfit = HUD.New(10, 150, "Profit:", itemTotalColor.r, itemTotalColor.g, itemTotalColor.b)
HUDExp = HUD.New(10, 170, "Experience:", itemTotalColor.r, itemTotalColor.g, itemTotalColor.b)
HUDTime = HUD.New(10, 190, "Time:", itemTotalColor.r, itemTotalColor.g, itemTotalColor.b)
HUDStamina = HUD.New(10, 210, "Stamina:", itemTotalColor.r, itemTotalColor.g, itemTotalColor.b)
offset = 0
offset2 = 0
Experience = HUD.New(140, 170, "", countTotalColor.r, countTotalColor.g, countTotalColor.b)
Timer = HUD.New(140, 190, "", countTotalColor.r, countTotalColor.g, countTotalColor.b)
Stamina = HUD.New(140, 210, "", countTotalColor.r, countTotalColor.g, countTotalColor.b)
Ping = HUD.New(50, 10, "", countTotalColor.r, countTotalColor.g, countTotalColor.b)
TotalLoot = HUD.New(140, 70, "", countTotalColor.r, countTotalColor.g, countTotalColor.b)
TotalSupplies = HUD.New(140, 110, "", countTotalColor.r, countTotalColor.g, countTotalColor.b)
TotalProfit = HUD.New(140, 150, "", countTotalColor.r, countTotalColor.g, countTotalColor.b)
HUDSupplies = {}
HUDSuppliesNames = {}
HUDLoot = {}
SessionStart = os.time()
ExperienceStart = Self.Experience()
DepotIDs = {3497, 3498, 3499, 3500}
LootNumbers = {}
SuppliesNumbers = {}
-- Remake to read loot list from backpacks ?
-- Container:GetItemData(spot)
-- function Container:ItemCount()
--LootIDs = {}
--SuppliesIDs = {}
--[[
local containers = Container.GetAll()
for j=1 , #containers do
local c = Container.New(containers[j])
local ContainerName = string.gmatch(c:Name(), "%S+")
local IsContainer = false
for k in ContainerName do
if k == "Backpack" or k == "Bag" then
IsContainer = true
end
end
if IsContainer then
if j ~= 1 then
local itemsNumber = c:ItemCount()
print(itemsNumber)
for i=0, itemsNumber - 1 do
local item = c:GetItemData(i)
--print(item.id)
local isNextBackpack = false
local itemName = string.gmatch(Item.GetName(item.id), "%S+")
print(Item.GetName(item.id))
local notBackpack = true
for k in itemName do
if k == "Backpack" or k == "Bag" then
notBackpack = false
end
end
if (not table.contains(LootNumbers, item.id)) and notBackpack then
table.insert(LootNumbers, item.id)
--print("x")
LootIDs[item.id] = { id = item.id, vamount = c:CountItemsOfID(item.id), samount = 0}
--print("x2")
HUDLoot[item.id] = HUD.New(140, 250+(#LootIDs * 15)+50, item.id.." (".."x"..")", R2, G2, B2)
--HUDLoot[item.id] = HUD.New(140, 250, "x", R2, G2, B2)
print(item.id)
else
--HUDLoot[item.id]:SetText(c:CountItemsOfID(item.id).." lol")
end
end
end
end
end
]]--
io.input("..\\Settings\\"..fileName..".xbst")
LootIDs = {}
SuppliesIDs = {}
local suppliesLines = {}
local lootLines = {}
for line in io.lines() do
if string.find(line:lower(), "action=") then
table.insert(lootLines, line:lower())
elseif string.find(line:lower(), "item id=") then
table.insert(suppliesLines, line:lower())
end
end
local numbers = {}
for i=1, #lootLines do
table.insert(numbers, string.match(lootLines[i], "%d+"))
end
for i=1, #numbers do
--if tonumber(numbers[i]) ~= 3031 then
LootIDs[#LootIDs + 1] = { id = tonumber(numbers[i]), vamount = 0, samount = 0, hud = false}
--end
end
local numbersSupplies = {16141}
for i=1, #suppliesLines do
table.insert(numbersSupplies, string.match(suppliesLines[i], "%d+"))
end
for i=1, #numbersSupplies do
SuppliesIDs[#SuppliesIDs + 1] = { id = tonumber(numbersSupplies[i]), vamount = 0, samount = 0, mamount = 0, uamount = 0, hud = false}
end
-- Maybe -- add start values = -1 and if -1 then do first check for all items amount to not count those looted before hud started
local Wasted = 0
local Looted = 0
local HUDsL = 0
HUD.CountLoot = function(c)
local LootPrice = 0
for i=1, #LootIDs do
local TempAmount = 0
local containers = Container.GetAll()
for j=1 , #containers do
local c = Container.New(containers[j])
local ContainerName = string.gmatch(c:Name(), "%S+")
local IsContainer = false
for k in ContainerName do
if k == "Backpack" or k == "Bag" or k == "Box" or k == "box" then
IsContainer = true
end
end
if IsContainer then
if j ~= 1 then
TempAmount = TempAmount + c:CountItemsOfID(LootIDs[i].id)
end
end
end
if TempAmount < LootIDs[i].vamount then -- Next Backpack
LootIDs[i].samount = LootIDs[i].samount + LootIDs[i].vamount
LootIDs[i].vamount = TempAmount
else
LootIDs[i].vamount = TempAmount
end
local TempPrice = LootIDs[i].samount + LootIDs[i].vamount
if LootIDs[i].hud then
HUDLoot[LootIDs[i].id]:SetText(TempPrice.." ("..(TempPrice * ItemValue(LootIDs[i].id)).." gp)")
elseif LootIDs[i].vamount > 0 and not LootIDs[i].hud then
offset = offset + 15
HUDsL = HUDsL + 1
LootIDs[i].hud = true
HUD.New(20, 50+(HUDsL * 15), string.sub(Item.GetName(LootIDs[i].id), 1, 15), itemColor.r, itemColor.g, itemColor.b)
HUDLoot[LootIDs[i].id] = HUD.New(120, 50+(HUDsL * 15), "0", countColor.r, countColor.g, countColor.b)
HUD.img = HUD.New (10, 50+(HUDsL * 15), "", itemColor.r, itemColor.g, itemColor.b)
HUD.img:SetItemSize(05)
HUD.ChangePosition()
end
LootPrice = LootPrice + (LootIDs[i].samount + LootIDs[i].vamount) * ItemValue(LootIDs[i].id)
end
Looted = LootPrice
TotalLoot:SetText(LootPrice .. " gp")
end
local HUDsS = 0
HUD.CountWaste = function(c)
local SuppliesWasted = 0
for i=1, #SuppliesIDs do
local TempAmount = Self.ItemCount(SuppliesIDs[i].id)
if TempAmount > SuppliesIDs[i].vamount then -- Refilled -- !! ONLY IF CLOSE TO NPC OR IN DEPO !!
SuppliesIDs[i].samount = SuppliesIDs[i].samount + SuppliesIDs[i].uamount
SuppliesIDs[i].mamount = TempAmount
SuppliesIDs[i].vamount = TempAmount
else -- Supply used
SuppliesIDs[i].vamount = TempAmount
SuppliesIDs[i].uamount = SuppliesIDs[i].mamount - TempAmount
end
local TempPrice = SuppliesIDs[i].samount + SuppliesIDs[i].uamount
if SuppliesIDs[i].hud then
HUDSupplies[SuppliesIDs[i].id]:SetText(TempPrice.." ("..(TempPrice * ItemPrice(SuppliesIDs[i].id)).." gp)")
elseif SuppliesIDs[i].uamount > 0 and not SuppliesIDs[i].hud then
offset2 = offset2 + 15
HUDsS = HUDsS + 1
SuppliesIDs[i].hud = true
HUDSuppliesNames[SuppliesIDs[i].id] = HUD.New(20, 110+(HUDsS * 15), string.sub(Item.GetName(SuppliesIDs[i].id), 1, 15), itemColor.r, itemColor.g, itemColor.b)
HUDSupplies[SuppliesIDs[i].id] = HUD.New(120, 110+(HUDsS * 15), "0", countColor.r, countColor.g, countColor.b)
HUD.img = HUD.New (10, 110+(HUDsS * 15), "", itemColor.r, itemColor.g, itemColor.b)
HUD.img:SetItemSize(10)
HUD.ChangePosition()
end
SuppliesWasted = SuppliesWasted + (SuppliesIDs[i].samount + SuppliesIDs[i].uamount) * ItemPrice(SuppliesIDs[i].id)
end
Wasted = SuppliesWasted
TotalSupplies:SetText(SuppliesWasted .. " gp")
end
HUD.ChangePosition = function()
local countTrues = 0
for i=1, #SuppliesIDs do
if SuppliesIDs[i].hud then
HUDSuppliesNames[SuppliesIDs[i].id]:SetPosition(20, 110 + (countTrues * 15) + offset)
HUDSupplies[SuppliesIDs[i].id]:SetPosition(120, 110 + (countTrues * 15) + offset)
countTrues = countTrues + 1
end
end
HUDSuppliesList:SetPosition(10, 90 + offset)
HUDExp:SetPosition(10, 170 + offset + offset2)
HUDTime:SetPosition(10, 190 + offset + offset2)
HUDStamina:SetPosition(10, 210 + offset + offset2)
Experience:SetPosition(110, 170 + offset + offset2)
Timer:SetPosition(110, 190 + offset + offset2)
Stamina:SetPosition(110, 210 + offset + offset2)
HUDEarned:SetPosition(10, 70 + offset)
TotalLoot:SetPosition(110, 70 + offset)
HUDWasted:SetPosition(10, 110 + offset + offset2)
TotalSupplies:SetPosition(110, 110 + offset + offset2)
HUDProfit:SetPosition(10, 150 + offset + offset2)
TotalProfit:SetPosition(110, 150 + offset + offset2)
end
local HUDUpdateStart = true
Module.New('HUD-Update', function(module)
if HUDUpdateStart then
-- Timer
local TimeDifference = os.difftime(os.time(), SessionStart)
h = string.format("%02.f", math.floor(TimeDifference/3600));
m = string.format("%02.f", math.floor(TimeDifference/60 - (h*60)));
Timer:SetText(h.."h "..m.."m")
-- Ping
Ping:SetText(Self.Ping() .. " ms")
if Self.Ping() >= 120 then
Ping:SetTextColor(255, 40, 0)
elseif Self.Ping() <= 120 then
Ping:SetTextColor(255, 255, 255)
end
-- Stamina
_G['refreshHUD'] = Module.New("refreshHUD", function(module)
stam = math.floor(Self.Stamina()/60)
stam2 = math.floor(((Self.Stamina()/60-stam)*60))
Stamina:SetText(stam.."h "..stam2.."m")
if Self.Stamina() <= 2400 then
Stamina:SetTextColor(210, 105, 30)
elseif Self.Stamina() <= 840 then
Stamina:SetTextColor(255, 0, 0)
end
end)
-- Check NPC
local noNPC = true
local spectators = Self.GetSpectators()
for _, cid in ipairs(spectators) do
if cid:isNpc() then
noNPC = false
break
end
end
-- Count
local DepotPos = {}
for i = 1, #DepotIDs do
local dps = Map.GetUseItems(DepotIDs[i])
for j = 1, #dps do
table.insert(DepotPos, dps[j])
end
end
local MainC = Container.GetFirst()
if tostring(#DepotPos) == '0' and MainC:isOpen() and noNPC then
HUD.CountLoot() -- Count Loot
HUD.CountWaste() -- Count Waste
end
-- Experience
Experience:SetText(Self.Experience() - ExperienceStart)
-- Profit
local Profit = Looted - Wasted
if Profit < 0 then
HUDProfit:SetText("Loss:")
Profit = math.abs(Profit)
else
HUDProfit:SetText("Profit:")
end
TotalProfit:SetText(Profit .. " gp" .. " (" .. (math.floor(Profit / (TimeDifference/3600))) .. " gp/h)")
module:Delay(1000)
end
end)