Item Adder

What is it?

- It is a Script that allows certain ranks to input a item id into a npc and get that item back in return.
- It logs the transaction with details of the character/account/time/item/date.

Cool, Can I use it for players?

Sure, you can just remove the requirement out of the script or change the rank requirement from a & az to a custom rank such as g for example which could be a VIP rank on your server.





The SQL: *You need this to log the transactions!

Code:
SET FOREIGN_KEY_CHECKS=0;
DROP TABLE IF EXISTS `item_logs`;
CREATE TABLE `item_logs` (
  `Entry` int(10) unsigned NOT NULL auto_increment COMMENT 'Unique ID',
  `Character` text collate latin1_general_ci,
  `Account` text collate latin1_general_ci,
  `Rank` text collate latin1_general_ci,
  `Item ID` decimal(10,0) default NULL,
  `Date` date default NULL,
  `Time` time default NULL,
  PRIMARY KEY  (`Entry`)
) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

The Script:
Lua | local NPC_ID = 90000 functi - Ground Zero - xLzE5g86 - Pastebin.com

OR



Code:
local NPC_ID = 90000

function NPC_OnGossipTalk(pUnit, event, player)
    pUnit:GossipCreateMenu(1, player, 1)
    pUnit:GossipMenuAddItem(1, "Claim a Item.", 1, 1)
    pUnit:GossipMenuAddItem(1, "Nevermind.", 2, 0)
    pUnit:GossipSendMenu(player)
end

function NPC_OnGossipSelect(pUnit, event, player, id, intid, code, pMisc)
    if(intid == 1) then
        if (player:GetGmRank() ==  'a') or (player:GetGmRank() ==  'az') then
            local select = WorldDBQuery("SELECT * FROM items WHERE entry = "..code.."")
            local PlayerName = player:GetName()
            local AccountName = player:GetAccountName()
            local Rank = player:GetGmRank()
            if(select == NULL) then
                player:SendBroadcastMessage("|cFFFF0000[NOTICE]:|r This item doesn't exist!")
                player:GossipComplete()
                else
                player:AddItem(code, 1)
                player:SendBroadcastMessage("|cFFFF0000[NOTICE]:|r You have recieved Item ID "..code.." and this transaction has been logged to the database.")
                WorldDBQuery("INSERT INTO item_logs (`Entry`, `Character`, `Account`, `Rank`, `Item ID`, `Date`, `Time`) VALUES ('0', '"..PlayerName.."', '"..AccountName.."', '"..Rank.."', '"..code.."','"..os.date("%X").."', '"..os.date("%x").."');")
                player:GossipComplete()
            end
        else
        player:SendBroadcastMessage("|cFFFF0000[NOTICE]:|r You need to be a <GM> or <Admin> to use this Feature!")
        end
    end
    
    if(intid == 2) then
    player:GossipComplete()
    end
end

RegisterUnitGossipEvent(NPC_ID, 1, "NPC_OnGossipTalk")
RegisterUnitGossipEvent(NPC_ID, 2, "NPC_OnGossipSelect")


Enjoy.

Thanks to pedobear (stoneharry) for fixing sql fails.

MAIN CREDITS To : GroundZero



› See More: [Lua] Item Adder & Logging System