slp13at420

mall vendors creator

Nov 17th, 2013
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.17 KB | None | 0 0
  1. -- vendor item table creator
  2. -- XXXXXXXXXXXXXXGXXXXXXXXXXXXXRXXXXXXXXXXXXUXXXXXXXXXMXXXXXXBXXXXOXXXXXXX
  3. -- X                 created by slp13at420 of ac-web                     X
  4. -- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  5. -- extracts item id's into a fastload sql insert file
  6. -- used for making mall vendors
  7. -- this will put ALLLLL items in db into vendors................
  8.  
  9. local Command = ".createvendor"
  10. local Class = 0
  11. local Subclass = 0
  12.  
  13. function Createvendor(event, pPlayer, msg)
  14.     if(msg == Command)then
  15.         local NpcID = 250000 -- start point for vendor ID's
  16.         local File1 = io.open("scripts/ADMIN/vendortable.sql", "w")
  17.         local File2 = io.open("scripts/ADMIN/vendor_names.sql", "w")
  18.         local File3 = io.open("scripts/ADMIN/vendor_proto.sql", "w")
  19.         File1:write("INSERT INTO `vendors`(`entry`, `item`, `amount`)Values\n\n")
  20.         File2:write("INSERT INTO `creature_names`(`entry`, `name`, `subname`, `info_str`, `male_displayid`)VALUE\n\n")
  21.         File3:write("INSERT INTO `creature_proto`(`entry`, `faction`, `scale`, `npcflags`)VALUES\n\n")
  22.  
  23.         repeat -- class
  24.             local Subclass = 0
  25.             repeat -- subclass
  26.                 local XentryID = WorldDBQuery("SELECT `entry` FROM world.items WHERE `class` = '"..Class.."' AND `subclass` = '"..Subclass.."';");
  27.                     if(XentryID~=nil)then
  28.                         repeat -- bundles into 150 count per vendor (max a vendor can show)
  29.                             local Vcount = 0
  30.                             File1:write("\n")
  31.                             File2:write("("..(NpcID)..", 'Mall Vendor', '"..tostring(Class).."x"..tostring(Subclass).."', 'Buy', 14334),\n")
  32.                             File3:write("("..(NpcID)..", 35, 1, 128),\n")
  33.                             repeat -- 150 per entries counter
  34.                                 Vcount = (Vcount+1)
  35.                                 local EntryID = XentryID:GetColumn(0):GetLong()
  36.                                 File1:write("("..NpcID..", "..tostring(EntryID)..", 1),\n")
  37.                                 until(Vcount==150)or(XentryID:NextRow()~=true)
  38.                             NpcID = (NpcID+1)
  39.                             until(XentryID:NextRow()~=true)
  40.                     end
  41.                 Subclass = (Subclass+1)
  42.                 until(Subclass==21)
  43.             Class = (Class+1)
  44.             until(Class==18)
  45.         pPlayer:SendBroadcastMessage("DONE.")  
  46.         File1:close()
  47.         File2:close()
  48.         File3:close()
  49.         return false;
  50.         end
  51. return;
  52. end
  53.    
  54. RegisterServerHook(16, "Createvendor")
Advertisement
Add Comment
Please, Sign In to add comment