Advertisement
Emistry

[RO] SQL Mall 1.4

Sep 13th, 2018
689
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.00 KB | None | 0 0
  1. // https://rathena.org/board/topic/107660-r-sql-mall/
  2.  
  3. - script all_in_one_shop_main -1,{
  4.  
  5. // Shop NPC Name
  6. function func_ShopTypeName {
  7. switch (getarg(0, -1)) {
  8. case IT_HEALING: return "HEALING";
  9. case IT_USABLE: return "USABLE";
  10. case IT_ETC: return "ETC";
  11. case IT_WEAPON: return "WEAPON";
  12. case IT_ARMOR: return "ARMOR";
  13. case IT_CARD: return "CARD";
  14. case IT_PETEGG: return "PETEGG";
  15. case IT_PETARMOR: return "PETARMOR";
  16. case IT_AMMO: return "AMMO";
  17. case IT_DELAYCONSUME: return "DELAYCONSUME";
  18. case IT_CASH: return "CASH";
  19. default: return "MISC";
  20. }
  21. }
  22.  
  23. // Shop NPC Sprite ID
  24. function func_ShopClassID {
  25. switch (getarg(0, -1)) {
  26. case IT_HEALING: return 4_F_KAFRA1;
  27. case IT_USABLE: return 4_F_KAFRA2;
  28. case IT_ETC: return 4_F_KAFRA3;
  29. case IT_WEAPON: return 4_F_KAFRA4;
  30. case IT_ARMOR: return 4_F_KAFRA5;
  31. case IT_CARD: return 4_F_KAFRA6;
  32. case IT_PETEGG: return 4_F_KAFRA7;
  33. case IT_PETARMOR: return 4_F_KAFRA8;
  34. case IT_AMMO: return 4_F_KAFRA9;
  35. case IT_DELAYCONSUME: return 4_F_KAFRA2;
  36. case IT_CASH: return 4_F_KAFRA1;
  37. default: return rand(4_F_KAFRA1, 4_F_KAFRA9);
  38. }
  39. }
  40.  
  41. OnInit:
  42. .is_renewal_db = 1;
  43. .max_shop_item = 100;
  44. .blacklist_item$ = "5001,5002,5003";
  45.  
  46. sleep 1000; // delays
  47. callsub(OnLoad, IT_HEALING);
  48. callsub(OnLoad, IT_USABLE);
  49. callsub(OnLoad, IT_ETC);
  50. callsub(OnLoad, IT_WEAPON);
  51. callsub(OnLoad, IT_ARMOR);
  52. callsub(OnLoad, IT_CARD);
  53. callsub(OnLoad, IT_PETEGG);
  54. callsub(OnLoad, IT_PETARMOR);
  55. callsub(OnLoad, IT_AMMO);
  56. callsub(OnLoad, IT_DELAYCONSUME);
  57. callsub(OnLoad, IT_CASH);
  58. end;
  59.  
  60. OnLoad:
  61. .@type = getarg(0, -1);
  62. .@npc = 1;
  63.  
  64. .@sql$ = "SELECT `id`, `weight`, `" + (.is_renewal_db ? "atk:matk" : "attack") + "`, `slots`, `weapon_level`, `defence`, `equip_level`, `script`, `equip_script`, `unequip_script` "
  65. + "FROM `" + (.is_renewal_db ? "item_db_re" : "item_db") + "` "
  66. + "WHERE `type` = "+.@type;
  67. if (.blacklist_item$ != "")
  68. .@sql$ = .@sql$ + " AND `id` NOT IN ("+escape_sql(.blacklist_item$)+")";
  69. .@sql$ = .@sql$ + " ORDER BY `name_english`";
  70.  
  71. .@size = query_sql(.@sql$, .@id, .@weight, .@atk, .@slot, .@weapon_level, .@defence, .@equip_level, .@script$, .@equip_script$, .@unequip_script$);
  72.  
  73. if (.@size) {
  74. .@npc_count = (.@size / .max_shop_item);
  75.  
  76. freeloop(1);
  77. do {
  78. .@x = 0;
  79.  
  80. .@npc_shop_name$ = "Shop#t_"+.@type+"_"+.@npc;
  81. if (getmapxy(.@map$, .@map_x, .@map_y, 1, .@npc_shop_name$)) {
  82. debugmes "SQL Mall - NPC not found - " + .@npc_shop_name$;
  83. }
  84. else {
  85. npcshopdelitem .@npc_shop_name$, 909;
  86.  
  87. do {
  88. .@index = (.@npc * .max_shop_item + .@x);
  89. .@total_cost = 0;
  90.  
  91. // cost calculations
  92. .@total_cost += ((.@weight[.@index] / 10) * 1000);
  93. .@total_cost += ((.@atk[.@index] / 100) * 5000);
  94. .@total_cost += (.@slots[.@index] * 3000);
  95. .@total_cost += (.@weapon_level[.@index] * 2000);
  96. .@total_cost += ((.@defence[.@index] / 10) * 1000);
  97. .@total_cost += ((.@equip_level[.@index] / 10) * 10000);
  98.  
  99. // effect count.
  100. .@total_cost += (countstr(.@script$[.@index], "bonus") * 1000);
  101. .@total_cost += (countstr(.@equip_script$[.@index], "bonus") * 1000);
  102. .@total_cost += (countstr(.@unequip_script$[.@index], "bonus") * 1000);
  103. .@total_cost += (countstr(.@unequip_script$[.@index], "heal") * 100);
  104. .@total_cost += (countstr(.@unequip_script$[.@index], "warp") * 1000);
  105.  
  106. if (.@total_cost > 0)
  107. npcshopadditem .@npc_shop_name$, .@id[.@index], .@total_cost;
  108. .@x++;
  109. .@total_item_count++;
  110. } while (.@x < .max_shop_item && .@index < .@size);
  111. setnpcdisplay(.@npc_shop_name$, func_ShopTypeName(.@type)+"#t_"+.@type+"_"+.@npc, func_ShopClassID(.@type));
  112. }
  113. .@npc++;
  114. } while (.@npc <= .@npc_count);
  115. freeloop(0);
  116.  
  117. }
  118.  
  119. // Remove excessive NPC
  120. while (!getmapxy(.@map$, .@map_x, .@map_y, 1, "Shop#t_"+.@type+"_"+.@npc) || .@npc <= .@npc_count) {
  121. disablenpc "Shop#t_"+.@type+"_"+.@npc;
  122. .@npc++;
  123. }
  124.  
  125. debugmes "SQL Mall - " + func_ShopTypeName(.@type) + " - Loaded " + F_InsertComma(.@total_item_count) + " Item(s)";
  126. return;
  127.  
  128. }
  129.  
  130.  
  131. // Add more if needed (follow the name and numbering)
  132.  
  133. prt_fild08,203,72,5 shop Shop#t_0_1 4_F_KAFRA1,909:-1
  134. prt_fild08,205,72,5 shop Shop#t_0_2 4_F_KAFRA1,909:-1
  135. prt_fild08,207,72,5 shop Shop#t_0_3 4_F_KAFRA1,909:-1
  136. prt_fild08,209,72,5 shop Shop#t_0_4 4_F_KAFRA1,909:-1
  137.  
  138. prt_fild08,203,74,5 shop Shop#t_2_1 4_F_KAFRA1,909:-1
  139. prt_fild08,205,74,5 shop Shop#t_2_2 4_F_KAFRA1,909:-1
  140. prt_fild08,207,74,5 shop Shop#t_2_3 4_F_KAFRA1,909:-1
  141. prt_fild08,209,74,5 shop Shop#t_2_4 4_F_KAFRA1,909:-1
  142. prt_fild08,211,74,5 shop Shop#t_2_5 4_F_KAFRA1,909:-1
  143. prt_fild08,213,74,5 shop Shop#t_2_6 4_F_KAFRA1,909:-1
  144. prt_fild08,215,74,5 shop Shop#t_2_7 4_F_KAFRA1,909:-1
  145. prt_fild08,217,74,5 shop Shop#t_2_8 4_F_KAFRA1,909:-1
  146. prt_fild08,219,74,5 shop Shop#t_2_9 4_F_KAFRA1,909:-1
  147. prt_fild08,221,74,5 shop Shop#t_2_10 4_F_KAFRA1,909:-1
  148.  
  149. prt_fild08,203,76,5 shop Shop#t_3_1 4_F_KAFRA1,909:-1
  150. prt_fild08,205,76,5 shop Shop#t_3_2 4_F_KAFRA1,909:-1
  151. prt_fild08,207,76,5 shop Shop#t_3_3 4_F_KAFRA1,909:-1
  152. prt_fild08,209,76,5 shop Shop#t_3_4 4_F_KAFRA1,909:-1
  153. prt_fild08,211,76,5 shop Shop#t_3_5 4_F_KAFRA1,909:-1
  154. prt_fild08,213,76,5 shop Shop#t_3_6 4_F_KAFRA1,909:-1
  155. prt_fild08,215,76,5 shop Shop#t_3_7 4_F_KAFRA1,909:-1
  156. prt_fild08,217,76,5 shop Shop#t_3_8 4_F_KAFRA1,909:-1
  157. prt_fild08,219,76,5 shop Shop#t_3_9 4_F_KAFRA1,909:-1
  158.  
  159. prt_fild08,203,78,5 shop Shop#t_3_10 4_F_KAFRA1,909:-1
  160. prt_fild08,205,78,5 shop Shop#t_3_11 4_F_KAFRA1,909:-1
  161. prt_fild08,207,78,5 shop Shop#t_3_12 4_F_KAFRA1,909:-1
  162. prt_fild08,209,78,5 shop Shop#t_3_13 4_F_KAFRA1,909:-1
  163. prt_fild08,211,78,5 shop Shop#t_3_14 4_F_KAFRA1,909:-1
  164. prt_fild08,213,78,5 shop Shop#t_3_15 4_F_KAFRA1,909:-1
  165. prt_fild08,215,78,5 shop Shop#t_3_16 4_F_KAFRA1,909:-1
  166. prt_fild08,217,78,5 shop Shop#t_3_17 4_F_KAFRA1,909:-1
  167. prt_fild08,219,78,5 shop Shop#t_3_18 4_F_KAFRA1,909:-1
  168. prt_fild08,221,78,5 shop Shop#t_3_19 4_F_KAFRA1,909:-1
  169.  
  170. prt_fild08,203,80,5 shop Shop#t_4_1 4_F_KAFRA1,909:-1
  171. prt_fild08,205,80,5 shop Shop#t_4_2 4_F_KAFRA1,909:-1
  172. prt_fild08,207,80,5 shop Shop#t_4_3 4_F_KAFRA1,909:-1
  173. prt_fild08,209,80,5 shop Shop#t_4_4 4_F_KAFRA1,909:-1
  174. prt_fild08,211,80,5 shop Shop#t_4_5 4_F_KAFRA1,909:-1
  175. prt_fild08,213,80,5 shop Shop#t_4_6 4_F_KAFRA1,909:-1
  176. prt_fild08,215,80,5 shop Shop#t_4_7 4_F_KAFRA1,909:-1
  177. prt_fild08,217,80,5 shop Shop#t_4_8 4_F_KAFRA1,909:-1
  178. prt_fild08,219,80,5 shop Shop#t_4_9 4_F_KAFRA1,909:-1
  179. prt_fild08,221,80,5 shop Shop#t_4_10 4_F_KAFRA1,909:-1
  180. prt_fild08,223,80,5 shop Shop#t_4_11 4_F_KAFRA1,909:-1
  181.  
  182. prt_fild08,203,82,5 shop Shop#t_5_1 4_F_KAFRA1,909:-1
  183. prt_fild08,205,82,5 shop Shop#t_5_2 4_F_KAFRA1,909:-1
  184. prt_fild08,207,82,5 shop Shop#t_5_3 4_F_KAFRA1,909:-1
  185. prt_fild08,209,82,5 shop Shop#t_5_4 4_F_KAFRA1,909:-1
  186. prt_fild08,211,82,5 shop Shop#t_5_5 4_F_KAFRA1,909:-1
  187. prt_fild08,213,82,5 shop Shop#t_5_6 4_F_KAFRA1,909:-1
  188. prt_fild08,215,82,5 shop Shop#t_5_7 4_F_KAFRA1,909:-1
  189. prt_fild08,217,82,5 shop Shop#t_5_8 4_F_KAFRA1,909:-1
  190. prt_fild08,219,82,5 shop Shop#t_5_9 4_F_KAFRA1,909:-1
  191.  
  192. prt_fild08,203,84,5 shop Shop#t_5_10 4_F_KAFRA1,909:-1
  193. prt_fild08,205,84,5 shop Shop#t_5_11 4_F_KAFRA1,909:-1
  194. prt_fild08,207,84,5 shop Shop#t_5_12 4_F_KAFRA1,909:-1
  195. prt_fild08,209,84,5 shop Shop#t_5_13 4_F_KAFRA1,909:-1
  196. prt_fild08,211,84,5 shop Shop#t_5_14 4_F_KAFRA1,909:-1
  197. prt_fild08,213,84,5 shop Shop#t_5_15 4_F_KAFRA1,909:-1
  198. prt_fild08,215,84,5 shop Shop#t_5_16 4_F_KAFRA1,909:-1
  199. prt_fild08,217,84,5 shop Shop#t_5_17 4_F_KAFRA1,909:-1
  200. prt_fild08,219,84,5 shop Shop#t_5_18 4_F_KAFRA1,909:-1
  201. prt_fild08,221,84,5 shop Shop#t_5_19 4_F_KAFRA1,909:-1
  202.  
  203. prt_fild08,203,86,5 shop Shop#t_5_20 4_F_KAFRA1,909:-1
  204. prt_fild08,205,86,5 shop Shop#t_5_21 4_F_KAFRA1,909:-1
  205. prt_fild08,207,86,5 shop Shop#t_5_22 4_F_KAFRA1,909:-1
  206. prt_fild08,209,86,5 shop Shop#t_5_23 4_F_KAFRA1,909:-1
  207. prt_fild08,211,86,5 shop Shop#t_5_24 4_F_KAFRA1,909:-1
  208. prt_fild08,213,86,5 shop Shop#t_5_25 4_F_KAFRA1,909:-1
  209. prt_fild08,215,86,5 shop Shop#t_5_26 4_F_KAFRA1,909:-1
  210. prt_fild08,217,86,5 shop Shop#t_5_27 4_F_KAFRA1,909:-1
  211. prt_fild08,219,86,5 shop Shop#t_5_28 4_F_KAFRA1,909:-1
  212. prt_fild08,221,86,5 shop Shop#t_5_29 4_F_KAFRA1,909:-1
  213.  
  214. prt_fild08,203,88,5 shop Shop#t_5_30 4_F_KAFRA1,909:-1
  215. prt_fild08,205,88,5 shop Shop#t_5_31 4_F_KAFRA1,909:-1
  216. prt_fild08,207,88,5 shop Shop#t_5_32 4_F_KAFRA1,909:-1
  217. prt_fild08,209,88,5 shop Shop#t_5_33 4_F_KAFRA1,909:-1
  218.  
  219. prt_fild08,203,90,5 shop Shop#t_6_1 4_F_KAFRA1,909:-1
  220. prt_fild08,205,90,5 shop Shop#t_6_2 4_F_KAFRA1,909:-1
  221. prt_fild08,207,90,5 shop Shop#t_6_3 4_F_KAFRA1,909:-1
  222. prt_fild08,209,90,5 shop Shop#t_6_4 4_F_KAFRA1,909:-1
  223. prt_fild08,211,90,5 shop Shop#t_6_5 4_F_KAFRA1,909:-1
  224. prt_fild08,213,90,5 shop Shop#t_6_6 4_F_KAFRA1,909:-1
  225. prt_fild08,215,90,5 shop Shop#t_6_7 4_F_KAFRA1,909:-1
  226. prt_fild08,217,90,5 shop Shop#t_6_8 4_F_KAFRA1,909:-1
  227. prt_fild08,219,90,5 shop Shop#t_6_9 4_F_KAFRA1,909:-1
  228.  
  229. prt_fild08,203,92,5 shop Shop#t_6_10 4_F_KAFRA1,909:-1
  230. prt_fild08,205,92,5 shop Shop#t_6_11 4_F_KAFRA1,909:-1
  231.  
  232. prt_fild08,203,94,5 shop Shop#t_7_1 4_F_KAFRA1,909:-1
  233.  
  234. prt_fild08,203,96,5 shop Shop#t_8_1 4_F_KAFRA1,909:-1
  235.  
  236. prt_fild08,203,98,5 shop Shop#t_10_1 4_F_KAFRA1,909:-1
  237. prt_fild08,205,98,5 shop Shop#t_10_2 4_F_KAFRA1,909:-1
  238.  
  239. prt_fild08,203,100,5 shop Shop#t_11_1 4_F_KAFRA1,909:-1
  240. prt_fild08,205,100,5 shop Shop#t_11_2 4_F_KAFRA1,909:-1
  241.  
  242. prt_fild08,203,102,5 shop Shop#t_18_1 4_F_KAFRA1,909:-1
  243. prt_fild08,205,102,5 shop Shop#t_18_2 4_F_KAFRA1,909:-1
  244. prt_fild08,207,102,5 shop Shop#t_18_3 4_F_KAFRA1,909:-1
  245. prt_fild08,209,102,5 shop Shop#t_18_4 4_F_KAFRA1,909:-1
  246. prt_fild08,211,102,5 shop Shop#t_18_5 4_F_KAFRA1,909:-1
  247. prt_fild08,213,102,5 shop Shop#t_18_6 4_F_KAFRA1,909:-1
  248. prt_fild08,215,102,5 shop Shop#t_18_7 4_F_KAFRA1,909:-1
  249. prt_fild08,217,102,5 shop Shop#t_18_8 4_F_KAFRA1,909:-1
  250. prt_fild08,219,102,5 shop Shop#t_18_9 4_F_KAFRA1,909:-1
  251.  
  252. prt_fild08,203,104,5 shop Shop#t_18_10 4_F_KAFRA1,909:-1
  253. prt_fild08,205,104,5 shop Shop#t_18_11 4_F_KAFRA1,909:-1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement