It isn't working at all..
Right now i'm in Orgrimmar at the General Goods vendor Trak'gen trying to get it to buy Razor Arrows level 25
I go to the vendor & talk but it does no buying..
I changed true to false in the .lua & didn't mess with anything else..but here is my .lua so you can see incase I deleted an extra space or period or something stupid..
--[[
cRefillAmmo
Copyright (c) 2008, Chimaine of EU-Blackrock
All rights reserved.
]]
if select(2, UnitClass("player")) ~= "HUNTER" then
return DisableAddOn("cRefillAmmo")
end
cRefillAmmo = CreateFrame("Frame")
cRefillAmmo:Hide()
-------------------------------------------------------
-- Config
-------------------------------------------------------
CRA_CFG = {
confirm = false, -- If true, will show a confirmation dialoge before refilling.
}
-------------------------------------------------------
-- do not edit from here on!
-------------------------------------------------------
local ammoBag, fAmmoSlots
-------------------------------------------------------
-- Utility functions
-------------------------------------------------------
local function print(text)
if text == nil then text = "" end
DEFAULT_CHAT_FRAME:AddMessage("|cff7696bc c|rRefillAmmo: ".. text)
end
local function FindAmmoBag()
for i = 0, NUM_BAG_SLOTS do
local freeSlots, bagType = GetContainerNumFreeSlots(i)
if freeSlots > 0 and bit.band(0x0003, bagType) > 0 then
return i, freeSlots
end
end
end
local function GetPAmmoInfo()
local ammoLink = GetInventoryItemLink("player", GetInventorySlotInfo("AmmoSlot"))
local ammoName = GetItemInfo(ammoLink)
return ammoName, ammoLink
end
local function MerchantHasAmmo()
local pAmmoName, pAmmoLink = GetPAmmoInfo()
for i = 1, GetMerchantNumItems() do
local mAmmoName = GetMerchantItemInfo(i)
if mAmmoName == pAmmoName then
return i
end
end
end
local function BuyAmmo(mSlot)
if not mSlot then
mSlot = MerchantHasAmmo()
end
for i = 1, fAmmoSlots do
BuyMerchantItem(mSlot)
end
ammoBag, fAmmoSlots = nil, nil
end
-------------------------------------------------------
-- Handler
-------------------------------------------------------
function cRefillAmmo:MERCHANT_SHOW()
ammoBag, fAmmoSlots = FindAmmoBag()
if CRA_CFG.confirm == true then
StaticPopupDialogs["CREFILLAMMO_MERCHANT1"].text = "|cff7696bc c|rRefill "..select(2,GetPAmmoInfo()).."?"
end
if ammoBag and fAmmoSlots ~= 0 then
local hasAmmo = MerchantHasAmmo()
if hasAmmo then
if CRA_CFG.confirm then
StaticPopup_Show("CREFILLAMMO_MERCHANT1")
elseif CRA_CFG.confirm then
BuyAmmo(hasAmmo)
end
end
else
ammoBag, fAmmoSlots = nil, nil
end
end
-------------------------------------------------------
-- Popup
-------------------------------------------------------
if CRA_CFG.confirm == true then
StaticPopupDialogs["CREFILLAMMO_MERCHANT1"] = {
text = "|cff7696bc c|rRefill?",
button1 = ACCEPT,
button2 = CANCEL,
OnAccept = function() BuyAmmo() end,
timeout = 0,
whileDead = 0,
hideOnEscape = 1
}
end
-------------------------------------------------------
-- Events/Scripts
-------------------------------------------------------
cRefillAmmo:RegisterEvent("MERCHANT_SHOW")
cRefillAmmo:SetScript("OnEvent", function(self, event)
self[event](self)
end) |