Перейти к содержанию

Дайджесты за январь-февраль

Обновления гайдов и аддонов

Январь Февраль

Мониторинг серверов и редактор аддонов

Представляем вам две легенды. То, о чем можно было только мечтать, стало реальностью.

Мониторинг серверов Редактор аддонов

Подсказки из игры на вашем сайте

Теперь вы можете отображать сведения о внутриигровых элементах простым наведением курсора мыши.

Подробнее

Апдейтер аддонов

Представляем вам программу для автообновления аддонов и делимся подробностями.

Подробнее Скачать

Need help about Sniper Addon


Гость Amphetamine

Рекомендуемые сообщения

Hey guys ;

I take this error :

Error: addon Sniper: Error while running the chunk

Error: addon Sniper: [string "mods/addons/sniper/scripts/sniper.lua"] :96: attempt to perform arithmetic on field `?' (a nil value)

Error: addon Sniper: func: ?, ?, line: -1, defined: C, line: -1, [c]

Error: addon Sniper: func: TrackEnvironment, global, line: 96, defined: Lua, line: 50, [string "mods/addons/sniper/scripts/sniper.lua"]

Thats my addons documents ;

Global("wtMainPanel", nil)

Global("wtPlayerList_Name", nil)

Global("wtPlayerList_Level", nil)

Global("wtPlayerList_Health", nil)

Global("wtButtonSelector", nil)

Global( "wtTotHealth", nil )

Global("wtPlayerList_Names", {})

Global("wtPlayerList_Levels", {})

Global("wtPlayerList_Healths", {})

Global("wtButtonSelectors", {})

Global( "wtTotHealths", {})

Global("wtMainPanelDNDId", 834)

Global("unitList", {})

Global("unitCount", 0)

Global("bExecLock", false)

Global("bUIToggleVisible", true)

Global('PLAYERLIST_MAX_ROWS', 7)

Global('PLAYERLIST_ROW_HEIGHT', 20)

Global('PLAYERLIST_PRIORITY_FLAGGED', 100)

Global('PLAYERLIST_PRIORITY_CLASSES', {

["druid"] = 100,

["mage"] = 100,

["necromancer"] = 100,

["paladin"] = 100,

["priest"] = 105,

["psionic"] = 100,

["stalker"] = 100,

["warrior"] = 100

})

Global("ClassColors", {

["warrior"] = { r = 0.65; g = 0.54; b = 0.34; a = 1 },

["paladin"] = { r = 0.00; g = 0.88; b = 0.78; a = 1 },

["mage"] = { r = 0.18; g = 0.57; b = 1.00; a = 1 },

["druid"] = { r = 1.00; g = 0.50; b = 0.00; a = 1 },

["psionic"] = { r = 1.00; g = 0.50; b = 1.00; a = 1 },

["stalker"] = { r = 0.00; g = 0.78; b = 0.00; a = 1 },

["priest"] = { r = 1.00; g = 1.00; b = 0.31; a = 1 },

["necromancer"] = { r = 0.95; g = 0.17; b = 0.28; a = 1 }

})

function TrackEnvironment(event)

if bExecLock or not bUIToggleVisible then

return

end

bExecLock = true

local detectedUnits = avatar.GetUnitList()

local i = 1

unitList = {}

for key, unitId in detectedUnits do

-- Check if unit is player and not dead

if unit.IsPlayer(unitId) and not object.IsDead(unitId) then

local faction = unit.GetFaction(unitId)

-- Check if player belongs to opposite faction

if not faction.isFriend or (not raid.IsPlayerInAvatarsRaid(object.GetName(unitId)) and unit.GetZonePvPType(avatar.GetId())==0) then

local fow = unit.GetPvPFlagInfo(unitId)

local unitClass = unit.GetClass(unitId)

local unitFlagged = 0

local unitHPP = unit.GetHealthPercentage(unitId)

local unitKiller = 0

local unitRWNDS = unit.GetRelativeWoundsComplexity(unitId)

local unitCURSE = unit.GetRuneWoundsComplexity(unitId)

local unitDONAT = 0

if unitCURSE > 0 then

unitDONAT = unitCURSE * 10

end

if unitHPP < 100 then

unitKiller = (100 - unitHPP) * 200

end

if fow.isOn then

unitFlagged = PLAYERLIST_PRIORITY_FLAGGED * 125

end

unitList = {}

unitList.id = unitId

unitList.priority = (PLAYERLIST_PRIORITY_CLASSES[unitclass.classname]) + unitFlagged + unitKiller + unitRWNDS + unitDONAT

unitList.flagged = fow.isOn

i = i + 1

end

end

end

unitCount = i - 1

detectedUnits = nil

ClearPlayerList()

if unitCount > 0 then

CreatePlayerList()

wtMainPanel:Show(true)

else

wtMainPanel:Show(false)

end

bExecLock = false

end

function CreatePlayerList()

table.sort(unitList, function(a, B) return a.priority > b.priority end)

for i = 1, unitCount do

local unitId = unitList.id

wtPlayerList_Names = mainForm:CreateWidgetByDesc(wtPlayerList_Name:GetWidgetDesc())

wtPlayerList_Names:SetName("PlayerList_Name"..i)

wtPlayerList_Names:SetVal("Name", object.GetName(unitId))

if unitList.flagged then

wtPlayerList_Names:SetClassVal("class", "tip_red")

else

wtPlayerList_Names:SetClassVal("class", "tip_white")

end

local place = wtPlayerList_Names:GetPlacementPlain()

place.posY = PLAYERLIST_ROW_HEIGHT * i;

wtPlayerList_Names:SetPlacementPlain(place)

wtPlayerList_Levels = mainForm:CreateWidgetByDesc(wtPlayerList_Level:GetWidgetDesc())

wtPlayerList_Levels:SetName("PlayerList_Level"..i)

wtPlayerList_Levels:SetVal("Level", common.FormatInt(unit.GetLevel(unitId), "%d"))

wtPlayerList_Levels:SetClassVal("class", "tip_white")

local place = wtPlayerList_Levels:GetPlacementPlain()

place.posY = PLAYERLIST_ROW_HEIGHT * i;

wtPlayerList_Levels:SetPlacementPlain(place)

wtPlayerList_Healths = mainForm:CreateWidgetByDesc(wtPlayerList_Health:GetWidgetDesc())

wtPlayerList_Healths:SetName("PlayerList_Health"..i)

--local unitHP = unit.GetHealthPercentage(unitId)

--local unitHP = unit.GetRuneWoundsComplexity(unitId)

local unitWND = unit.GetRelativeWoundsComplexity(unitId)

--wtPlayerList_Healths:SetVal("Health", common.FormatInt(unitHP, "%d"))

--Would be good to add total value of enemy runes, currently I don't think it is possible.

wtPlayerList_Healths:SetVal("Health", common.FormatInt(unitWND, "%d" ))

wtPlayerList_Healths:SetClassVal("class", "tip_white")

--Maybe will add it later, now to much coloring.

--if unitHP > 40 then

--wtPlayerList_Healths:SetClassVal("class", "tip_red")

--elseif unitHP <= 40 and unitHP > 20 then

--wtPlayerList_Healths:SetClassVal("class", "tip_yellow")

--elseif unitHP <= 20 then

--wtPlayerList_Healths:SetClassVal("class", "tip_green")

--end

local place = wtPlayerList_Healths:GetPlacementPlain()

place.posY = PLAYERLIST_ROW_HEIGHT * i;

wtPlayerList_Healths:SetPlacementPlain(place)

wtButtonSelectors = mainForm:CreateWidgetByDesc(wtButtonSelector:GetWidgetDesc())

wtButtonSelectors:SetName("ButtonSelector_"..i)

local place = wtButtonSelectors:GetPlacementPlain()

place.posY = PLAYERLIST_ROW_HEIGHT * i;

wtButtonSelectors:SetPlacementPlain(place)

local place

local Percentage

local PlayerClass

wtTotHealths = mainForm:CreateWidgetByDesc(wtTotHealth:GetWidgetDesc())

Percentage = unit.GetHealthPercentage(unitId)

PlayerClass = unit.GetClass(unitId)

if Percentage ~= nil then

place = wtTotHealths:GetPlacementPlain()

place.posY = PLAYERLIST_ROW_HEIGHT * i;

place.sizeX = math.ceil( 175 * Percentage / 100 ) -- Health bar width, px = 86

wtTotHealths:SetBackgroundColor( ClassColors[playerclass.classname] )

wtTotHealths:SetPlacementPlain(place)

end

wtMainPanel:AddChild(wtPlayerList_Names)

wtMainPanel:AddChild(wtPlayerList_Levels)

wtMainPanel:AddChild(wtPlayerList_Healths)

wtMainPanel:AddChild(wtButtonSelectors)

wtMainPanel:AddChild(wtTotHealths)

if i >= PLAYERLIST_MAX_ROWS then

break

end

end

end

function ClearPlayerList()

if wtPlayerList_Names then

for i, w in wtPlayerList_Names do

wtPlayerList_Names:DestroyWidget()

wtPlayerList_Levels:DestroyWidget()

wtPlayerList_Healths:DestroyWidget()

wtTotHealths:DestroyWidget()

wtButtonSelectors:DestroyWidget()

end

end

end

function ReactionSelectTarget(params)

local senderIndex = tonumber(string.sub(params.sender, string.len("ButtonSelector_") + 1))

if senderIndex then

avatar.SelectTarget(unitList[senderindex].id)

end

end

function MemRequestHandler(params)

userMods.SendEvent("U_EVENT_ADDON_MEM_USAGE_RESPONSE", {sender = common.GetAddonName(), memUsage = gcinfo()})

end

function ToggleDNDHandler(params)

if params.target == common.GetAddonName() then

DnD:Enable(wtMainPanel, params.state)

end

end

function ToggleUIHandler(params)

bUIToggleVisible = params.visible

mainForm:Show( params.visible )

end

function Init()

common.RegisterReactionHandler(ReactionSelectTarget, "SelectTarget")

common.RegisterEventHandler(TrackEnvironment, "EVENT_SECOND_TIMER")

common.RegisterEventHandler(MemRequestHandler, "U_EVENT_ADDON_MEM_USAGE_REQUEST")

common.RegisterEventHandler(ToggleDNDHandler, "U_EVENT_TOGGLE_DND")

common.RegisterEventHandler(ToggleUIHandler, "SCRIPT_TOGGLE_UI")

wtMainPanel = mainForm:GetChildChecked("MainPanel", false)

wtPlayerList_Name = wtMainPanel:GetChildChecked("PlayerList_Name", false)

wtPlayerList_Level = wtMainPanel:GetChildChecked("PlayerList_Level", false)

wtPlayerList_Health = wtMainPanel:GetChildChecked("PlayerList_Health", false)

wtButtonSelector = wtMainPanel:GetChildChecked("ButtonSelector", false)

wtTotHealth = wtMainPanel:GetChildChecked( "TotHealth", false )

DnD:Init(wtMainPanelDNDId, wtMainPanel, wtMainPanel, true, true, {-8,-8,-8,-8})

wtPlayerList_Name:Show(false)

wtPlayerList_Level:Show(false)

wtPlayerList_Health:Show(false)

wtButtonSelector:Show(false)

wtTotHealth:Show(false)

wtMainPanel:Show(false)

local place = wtMainPanel:GetPlacementPlain()

place.sizeY = PLAYERLIST_ROW_HEIGHT * PLAYERLIST_MAX_ROWS + 36;

wtMainPanel:SetPlacementPlain(place)

end

Init()

How i can fix that ?

Thanks anyways xoxo.

Ссылка на комментарий
Поделиться на другие сайты

Гость
Ответить в этой теме...

×   Вставлено с форматированием.   Восстановить форматирование

  Разрешено использовать не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Отображать как обычную ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.

×
×
  • Создать...

Важная информация

Пользуясь сайтом, вы принимаете Условия использования