Hallo Zusammen
Hier möchte ich Euch meinen Transmog NPC zur Verfügung stellen, dessen Transmoggs bleiben bestehen auch wenn Ihr Euch ausgeloggt habt.
Menü:

Habt Ihr kein Item in der Tasche bekommt Ihr eine Fehlermeldung:

Mainhand Auswahl:

Vorher:

Transmoggen:


Transmogs Entfernen:
ACHTUNG!!! Ihr könnt auch Einzelne Transmogs Entfernen wie Im (Mainhand Auswahl:) Screen zu sehen ist.




Und Hier das Script und die SQL dazu:
Display All
Diese DB Struktur müsst Ihr in Eure Char DB einfügen:
Display All
Viel Spass damit.
mfg Batida
Hier möchte ich Euch meinen Transmog NPC zur Verfügung stellen, dessen Transmoggs bleiben bestehen auch wenn Ihr Euch ausgeloggt habt.
Menü:
Habt Ihr kein Item in der Tasche bekommt Ihr eine Fehlermeldung:
Mainhand Auswahl:
Vorher:
Transmoggen:
Transmogs Entfernen:
ACHTUNG!!! Ihr könnt auch Einzelne Transmogs Entfernen wie Im (Mainhand Auswahl:) Screen zu sehen ist.
Und Hier das Script und die SQL dazu:
C Source Code: Transmogger.lua
- --[[ Scripted by Batidadekill ]]--
- local NPCENTRY = 90013 -- Your NPC's entry
- -- Warning! Executes quite some code. Delay in milliseconds. (applies transmogs)
- local DELAY = 500 -- 500 (best visual update, very low population), 1000 (good visual update, very low population), 2000+ (slow visual update, medium to high population)
- -- DO NOT TOUCH ANYTHING BELOW!
- -- Transmog table and functions.
- local Transmogs, Hello, Select, AddTransmog, RemoveTransmog, GetValidSources, LoadTransmogs, ApplyTransmogs
- -- Key0 is the key for inv_slots table, which contains the slotID. Key0 is also used for the inv_slot_names table
- local inv_slots = {0, 2, 4, 5, 6, 7, 8, 9, 14, 15, 16, 17}
- local inv_slot_names = {"|TInterface\\Icons\\inv_helmet_99.png:25|t|cffff0000>->|r|cff6666FF Kopf|cffff0000<-<|r", "|TInterface\\Icons\\inv_shoulder_63.png:25|t|cffff0000>->|r|cff6666FF Schulter|cffff0000<-<|r", "|TInterface\\Icons\\inv_chest_cloth_66.png:25|t|cffff0000>->|r|cff6666FF Brust|cffff0000<-<|r", "|TInterface\\Icons\\inv_belt_07.png:25|t|cffff0000>->|r|cff6666FF G\195\188rtel|cffff0000<-<|r", "|TInterface\\Icons\\inv_pants_cloth_27.png:25|t|cffff0000>->|r|cff6666FF Hose|cffff0000<-<|r", "|TInterface\\Icons\\inv_boots_cloth_07.png:25|t|cffff0000>->|r|cff6666FF Schuhe|cffff0000<-<|r", "|TInterface\\Icons\\inv_bracer_10.png:25|t|cffff0000>->|r|cff6666FF Handgelenke|cffff0000<-<|r", "|TInterface\\Icons\\inv_gauntlets_63.png:25|t|cffff0000>->|r|cff6666FF H\195\164nde|cffff0000<-<|r", "|TInterface\\Icons\\inv_misc_cape_naxxramas_03.png:25|t|cffff0000>->|r|cff6666FF Umhang|cffff0000<-<|r", "|TInterface\\Icons\\inv_weapon_glave_01.png:25|t|cffff0000>->|r|cff6666FF Main Hand|cffff0000<-<|r", "|TInterface\\Icons\\inv_misc_book_06.png:25|t|cffff0000>->|r|cff6666FF Off Hand|cffff0000<-<|r", "|TInterface\\Icons\\inv_weapon_bow_39.png:25|t|cffff0000>->|r|cff6666FF Ranged|cffff0000<-<|r"}
- local INV_BAG, INV_START, INV_END = 255, 1, #inv_slots
- local VISIBLE_ITEM_ENTRY_0 = 283
- local BAGS =
- {
- {BAG = INV_BAG, START = 23, END = 38},
- {BAG = 19, START = 0, END = 35},
- {BAG = 20, START = 0, END = 35},
- {BAG = 21, START = 0, END = 35},
- {BAG = 22, START = 0, END = 35},
- }
- -- bags -1 inventory and backpack, 19-22 other bags
- -- slots 0-18 equipment
- -- slots 19-22 bags
- -- slots 23-38 backpack
- -- slots 0-35 other bags
- local space = 20
- local opt_space = 100
- local opt_amount = 13 -- Warning! Do not use over 30
- local Data = {}
- function Hello(unit, event, player)
- Data[tostring(player:GetGUID())] = nil
- unit:GossipCreateMenu(100, player, 0)
- for Key0 = INV_START, INV_END do
- unit:GossipMenuAddItem(3, inv_slot_names[Key0], Key0+space, 0, "", 0)
- end
- unit:GossipMenuAddItem(4, "|cffff0000>->|rAlle Transmog's entfernen|cffff0000<-<|r", 0, 0, "Wirklich alle Transmog's entfernen?", 0)
- unit:GossipSendMenu(player)
- end
- function Select(unit, event, player, id, intid, code)
- local pGUID = tostring(player:GetGUID())
- if(intid == 0) then -- remove all transmogs
- for Key0 = INV_START, INV_END do
- RemoveTransmog(inv_slots[Key0], player)
- end
- player:SendAreaTriggerMessage("|cff00FF00Transmog's entfernt")
- Hello(unit, event, player)
- elseif(intid == 1) then
- Hello(unit, event, player)
- elseif(intid > INV_START and intid <= INV_END+1) then -- remove one transmog
- RemoveTransmog(inv_slots[intid-1], player)
- player:SendAreaTriggerMessage("|cff00FF00Transmogrification entfernt von "..inv_slot_names[intid-1])
- Select(unit, event, player, id, intid+space-1, code)
- elseif(intid >= INV_START+space and intid <= INV_END+space) then
- local Key0 = intid-space
- local sources = GetValidSources(inv_slots[Key0], player)
- if(not sources) then
- player:SendAreaTriggerMessage("|cff00FF00Du hast f\195\188r diese Aktion keine Items")
- Hello(unit, event, player)
- elseif(#sources < 2) then
- player:SendAreaTriggerMessage("|cff00FF00Kein passendes Item in der Tasche")
- Hello(unit, event, player)
- else
- Data[pGUID] = {Key0, sources}
- unit:GossipCreateMenu(100, player, 0)
- for k = 1, #sources-1 do
- unit:GossipMenuAddItem(4, sources[k]:GetName(), k+INV_END+space, 0, "", 0)
- end
- unit:GossipMenuAddItem(4, "Transmog's entfernen von "..inv_slot_names[Key0], Key0+1, 0, "Remove transmogrif ication from "..inv_slot_names[Key0].."?", 0)
- unit:GossipMenuAddItem(7, ">----> |cffff0000[<<]|rZur\195\188ck|cffff0000[>>]|r <----<..", 1, 0, "", 0)
- unit:GossipSendMenu(player)
- end
- elseif(intid > INV_END+space and intid <= INV_END+space+opt_amount) then
- local slot = inv_slots[Data[pGUID][1]]
- local target = player:GetInventoryItem(INV_BAG, slot)
- local origGUID = Data[pGUID][2][#Data[pGUID][2]] -- no cheating with swapping items on the fly
- if(target and tostring(target:GetGUID()) == origGUID) then
- local source = Data[pGUID][2][intid-INV_END-space]
- if(source and source:GetOwner():IsInWorld() and pGUID == tostring(source:GetOwner():GetGUID())) then
- AddTransmog(slot, player, source:GetEntryId())
- player:SendAreaTriggerMessage(inv_slot_names[Data[pGUID][1]].." Transmogd")
- else
- player:SendAreaTriggerMessage("|cff00FF00Item nicht in deiner Tasche")
- end
- else
- player:SendAreaTriggerMessage("|cff00FF00Ausgew\195\164hltes Item ist nicht angelegt")
- end
- Select(unit, event, player, id, Data[pGUID][1]+space, code)
- end
- end
- function AddTransmog(slot, player, fake)
- local item = player:GetInventoryItem(INV_BAG, slot)
- if (item) then
- local pGUID, iGUID = tostring(player:GetGUID()), tostring(item:GetGUID())
- player:SetUInt32Value(VISIBLE_ITEM_ENTRY_0+(slot * 2), fake)
- if (not Transmogs[pGUID]) then
- Transmogs[pGUID] = {}
- end
- if (not Transmogs[pGUID][slot]) then
- Transmogs[pGUID][slot] = {}
- end
- Transmogs[pGUID][slot][iGUID] = fake
- CharDBQuery('REPLACE INTO Transmog_items (player_GUID, item_GUID, slot, fake) VALUES ("'..pGUID..'", "'..iGUID..'", '..slot..', '..fake..')')
- return true
- end
- return false
- end
- function RemoveTransmog(slot, player)
- local pGUID = tostring(player:GetGUID())
- if (Transmogs[pGUID] and Transmogs[pGUID][slot]) then
- local item = player:GetInventoryItem(INV_BAG, slot)
- if (item) then
- local iGUID = tostring(item:GetGUID())
- if (Transmogs[pGUID][slot][iGUID]) then
- player:SetUInt32Value(VISIBLE_ITEM_ENTRY_0+(slot * 2), item:GetEntryId())
- Transmogs[pGUID][slot][iGUID] = nil
- CharDBQuery('DELETE FROM Transmog_items WHERE item_GUID = "'..iGUID..'"')
- return true
- end
- end
- end
- return false
- end
- function GetValidSources(inv_slot, player) -- returns nil or a table containing the items (can be empty)
- local item = player:GetInventoryItem(INV_BAG, inv_slot)
- if (not item) then return nil end
- local items = {}
- local entries = {}
- local hasitems = false
- for k, DATA in ipairs(BAGS) do
- if (DATA.BAG == INV_BAG or player:GetInventoryItem(INV_BAG, DATA.BAG)) then -- skip nonexistant bags
- for slot = DATA.START, DATA.END do
- local item = player:GetInventoryItem(DATA.BAG, slot)
- if(item) then
- table.insert(entries, item:GetEntryId())
- items[item:GetEntryId()] = item
- if (not hasitems) then hasitems = true end
- end
- end
- end
- end
- if (hasitems) then
- local Q = WorldDBQuery("SELECT inventorytype FROM items WHERE entry = "..item:GetEntryId())
- if (Q) then
- local Q = WorldDBQuery("SELECT entry FROM items WHERE entry IN("..table.concat(entries, ',')..") and inventorytype = "..Q:GetColumn(0):GetULong().." LIMIT "..opt_amount)
- if (Q) then
- local suitable = {}
- for i = 1, Q:GetRowCount() do
- table.insert(suitable, items[Q:GetColumn(0):GetULong()]) -- Could possibly add performance if we let this security off
- Q:NextRow()
- end
- table.insert(suitable, tostring(item:GetGUID()))
- return suitable
- end
- end
- end
- return {}
- end
- function LoadTransmogs()
- local Time = os.time()
- print("Loading transmogrifications..")
- Transmogs = {}
- -- CharDBQuery("DELETE FROM transmog_items WHERE NOT EXISTS (SELECT 1 FROM playeritems WHERE item_GUID = guid) OR NOT EXISTS (SELECT 1 FROM characters WHERE player_GUID = guid)") -- cleanup before load
- local Q = CharDBQuery("SELECT player_GUID, item_GUID, slot, fake FROM Transmog_items")
- if (Q) then
- for i = 1, Q:GetRowCount() do
- local pGUID, iGUID, slot, fake = Q:GetColumn(0):GetString(), Q:GetColumn(1):GetString(), Q:GetColumn(2):GetULong(), Q:GetColumn(3):GetULong()
- if (not Transmogs[pGUID]) then
- Transmogs[pGUID] = {}
- end
- if (not Transmogs[pGUID][slot]) then
- Transmogs[pGUID][slot] = {}
- end
- Transmogs[pGUID][slot][iGUID] = fake
- Q:NextRow()
- end
- end
- print("Transmogrifications loaded in "..(os.time()-Time).." seconds")
- end
- function ApplyTransmogs() -- minimum looping and checking
- local players = GetPlayersInWorld()
- for k, player in ipairs(players) do -- loop players
- if (player and player:IsInWorld()) then -- player exists
- local pGUID = tostring(player:GetGUID())
- if (Transmogs[pGUID]) then -- has transmogs
- for slot, Data in pairs(Transmogs[pGUID]) do -- looop transmog slots
- local item = player:GetInventoryItem(INV_BAG, slot)
- if (item) then -- has item in slot
- local iGUID = tostring(item:GetGUID())
- if(Data[iGUID]) then -- check if item has transmog saved
- player:SetUInt32Value(283+(slot * 2), Data[iGUID]) -- apply transmog
- end
- end
- end
- end
- end
- end
- end
- RegisterUnitGossipEvent(NPCENTRY, 1, Hello)
- RegisterUnitGossipEvent(NPCENTRY, 2, Select)
- LoadTransmogs()
- CreateLuaEvent(ApplyTransmogs, DELAY, 0)
Diese DB Struktur müsst Ihr in Eure Char DB einfügen:
C Source Code: transmog_items.sql
- SET FOREIGN_KEY_CHECKS=0;
- -- ----------------------------
- -- Table structure for transmog_items
- -- ----------------------------
- DROP TABLE IF EXISTS `transmog_items`;
- CREATE TABLE `transmog_items` (
- `player_GUID` text NOT NULL COMMENT 'owner guid',
- `item_GUID` text NOT NULL COMMENT 'item guid',
- `slot` int(10) unsigned NOT NULL COMMENT 'equip slot',
- `fake` int(10) unsigned NOT NULL COMMENT 'fake entry'
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='This table is used for storing the transmogrification information.\r\nDo not edit this table or it''s contents.';
Viel Spass damit.
mfg Batida
