Jump to content

Digest Jan-Feb

We talk about what was done and updated in the past month. We help keep abreast of events.

January February

Servers monitoring and the Addons Editor

We present you two legends. All dreams come true.

Servers monitoring The Addons Editor

Game tooltips

Tooltips provide a way for 3rd party fansites and extensions to display detailed information on mouseover.

Read more

The Addons Updater

Let us to introduce the addons updating software and to share the details

Read more Download

Need help about Sniper Addon


Guest Amphetamine

Recommended Posts

Guest 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.

Link to comment
Share on other sites

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using our site you agree to the Terms of Use