Advertisement
Guest User

query add item to npc

a guest
Jul 17th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.85 KB | None | 0 0
  1. /****query add item npc edited by mohamed hasan***/
  2. USE SRO_VT_SHARD
  3. GO
  4. DECLARE @ID int
  5. DECLARE @INDEX int
  6. DECLARE @CodeName varchar(128)
  7. DECLARE @PackageName varchar(128)
  8. DECLARE @DescSTRID varchar(128)
  9. DECLARE @File varchar(128)
  10. DECLARE @Price int
  11. DECLARE @SilkPrice int
  12. DECLARE @Gcoin int
  13. DECLARE @Scoin int
  14. DECLARE @Icoin int
  15. DECLARE @Ccoin int
  16. DECLARE @Acoin int
  17. DECLARE @Optlvl int
  18. DECLARE @Slot tinyint
  19. DECLARE @TAB varchar(128)
  20. DECLARE @Data int
  21. DECLARE @SkipScrapOfPackageItem int = 0
  22. DECLARE @SkipPackageItem int = 0
  23. DECLARE @SkipPricePolicyOfItem int = 0
  24. --- Set Variables
  25. SET @CodeName = 'ITEM_CH_NECKLACE_11_A_RARE' -- Item CodeName in RefObjCommon
  26. SET @Price = 1 -- Set 0 if you don't want to set Gold Price
  27. SET @SilkPrice = 0 -- Set 0 if you don't want to set Silk Price
  28. SET @Gcoin = 0 -- Set 0 if you don't want to set Gold Coin Price
  29. SET @Scoin = 0 -- Set 0 if you don't want to set Silver Coin Price
  30. SET @Icoin = 0 -- set 0 if you don't want to set Iron Coin Price
  31. SET @Ccoin = 0 -- set 0 if you don't want to set Copper Coin Price
  32. SET @Acoin = 0 -- set 0 if you don't want to set Arena Coin Price
  33. SET @Optlvl = 5 -- Item Plus in npc Set 0 if you don't want plus for any item
  34. SET @TAB = 'STORE_CH_NOVA_SET_SELLER_TAB7' -- Tab name in NPC, For _RefShopGoods
  35. SET @PackageName = 'PACKAGE_'+@CodeName -- Do not edit if you don't know what are you doing.
  36. --- you don't need to touch here...
  37. IF (@CodeName = '')
  38. BEGIN
  39. PRINT 'You have to edit CodeName..!'
  40. PRINT 'FAILED.'
  41. RETURN
  42. END
  43. IF ((SELECT COUNT(ID) FROM _RefObjCommon WHERE CodeName128 = @CodeName) < 1)
  44. BEGIN
  45. PRINT 'There is no item with this CodeName..!'
  46. PRINT 'FAILED.'
  47. RETURN
  48. END
  49. IF (@Price < 0)
  50. BEGIN
  51. PRINT 'Price is not VALID..!'
  52. PRINT 'FAILED.'
  53. RETURN
  54. END
  55. IF (@SilkPrice < 0)
  56. BEGIN
  57. PRINT 'Silk Price is not VALID..!'
  58. PRINT 'FAILED.'
  59. RETURN
  60. END
  61. IF ((SELECT COUNT(ID) FROM _RefShopTab WHERE CodeName128 = @TAB) < 1)
  62. BEGIN
  63. PRINT 'TAB VALUE IS NOT VALID..!'
  64. PRINT 'FAILED.'
  65. RETURN
  66. END
  67. IF ((SELECT COUNT (RefPackageItemCodeName) FROM _RefShopGoods WHERE RefPackageItemCodeName = @PackageName AND RefTabCodeName = @TAB) > 0)
  68. BEGIN
  69. PRINT 'There is already same item in same tab..!'
  70. PRINT 'FAILED.'
  71. RETURN
  72. END
  73. IF ((SELECT COUNT (RefPackageItemCodeName) FROM _RefScrapOfPackageItem WHERE RefPackageItemCodeName = @PackageName) > 0)
  74. BEGIN
  75. PRINT 'There is already an entry for this item, skipping @_RefScrapOfPackageItem table..!'
  76. SET @SkipScrapOfPackageItem = 1
  77. END
  78. IF ((SELECT COUNT (CodeName128) FROM _RefPackageItem WHERE CodeName128 = @PackageName) > 0)
  79. BEGIN
  80. PRINT 'There is already an entry for this item, skipping @_RefPackageItem table..!'
  81. SET @SkipPackageItem = 1
  82. END
  83. IF ((SELECT COUNT (PaymentDevice) FROM _RefPricePolicyOfItem WHERE RefPackageItemCodeName = @PackageName AND PaymentDevice = '1') > 0)
  84. BEGIN
  85. PRINT 'There is already an entry for this item with same PaymentDevice, skipping @_RefPricePolicyOfItem table..! (Gold)'
  86. SET @SkipPricePolicyOfItem = 1
  87. END
  88. IF ((SELECT COUNT (PaymentDevice) FROM _RefPricePolicyOfItem WHERE RefPackageItemCodeName = @PackageName AND PaymentDevice = '2') > 0)
  89. BEGIN
  90. PRINT 'There is already an entry for this item with same PaymentDevice, skipping @_RefPricePolicyOfItem table..! (Silk)'
  91. IF (@SkipPricePolicyOfItem = 1)
  92. BEGIN
  93. SET @SkipPricePolicyOfItem = 3
  94. END
  95. ELSE
  96. BEGIN
  97. SET @SkipPricePolicyOfItem = 2
  98. END
  99. END
  100. IF (@SilkPrice = 0) AND (@Price = 0)
  101. BEGIN
  102. PRINT 'You need to set a price, at least one !'
  103. PRINT 'FAILED.'
  104. RETURN
  105. END
  106. SELECT TOP 1 @ID = ID FROM _RefPackageItem ORDER BY ID DESC
  107. SET @ID = @ID + 1
  108. SELECT TOP 1 @INDEX = [Index] FROM _RefScrapOfPackageItem ORDER BY [Index] DESC
  109. SET @INDEX = @INDEX + 1
  110. SELECT TOP 1 @Slot = SlotIndex FROM _RefShopGoods WHERE RefTabCodeName = @TAB ORDER BY SlotIndex DESC
  111. IF (@Slot = 0)
  112. BEGIN
  113. SET @Slot = @Slot + 1
  114. END
  115. ELSE IF (@Slot > 0)
  116. BEGIN
  117. SET @Slot = @Slot + 1
  118. END
  119. ELSE
  120. BEGIN
  121. SET @Slot = 0
  122. END
  123. SET @DescSTRID = 'SN_' + @CodeName + '_TT_DESC'
  124. SELECT @File = AssocFileIcon128 FROM _RefObjCommon WHERE CodeName128 = @CodeName
  125. IF (@CodeName LIKE '%RING%' OR @CodeName LIKE '%NECKLACE%' OR @CodeName LIKE '%ARCHEMY%')
  126. BEGIN
  127. SET @Data = 1
  128. END
  129. ELSE
  130. BEGIN
  131. SELECT @Data = Dur_U FROM _RefObjItem WHERE ID = (SELECT Link FROM _RefObjCommon WHERE CodeName128 = @CodeName)
  132. END
  133. BEGIN TRANSACTION
  134. IF (@SkipPackageItem = 0)
  135. BEGIN
  136. --SET IDENTITY_INSERT _RefPackageItem ON
  137. INSERT _RefPackageItem ([Service], Country, ID, CodeName128, SaleTag, ExpandTerm, NameStrID, DescStrID, AssocFileIcon, Param1, Param1_Desc128, Param2, Param2_Desc128, Param3, Param3_Desc128, Param4, Param4_Desc128) VALUES (1, 15, @ID, @PackageName, 0, 'EXPAND_TERM_ALL', 'SN_'+@CodeName, @DescSTRID, @File, -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx')
  138. IF (@@ERROR <> 0)
  139. BEGIN
  140. PRINT 'AN ERROR HAPPENED WHILE ADDING TO _RefPackageItem, Rolling back...'
  141. ROLLBACK TRANSACTION
  142. RETURN
  143. END
  144. PRINT 'Added to _RefPackageItem !'
  145. --SET IDENTITY_INSERT _RefPackageItem OFF
  146. END
  147. IF (@SkipScrapOfPackageItem = 0)
  148. BEGIN
  149. INSERT _RefScrapOfPackageItem (Service, Country, RefPackageItemCodeName, RefItemCodeName, OptLevel, Variance, Data, MagParamNum, MagParam1, MagParam2, MagParam3, MagParam4, MagParam5, MagParam6, MagParam7, MagParam8, MagParam9, MagParam10, MagParam11, MagParam12, Param1, Param1_Desc128, Param2, Param2_Desc128, Param3, Param3_Desc128, Param4, Param4_Desc128, [Index]) VALUES (1, 15, @PackageName, @CodeName, @Optlvl, 0, @Data, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', @INDEX)
  150. IF (@@ERROR <> 0)
  151. BEGIN
  152. PRINT 'AN ERROR HAPPENED WHILE ADDING TO _RefScrapOfPackageItem, Rolling back...'
  153. ROLLBACK TRANSACTION
  154. RETURN
  155. END
  156. PRINT 'Added to _RefScrapOfPackageItem !'
  157. END
  158. /**Gold Price***/
  159. IF (@SkipPricePolicyOfItem = 2 OR @SkipPricePolicyOfItem = 0 AND @Price > 0)
  160. BEGIN
  161. INSERT _RefPricePolicyOfItem (Service, Country, RefPackageItemCodeName, PaymentDevice, PreviousCost, Cost, Param1, Param1_Desc128, Param2, Param2_Desc128, Param3, Param3_Desc128, Param4, Param4_Desc128) VALUES (1, 15, @PackageName, 1, 0, @Price, -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx')
  162. IF (@@ERROR <> 0)
  163. BEGIN
  164. PRINT 'AN ERROR HAPPENED WHILE ADDING TO _RefPricePolicyOfItem, Rolling back...'
  165. ROLLBACK TRANSACTION
  166. RETURN
  167. END
  168. PRINT 'Added to _RefPricePolicyOfItem, PaymentDevice = 1 (Gold)'
  169. END
  170. /*** Silk Price **/
  171. IF (@SkipPricePolicyOfItem = 1 OR @SkipPricePolicyOfItem = 0 AND @SilkPrice > 0)
  172. BEGIN
  173. INSERT _RefPricePolicyOfItem (Service, Country, RefPackageItemCodeName, PaymentDevice, PreviousCost, Cost, Param1, Param1_Desc128, Param2, Param2_Desc128, Param3, Param3_Desc128, Param4, Param4_Desc128) VALUES (1, 15, @PackageName, 2, 0, @SilkPrice, -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx')
  174. IF (@@ERROR <> 0)
  175. BEGIN
  176. PRINT 'AN ERROR HAPPENED WHILE ADDING TO _RefPricePolicyOfItem, Rolling back...'
  177. ROLLBACK TRANSACTION
  178. RETURN
  179. END
  180. PRINT 'Added to _RefPricePolicyOfItem, PaymentDevice = 2 (Silk)'
  181. END
  182. ELSE
  183. BEGIN
  184. PRINT 'There is already silk / gold price, skipping _RefPricePolicyOfItem table...'
  185. END
  186. /*****Gold Coin***/
  187. IF (@SkipPricePolicyOfItem = 1 OR @SkipPricePolicyOfItem = 0 AND @Gcoin > 0)
  188. BEGIN
  189. INSERT _RefPricePolicyOfItem (Service, Country, RefPackageItemCodeName, PaymentDevice, PreviousCost, Cost, Param1, Param1_Desc128, Param2, Param2_Desc128, Param3, Param3_Desc128, Param4, Param4_Desc128) VALUES (1, 15, @PackageName, 512, 0, @Gcoin, -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx')
  190. IF (@@ERROR <> 0)
  191. BEGIN
  192. PRINT 'AN ERROR HAPPENED WHILE ADDING TO _RefPricePolicyOfItem, Rolling back...'
  193. ROLLBACK TRANSACTION
  194. RETURN
  195. END
  196. PRINT 'Added to _RefPricePolicyOfItem, PaymentDevice = 512 (Gold Coin)'
  197. END
  198. ELSE
  199. BEGIN
  200. PRINT 'There is already silk / gold price, skipping _RefPricePolicyOfItem table...'
  201. END
  202. /***Silver Coin***/
  203. IF (@SkipPricePolicyOfItem = 1 OR @SkipPricePolicyOfItem = 0 AND @Scoin > 0)
  204. BEGIN
  205. INSERT _RefPricePolicyOfItem (Service, Country, RefPackageItemCodeName, PaymentDevice, PreviousCost, Cost, Param1, Param1_Desc128, Param2, Param2_Desc128, Param3, Param3_Desc128, Param4, Param4_Desc128) VALUES (1, 15, @PackageName, 256, 0, @Scoin, -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx')
  206. IF (@@ERROR <> 0)
  207. BEGIN
  208. PRINT 'AN ERROR HAPPENED WHILE ADDING TO _RefPricePolicyOfItem, Rolling back...'
  209. ROLLBACK TRANSACTION
  210. RETURN
  211. END
  212. PRINT 'Added to _RefPricePolicyOfItem, PaymentDevice = 256 (Silver Coin)'
  213. END
  214. ELSE
  215. BEGIN
  216. PRINT 'There is already silk / gold price, skipping _RefPricePolicyOfItem table...'
  217. END
  218. /****Iron Coin****/
  219. IF (@SkipPricePolicyOfItem = 1 OR @SkipPricePolicyOfItem = 0 AND @Icoin > 0)
  220. BEGIN
  221. INSERT _RefPricePolicyOfItem (Service, Country, RefPackageItemCodeName, PaymentDevice, PreviousCost, Cost, Param1, Param1_Desc128, Param2, Param2_Desc128, Param3, Param3_Desc128, Param4, Param4_Desc128) VALUES (1, 15, @PackageName, 128, 0, @Icoin, -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx')
  222. IF (@@ERROR <> 0)
  223. BEGIN
  224. PRINT 'AN ERROR HAPPENED WHILE ADDING TO _RefPricePolicyOfItem, Rolling back...'
  225. ROLLBACK TRANSACTION
  226. RETURN
  227. END
  228. PRINT 'Added to _RefPricePolicyOfItem, PaymentDevice = 128 (Iron Coin)'
  229. END
  230. ELSE
  231. BEGIN
  232. PRINT 'There is already silk / gold price, skipping _RefPricePolicyOfItem table...'
  233. END
  234. /****Copper Coin**/
  235. IF (@SkipPricePolicyOfItem = 1 OR @SkipPricePolicyOfItem = 0 AND @Ccoin > 0)
  236. BEGIN
  237. INSERT _RefPricePolicyOfItem (Service, Country, RefPackageItemCodeName, PaymentDevice, PreviousCost, Cost, Param1, Param1_Desc128, Param2, Param2_Desc128, Param3, Param3_Desc128, Param4, Param4_Desc128) VALUES (1, 15, @PackageName, 64, 0, @Ccoin, -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx')
  238. IF (@@ERROR <> 0)
  239. BEGIN
  240. PRINT 'AN ERROR HAPPENED WHILE ADDING TO _RefPricePolicyOfItem, Rolling back...'
  241. ROLLBACK TRANSACTION
  242. RETURN
  243. END
  244. PRINT 'Added to _RefPricePolicyOfItem, PaymentDevice = 64 (Copper Coin)'
  245. END
  246. ELSE
  247. BEGIN
  248. PRINT 'There is already silk / gold price, skipping _RefPricePolicyOfItem table...'
  249. END
  250. /****Arena Coin***/
  251. IF (@SkipPricePolicyOfItem = 1 OR @SkipPricePolicyOfItem = 0 AND @Acoin > 0)
  252. BEGIN
  253. INSERT _RefPricePolicyOfItem (Service, Country, RefPackageItemCodeName, PaymentDevice, PreviousCost, Cost, Param1, Param1_Desc128, Param2, Param2_Desc128, Param3, Param3_Desc128, Param4, Param4_Desc128) VALUES (1, 15, @PackageName, 1024, 0, @Acoin, -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx')
  254. IF (@@ERROR <> 0)
  255. BEGIN
  256. PRINT 'AN ERROR HAPPENED WHILE ADDING TO _RefPricePolicyOfItem, Rolling back...'
  257. ROLLBACK TRANSACTION
  258. RETURN
  259. END
  260. PRINT 'Added to _RefPricePolicyOfItem, PaymentDevice = 1024 (Arena Coin)'
  261. END
  262. ELSE
  263. BEGIN
  264. PRINT 'There is already silk / gold price, skipping _RefPricePolicyOfItem table...'
  265. END
  266. /************** End Prices ***************/
  267. INSERT _RefShopGoods (Service, Country, RefTabCodeName, RefPackageItemCodeName, SlotIndex, Param1, Param1_Desc128, Param2, Param2_Desc128, Param3, Param3_Desc128, Param4, Param4_Desc128) VALUES (1, 15, @TAB, @PackageName, @Slot, -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx')
  268. IF (@@ERROR <> 0)
  269. BEGIN
  270. PRINT 'An error happened while adding to _RefShopGoods table'
  271. PRINT 'FAILED.'
  272. ROLLBACK TRANSACTION
  273. RETURN
  274. END
  275. PRINT 'Added to _RefShopGoods, DONE!'
  276. COMMIT TRANSACTION
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement