1. #1

    Help with addon code fixing

    Hi there, I recently made a post asking for suggestion for good Loot Master Addon as a replacement for Mater Looter Manager Remix which was the greatest addon I have ever seen for that purpouse.

    Thing is that nobody was able to suggest me one and I found only lame replacements.

    So I decided to look into the code and debug a little the addon.

    What I found out was that the addon is not able to award the loot to the players which are not from the same realm as Master Looter. I suppose there is a mistake in code (it was abadoned 2 years ago so yeah) that list names of players who /roll and then tries to award the item to the person with certain name from that list. But actually name is different since he is from different realm. So the item is not awarded in the end.

    I went into the code and found two functions which might be responsible for that and with maybe some tweaking it might work again. Sadly Im no expert on LUA and have only very basic knowladge of C++ from highschool. So I hope someone kind enough look into it and check if it can be fixed.

    String #1:
    Code:
    function MasterLootManager:AwardLootClicked(buttonFrame)
    	local itemLink = MasterLootTable:GetItemLink(self.currentItemIndex)
    	if AssignLoot(itemLink, MasterLootRolls.winningPlayer) then
    		MasterLootLogger:ProcessItem(itemLink, MasterLootRolls.winningPlayer, self.lastRollType, MasterLootRolls:GetWinningValue());
    		self:Speak(string.format(MLM_Local["Congratutlations to on winning"], MasterLootRolls.winningPlayer, itemLink))
    	end
    end

    String #2:
    Code:
    function MasterLootManager:PlayerSelectionButtonClicked(buttonFrame)
    	local buttonName = buttonFrame:GetName()
    	local playerNameLabel = getglobal(buttonName .. "_PlayerName")
    	MasterLootRolls.winningPlayer = playerNameLabel:GetText()
    	MasterLootRolls:UpdateRollList()
    end
    Im including link to the whole addon: http://wow.curseforge.com/addons/mlm-remix/

  2. #2
    Might try GetUnitName() instead of GetName() ?

    Returns the name and realm of the specified unit:

    name = GetUnitName(unit, showServerName)

    Arguments:

    ("unit", showServerName)
    unit
    Code:
    String - The UnitId to query (e.g. "player", "party2", "pet", "target" etc.)
    showServerName
    Code:
    Boolean - If true, append " - [server name]" to name if it's available or FOREIGN_SERVER_LABEL (" (*)" on enUS locale) if nil or false.
    Returns
    name
    A formatted string based on the return values of UnitName(unit).


    Two pages that may help you:
    http://www.wowwiki.com/API_GetUnitName
    http://www.wowwiki.com/API_UnitName
    Last edited by Skalm; 2014-10-20 at 04:49 PM.

  3. #3
    Well I tried to replace all strings including GetName() with GetUnitName() but when I tested it with my friend addon posted into chat that player could not be found.
    "MasterLootManger: Cannot find player - Torm"

  4. #4
    Field Marshal Concatto's Avatar
    10+ Year Old Account
    Join Date
    Dec 2013
    Location
    Auldrant
    Posts
    86
    When a player from a different realm uses "/roll", does the chat message show the player's realm? The AddOn uses that message to get the names.

  5. #5
    Basicly when the player from any realm uses /roll in the table of addon only the name appiers like on this pic: http://www.curseforge.com/media/imag...69/Default.JPG

  6. #6
    Field Marshal Concatto's Avatar
    10+ Year Old Account
    Join Date
    Dec 2013
    Location
    Auldrant
    Posts
    86
    In that case, if there's two players with the same name from different realms, it will assign the item to the first player.

    Replace the function AssignLoot (around line 150 in MasterLootManager.lua) with this:

    Code:
    local function AssignLoot(pItemLink, pPlayerName)
    	--First we need to find the item slot for the current open loot window
    	local itemSlot, itemLink
    	for itemIndex=1, GetNumLootItems() do
    		itemLink = GetLootSlotLink(itemIndex)
    		if itemLink == pItemLink then
    			itemSlot = itemIndex;
    			break
    		end
    	end
    	
    	--Damnit...
    	if itemSlot == nil then 
    		MasterLootManager:Print(string.format(MLM_Local["MasterLootManger: Cannot find item - "],pItemLink))
    		return false
    	end
    	
    	--Now find the player, as of 5.0 master loot candidates must be checked with the loot slot
    	local filteredPlayerName, separatorIndex
    	for winningPlayerIndex = 1, 40 do
    		filteredPlayerName = GetMasterLootCandidate(itemSlot, winningPlayerIndex)
    		if (filteredPlayerName == nil) then
    			break
    		end
    		separatorIndex = filteredPlayerName:find("-");
    		if (separatorIndex ~= nil) then
    			--If the player is from a different realm
    			filteredPlayerName = filteredPlayerName:sub(0, separatorIndex - 1);
    		end
    		if (filteredPlayerName == pPlayerName) then
    			GiveMasterLoot(itemSlot, winningPlayerIndex)
    			return true
    		end
    	end
    	MasterLootManager:Print(string.format(MLM_Local["MasterLootManger: Cannot find player - "],pPlayerName))
    end
    I haven't tested it, so let me know if any Lua errors happen.
    Last edited by Concatto; 2014-10-20 at 08:17 PM.

  7. #7
    Great job Concatto! I pasted your updated function into the addon and everything seems to be working as expected. Just tested it in Stockades with friend in a raid. Tomorrow evening I will be hosting SoO HC run where I'll test it heavily. So far no LUA errors.

    p.s. I did not update functions GetName() with GetUnitName()

  8. #8

    Any chance I can get a copy of this?

    Quote Originally Posted by Torm View Post
    Great job Concatto! I pasted your updated function into the addon and everything seems to be working as expected. Just tested it in Stockades with friend in a raid. Tomorrow evening I will be hosting SoO HC run where I'll test it heavily. So far no LUA errors.

    p.s. I did not update functions GetName() with GetUnitName()
    I loved this addon, was in a raid last night and used it for the first time since the server merge and was all sorts of disappointed.

    Any chance you can email me the updated addon? I have zero programming skills at this point.

    mav1369 at hotmail

    Thanks a ton!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •