Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 95.93 KB | None | 0 0
  1. --------------------------------------- File Info Start ---------------------------------------
  2. ----------- Project name: In Game Shop & Trade -----------
  3. ----------- Author: masodikbela@Hungary -----------
  4. ----------- Version: v2.0 -----------
  5. ----------- Original relase date: 2014. 12. 02. 21:23:42 -----------
  6. ----------- Previous released version: v1.0 with some fixes -----------
  7. ----------- Developed for: Everyone -----------
  8. ----------- Aviable languages: Hungarian, English -----------
  9. ----------- Last edited: 2015. 08. 17. 23:54 -----------
  10. --------------------------------------- File Info End -----------------------------------------
  11. quest mb_igshop begin
  12. state start begin
  13. --------------------------
  14. --Client commander Start--
  15. --------------------------
  16.  
  17. when button begin
  18. local cmd = client_command(getinput("IGSHOP QUESTCMD"))
  19. if cmd[1] == "GROUP" then
  20. if table.getn(cmd) != 3 then syschat("mb_igshop Error->invalid_packet_size(GROUP)") return end
  21. mb_igshop.clearAllArraySell(pc.get_player_id())
  22. if cmd[2] == "" then return end
  23. for i = 1, table.getn(availableGroups) do
  24. if availableGroups[i] == cmd[2] then break end
  25. if i == table.getn(availableGroups) then syschat("mb_igshop Error->WrongGroup|"..cmd[2]) return end
  26. end
  27. local get = {}
  28. if cmd[2] == "my_buys" then
  29. get = mb_igshop.get_myboughtitems()
  30. elseif cmd[2] == "my_sales" then
  31. get = mb_igshop.get_myitems()
  32. elseif cmd[2] == "get_trade_items" then
  33. local fOpen = io.open(igshop_path.."data/"..pc.get_name().."/trade_data_list.txt", "r")
  34. if fOpen != nil then
  35. for i in fOpen:lines() do
  36. table.insert(get, i)
  37. end
  38. end
  39. else
  40. get = mb_igshop.get_items(cmd[2])
  41. end
  42. mb_igshop.refresh_pages(get)
  43. local lines = table.getn(get)
  44. if lines > 0 then
  45. mb_igshop.add_items(tonumber(pc.getqf("pages")),tonumber(cmd[3]),get, tonumber(pc.getqf("itemsOnLastPage")), cmd[2])
  46. cmdchat("IGSHOP MANAGEPAGES/"..tonumber(pc.getqf("pages")).."/1")
  47. end
  48. if cmd[2] != "my_buys" and cmd[2] != "get_trade_items" then
  49. cmdchat("IGSHOP SETGOLD/"..mb_igshop.get_gold(pc.get_account_id()))
  50. if cmd[2] != "my_sales" then
  51. cmdchat("IGSHOP SETCASH/"..get_coins())
  52. end
  53. end
  54.  
  55. elseif cmd[1] == "SWITCHPAGE" then
  56. if table.getn(cmd) != 3 then syschat("mb_igshop Error->invalid_packet_size(SWITCHPAGE)") return end
  57. mb_igshop.clearAllArraySell(pc.get_player_id())
  58. if cmd[2] == "" then return end
  59. for i = 1, table.getn(availableGroups) do
  60. if availableGroups[i] == cmd[2] then break end
  61. if i == table.getn(availableGroups) then syschat("mb_igshop Error->WrongGroup|"..cmd[2]) return end
  62. end
  63. local get = {}
  64. if cmd[2] == "my_buys" then
  65. get = mb_igshop.get_myboughtitems()
  66. elseif cmd[2] == "my_sales" then
  67. get = mb_igshop.get_myitems()
  68. elseif cmd[2] == "get_trade_items" then
  69. local fOpen = io.open(igshop_path.."data/"..pc.get_name().."/trade_data_list.txt", "r")
  70. if fOpen != nil then
  71. for i in fOpen:lines() do
  72. table.insert(get, i)
  73. end
  74. end
  75. else
  76. get = mb_igshop.get_items(cmd[2])
  77. end
  78. mb_igshop.refresh_pages(get)
  79. local lines = table.getn(get)
  80. if lines > 0 then
  81. local page = tonumber(cmd[3])
  82. if page > tonumber(pc.getqf("pages")) then page = tonumber(pc.getqf("pages")) end
  83. mb_igshop.add_items(tonumber(pc.getqf("pages")), page, get, tonumber(pc.getqf("itemsOnLastPage")), cmd[2])
  84. cmdchat("IGSHOP MANAGEPAGES/"..tonumber(pc.getqf("pages")).."/"..page)
  85. end
  86. if cmd[2] != "my_buys" and cmd[2] != "get_trade_items" then
  87. cmdchat("IGSHOP SETGOLD/"..mb_igshop.get_gold(pc.get_account_id()))
  88. if cmd[2] != "my_sales" then
  89. cmdchat("IGSHOP SETCASH/"..get_coins())
  90. end
  91. end
  92. elseif cmd[1] == "BUYITEM" then
  93. if table.getn(cmd) != 8 then syschat("mb_igshop Error->invalid_packet_size(BUYITEM)") return end
  94. if not mb_igshop.gm_buy_check() then syschat(loadLang(56)) return end
  95. local itemID = math.floor(tonumber(cmd[2]))
  96. local buytype = cmd[3]
  97. local page = math.floor(tonumber(cmd[4]))
  98. local slot = math.floor(tonumber(cmd[5]))
  99. local count = math.floor(tonumber(cmd[6]))
  100. local money = math.floor(tonumber(cmd[7]))
  101. for i = 1, table.getn(availableGroups) do
  102. if availableGroups[i] == cmd[8] then break end
  103. if i == table.getn(availableGroups) then syschat("mb_igshop Error->WrongGroup|"..cmd[8]) return end
  104. end
  105. local group = cmd[8]
  106. if count < 0 then syschat("mb_igshop Error->negative_count_of_item") return end
  107. if buytype == "CASH" then
  108. local coins = get_coins()
  109. if coins < money then
  110. syschat("mb_igshop Error->wrong_money_data")
  111. cmdchat("IGSHOP SETCASH/"..coins)
  112. else
  113. mb_igshop.BuyItem(itemID, buytype, page, slot, count, coins, group)
  114. end
  115. elseif buytype == "GOLD" then
  116. local gold = mb_igshop.get_gold(pc.get_account_id())
  117. if gold < money then
  118. syschat("mb_igshop Error->wrong_money_data")
  119. cmdchat("IGSHOP SETGOLD/"..gold)
  120. else
  121. mb_igshop.BuyItem(itemID, buytype, page, slot, count, gold, group)
  122. end
  123. else
  124. syschat("mb_igshop Error-> "..tostring(buytype))
  125. syschat("unknownError")
  126. end
  127. elseif cmd[1] == "CLAIMITEM" then
  128. if table.getn(cmd) != 4 then syschat("mb_igshop Error->invalid_packet_size(CLAIMITEM)") return end
  129. local itemID = math.floor(tonumber(cmd[2]))
  130. local page = math.floor(tonumber(cmd[3]))
  131. local slot = math.floor(tonumber(cmd[4]))
  132. mb_igshop.ClaimItem(itemID, page, slot)
  133. elseif cmd[1] == "CLAIMMYITEM" then
  134. if table.getn(cmd) != 4 then syschat("mb_igshop Error->invalid_packet_size(CLAIMMYITEM)") return end
  135. local itemID = math.floor(tonumber(cmd[2]))
  136. local page = math.floor(tonumber(cmd[3]))
  137. local slot = math.floor(tonumber(cmd[4]))
  138. mb_igshop.ClaimMyItem(itemID, page, slot)
  139. elseif cmd[1] == "SELLITEM" then
  140. if table.getn(cmd) != 3 then syschat("mb_igshop Error->invalid_packet_size(SELLITEM)") return end
  141. if not mb_igshop.gm_sell_check() then syschat(loadLang(55)) return end
  142. if not mb_igshop.expandable_limited_storage("get") then syschat(loadLang(2)) return end
  143. if not mb_igshop.check_itemc() then return syschat(loadLang(6)) end
  144. if not mb_igshop.check_accIC() then return syschat(loadLang(6)) end
  145. if not mb_igshop.char_filters() then return syschat(loadLang(4)) end
  146. local cell = tonumber(cmd[3])
  147. local slot = tonumber(cmd[2])
  148. if not item.select_cell(cell) then syschat(loadLang(54)) return end
  149. local id, vnum, count, itype, isubtype = item.get_id(), item.get_vnum(), item.get_count(), item.get_type(), item.get_sub_type()
  150. if not mb_igshop.check_always_available(vnum) then
  151. if not mb_igshop.check_antiflag(vnum) then return syschat(loadLang(5)) end
  152. if not mb_igshop.check_type(itype, isubtype) then return syschat(loadLang(3)) end
  153. if not mb_igshop.check_sellableItems(vnum) then return syschat(loadLang(5)) end
  154. end
  155. if itype == 0 then return end
  156. if count < 0 then syschat("mb_igshop Error->negative_count_of_item") return end
  157. if mb_igshop.igshop_gold_manager("put_in", vnum, count, cell) then return end
  158. pc.setqf("sellitemid",id)
  159. pc.setqf("itemcell",cell)
  160. pc.setqf("itemcount", pc.count_item(vnum))
  161. local attr = {{item.get_attr_type(0), item.get_attr_value(0)}, {item.get_attr_type(1), item.get_attr_value(1)}, {item.get_attr_type(2), item.get_attr_value(2)}, {item.get_attr_type(3), item.get_attr_value(3)},{item.get_attr_type(4), item.get_attr_value(4)},{item.get_attr_type(5), item.get_attr_value(5)}, {item.get_attr_type(6), item.get_attr_value(6)}, {item.get_attr_type(7), item.get_attr_value(7)}}
  162. local socket = {item.get_socket(0), item.get_socket(1), item.get_socket(2),item.get_socket(3),item.get_socket(4),item.get_socket(5)}
  163. cmdchat('IGSHOP_ADDTOTEMPSLOT '..slot..' '..vnum..' '..count..' '..socket[1]..' '..socket[2]..' '..socket[3]..' '..socket[4]..' '..socket[5]..' '..socket[6]..' '..attr[1][1]..' '..attr[1][2]..' '..attr[2][1]..' '..attr[2][2]..' '..attr[3][1]..' '..attr[3][2]..' '..attr[4][1]..' '..attr[4][2]..' '..attr[5][1]..' '..attr[5][2]..' '..attr[6][1]..' '..attr[6][2]..' '..attr[7][1]..' '..attr[7][2]..' '..attr[8][1]..' '..attr[8][2])
  164. elseif cmd[1] == "FINISHSALE" then
  165. if table.getn(cmd) != 3 then syschat("mb_igshop Error->invalid_packet_size(FINISHSALE)") return end
  166. if not mb_igshop.gm_sell_check() then syschat(loadLang(55)) return end
  167. if cmd[2] == "" then cmd[2] = 0 end
  168. if cmd[3] == "" then cmd[3] = 0 end
  169. local priceY = math.floor(tonumber(cmd[2]))
  170. local priceS = math.floor(tonumber(cmd[3]))
  171. if priceY <0 or priceS <0 then syschat(loadLang(7)) return end
  172. if not mb_igshop.char_filters() then return syschat(loadLang(4)) end
  173. if not mb_igshop.check_itemc() then return syschat(loadLang(6)) end
  174. if not mb_igshop.check_accIC() then return syschat(loadLang(6)) end
  175. mb_igshop.SellItem(priceY, priceS)
  176. elseif cmd[1] == "SEARCH" then
  177. if table.getn(cmd) < 4 then syschat("mb_igshop Error->invalid_packet_size(SEARCH)") return end
  178. if table.getn(cmd) > 4 then
  179. for i = 4, table.getn(cmd)-1 do
  180. cmd[3] = ""..cmd[3].."#"..cmd[i]
  181. end
  182. cmd[4] = cmd[table.getn(cmd)]
  183. end
  184. local fOwner = cmd[2]
  185. local fItem = string.lower(cmd[3])
  186. if fOwner == "" and fItem == "" then syschat(loadLang(8)) return end
  187. local file = io.open(igshop_path.."data/"..pc.get_name().."/search.txt", "w+")
  188. file:write(fOwner.."#"..fItem)
  189. file:flush()
  190. file:close()
  191. mb_igshop.searchItem(fOwner, fItem, tonumber(cmd[4]), 1)
  192. elseif cmd[1] == "GETMONEY" then
  193. if table.getn(cmd) != 2 then syschat("mb_igshop Error->invalid_packet_size(GETMONEY)") return end
  194. local money = cmd[2]
  195.  
  196. if pc.get_empty_inventory_count() < 1 then syschat(loadLang(9)) return end
  197. local tbl = split_(money, "|")
  198. local once = 0
  199. for i = 1, table.getn(tbl) do
  200. local mymoney = math.pow(1000, table.getn(tbl)-i)*tbl[i]
  201. local ret = mb_igshop.igshop_gold_manager("get_out",mymoney)
  202. if ret >= 0 then
  203. mb_igshop.set_gold(pc.get_account_id(),0 - mymoney + ret)
  204. end
  205. if ret != 0 and once == 0 and ret > 0 then syschat(loadLang(10)) once = 1 end
  206. end
  207. local gold = mb_igshop.get_gold(pc.get_account_id())
  208. cmdchat("IGSHOP SETGOLD/"..gold)
  209. cmdchat("IGSHOP EMPTYINPUTGOLD")
  210. elseif cmd[1] == "ChangeLang" then
  211. if table.getn(cmd) != 2 then syschat("mb_igshop Error->invalid_packet_size(ChangeLang)") return end
  212. local langNum = math.floor(tonumber(cmd[2])) + 1
  213. if langNum <= 0 or langNum > table.getn(igshopLangTable) then syschat("mb_igshop Error->no_lang_found") return end
  214. pc.setqf("langVar", langNum)
  215.  
  216. mb_igshop.OpenIgShop()
  217. elseif igshopEnableTrade then
  218. if cmd[1] == "trade.FindItemAndPut" then
  219. if table.getn(cmd) < 3 then syschat("mb_igshop Error->invalid_packet_size(trade.FindItemAndPut)") return end
  220. if table.getn(cmd) > 3 then
  221. for i = 3, table.getn(cmd)-1 do
  222. cmd[2] = ""..cmd[2].."#"..cmd[i]
  223. end
  224. cmd[3] = cmd[table.getn(cmd)]
  225. end
  226. local findName = trim(tostring(cmd[2]))
  227.  
  228. if string.len(findName) < 2 then
  229. syschat(loadLang(11))
  230. return
  231. end
  232. mb_igshop.FindTradeItemAndPut(string.lower(findName), cmd[3])
  233. elseif cmd[1] == "trade.ApplyWantsItem" then
  234. if table.getn(cmd) != 4+2*7 then syschat("mb_igshop Error->invalid_packet_size(trade.ApplyWantsItem)") return end
  235. local slotNum = tonumber(cmd[2])
  236. if slotNum < 1 or slotNum > igshop_maximumSlotSize then syschat("mb_igshop Error->wrong_slot_number") return end
  237. local itemVnum = tonumber(cmd[3])
  238. local itemCount = tonumber(cmd[4])
  239. if itemCount <= 0 then itemCount = 1 end
  240. if itemCount != math.floor(itemCount) then syschat(loadLang(12)) return end
  241. local tbl = {{tonumber(cmd[5]),tonumber(cmd[6])},{tonumber(cmd[7]),tonumber(cmd[8])},{tonumber(cmd[9]),tonumber(cmd[10])},{tonumber(cmd[11]),tonumber(cmd[12])},{tonumber(cmd[13]),tonumber(cmd[14])},{tonumber(cmd[15]),tonumber(cmd[16])},{tonumber(cmd[17]),tonumber(cmd[18])},{tonumber(cmd[19]),tonumber(cmd[20])}}
  242. if mb_igshop.applyNewTempSell(pc.get_player_id(), slotNum, itemVnum, itemCount, tbl) then
  243. cmdchat("IGSHOP trade.ApplyWantsItem")
  244. end
  245. elseif cmd[1] == "trade.RemoveFromTempSell" then
  246. if table.getn(cmd) != 2 then syschat("mb_igshop Error->invalid_packet_size(trade.RemoveFromTempSell)") return end
  247. local slot = tonumber(cmd[2])
  248. mb_igshop.removeFromTempSell(pc.get_player_id(), slot)
  249. elseif cmd[1] == "trade.RestoreFromSavedSell" then
  250. if table.getn(cmd) != 1 then syschat("mb_igshop Error->invalid_packet_size(trade.RestoreFromSavedSell)") return end
  251. mb_igshop.restoreFromSavedSell(pc.get_player_id())
  252. elseif cmd[1] == "trade.SaveFromTempSlotSell" then
  253. if table.getn(cmd) != 1 then syschat("mb_igshop Error->invalid_packet_size(trade.SaveFromTempSlotSell)") return end
  254. mb_igshop.saveFromTempSell(pc.get_player_id())
  255. elseif cmd[1] == "trade.ClearAllArraySell" then
  256. if table.getn(cmd) != 1 then syschat("mb_igshop Error->invalid_packet_size(trade.ClearAllArraySell)") return end
  257. mb_igshop.clearAllArraySell(pc.get_player_id())
  258. elseif cmd[1] == "trade.AppendSocket" then
  259. if table.getn(cmd) < 3 then syschat("mb_igshop Error->invalid_packet_size(trade.AppendSocket)") return end
  260. if table.getn(cmd) > 3 then
  261. for i = 4, table.getn(cmd)-1 do
  262. cmd[3] = ""..cmd[3].."#"..cmd[i]
  263. end
  264. end
  265. local pos = tonumber(cmd[2])
  266. local findItem = trim(cmd[3])
  267.  
  268. mb_igshop.FindStoneItemAndPut(pos, string.lower(findItem))
  269. elseif cmd[1] == "trade.RemoveSocket" then
  270. if table.getn(cmd) != 2 then syschat("mb_igshop Error->invalid_packet_size(trade.RemoveSocket)") return end
  271. mb_igshop.clearStoneSlotArraySpec(pc.get_player_id(), tonumber(cmd[2]))
  272. elseif cmd[1] == "trade.RequestTrade" then
  273. if table.getn(cmd) != 5 then syschat("mb_igshop Error->invalid_packet_size(trade.RequestTrade)") return end
  274. mb_igshop.MakeRequestTrade(tonumber(cmd[2]), tonumber(cmd[3]), tonumber(cmd[4]), cmd[5])
  275. elseif cmd[1] == "trade.CheckTradeItem" then
  276. if table.getn(cmd) != 5 then syschat("mb_igshop Error->invalid_packet_size(trade.CheckTradeItem)") return end
  277. local representedPos = math.floor(tonumber(cmd[2]))
  278. local inventoryPos = math.floor(tonumber(cmd[3]))
  279. local lastPYArrayPos = math.floor(tonumber(cmd[4]))
  280. local givePos = math.floor(tonumber(cmd[5]))
  281. if representedPos <= 0 or representedPos > igshop_maximumSlotSize then syschat("mb_igshop Error->invalid_slot_num") return end
  282. if givePos <= 0 or givePos > igshop_maximumSlotSize then syschat("mb_igshop Error->invalid_give_slot_num") return end
  283. mb_igshop.CheckTradeItem(representedPos, inventoryPos, lastPYArrayPos, givePos)
  284. elseif cmd[1] == "trade.SecondWave" then
  285. if table.getn(cmd) != 6 then syschat("mb_igshop Error->invalid_packet_size(trade.SecondWave)") return end
  286. local old_newID = math.floor(tonumber(cmd[2]))
  287. local old_myPos = math.floor(tonumber(cmd[3]))
  288. local my_ID = math.floor(tonumber(cmd[4]))
  289. local myPos = math.floor(tonumber(cmd[5]))
  290. local inventoryPos = math.floor(tonumber(cmd[6]))
  291. if old_newID <= 0 or old_newID > igshop_maximumSlotSize or my_ID <= 0 or my_ID > igshop_maximumSlotSize then syschat("mb_igshop Error->invalid_slot_num") return end
  292. if old_myPos <= 0 or old_myPos > igshop_maximumSlotSize or myPos <= 0 or myPos > igshop_maximumSlotSize then syschat("mb_igshop Error->invalid_give_slot_num") return end
  293. mb_igshop.SecondWave(old_newID, old_myPos, my_ID, myPos, inventoryPos)
  294. elseif cmd[1] == "trade.ApplyTrade" then
  295. if table.getn(cmd) != 1 then syschat("mb_igshop Error->invalid_packet_size(trade.ApplyTrade)") return end
  296. if not mb_igshop.gm_buy_check() then syschat(loadLang(56)) return end
  297. mb_igshop.DoTrade()
  298. cmdchat("IGSHOP REFRESHAFTERBUY")
  299. mb_igshop.clearAllArraySell(pc.get_player_id())
  300. elseif cmd[1] == "trade.ClaimTradeItem" then
  301. if table.getn(cmd) != 5 then syschat("mb_igshop Error->invalid_packet_size(trade.ClaimTradeItem)") return end
  302. mb_igshop.ClaimTradeItem(tonumber(cmd[2]), tonumber(cmd[3]), tonumber(cmd[4]), tonumber(cmd[5]))
  303. elseif cmd[1] == "trade.RemoveGivesSlot" then
  304. if table.getn(cmd) != 2 then syschat("mb_igshop Error->invalid_packet_size(trade.RemoveGivesSlot)") return end
  305. local pos = math.floor(tonumber(cmd[2]))
  306. mb_igshop.removeGivesItem(pc.get_player_id(), pos)
  307. end
  308. end
  309. end
  310.  
  311. ------------------------
  312. --Client commander End--
  313. ------------------------
  314.  
  315. ------------------------------------
  316. --Temporary array controller Start--
  317. ------------------------------------
  318. -- array struct: tempTradeItemContainer[playerID] = {playerID, {}, {}, {{1,0}, {1,0}, {1,0}, {1,0}}, {}, {}, {}}
  319. --#1 = playerID; #2 = temporary sell item container ; #3 = saved sell item container ; #4 = socked finder temp container ; #5 = wants container ; #6 gives container ; #7 safe item data container
  320.  
  321. when logout with mb_igshop.hasTempArray(pc.get_player_id()) begin
  322. mb_igshop.deleteTempArray(pc.get_player_id())
  323. end
  324.  
  325. function checkTradeDataSell(playerID)
  326. if not mb_igshop.hasTempArray(playerID) then return false end
  327. if tempTradeItemContainer[playerID][3] == {} then return false end
  328. local allNil = false
  329. for i = 1, igshop_maximumSlotSize do
  330. if tempTradeItemContainer[playerID][3][i] == nil then
  331. allNil = false
  332. else
  333. allNil = true
  334. break
  335. end
  336. end
  337. return allNil
  338. end
  339.  
  340. function hasSameSocket(playerID, currSlot, aType)
  341. mb_igshop.makeTempArray(playerID)
  342. for i = 1, table.getn(tempTradeItemContainer[playerID][4]) do
  343. if i != currSlot then
  344. if tempTradeItemContainer[playerID][4][i][2] == aType then
  345. return true
  346. end
  347. end
  348. end
  349. return false
  350. end
  351.  
  352. function registerSocketTempArray(playerID, stoneSlot, stoneVnum, aType)
  353. if not mb_igshop.hasTempArray(playerID) then return end
  354. if table.getn(tempTradeItemContainer[playerID][4]) < stoneSlot then return end
  355. tempTradeItemContainer[playerID][4][stoneSlot][1] = stoneVnum
  356. tempTradeItemContainer[playerID][4][stoneSlot][2] = aType
  357. end
  358.  
  359. function clearStoneSlotsArray(playerID)
  360. if not mb_igshop.hasTempArray(playerID) then return end
  361. tempTradeItemContainer[playerID][4] = {{1,0}, {1,0}, {1,0}, {1,0}}
  362. end
  363.  
  364. function clearStoneSlotArraySpec(playerID, pos)
  365. if not mb_igshop.hasTempArray(playerID) then return end
  366. tempTradeItemContainer[playerID][4][pos] = {1,0}
  367. end
  368.  
  369. function clearAllArraySell(playerID)
  370. if not mb_igshop.hasTempArray(playerID) then return end
  371. tempTradeItemContainer[playerID][2] = {}
  372. tempTradeItemContainer[playerID][3] = {}
  373. tempTradeItemContainer[playerID][4] = {{1,0}, {1,0}, {1,0}, {1,0}}
  374. tempTradeItemContainer[playerID][5] = {}
  375. tempTradeItemContainer[playerID][6] = {}
  376. tempTradeItemContainer[playerID][7] = {}
  377. end
  378.  
  379. function saveFromTempSell(playerID)
  380. if not mb_igshop.hasTempArray(playerID) then return end
  381. tempTradeItemContainer[playerID][3] = deepcopy(tempTradeItemContainer[playerID][2])
  382. end
  383.  
  384. function removeFromTempSell(playerID, slotNum)
  385. if not mb_igshop.hasTempArray(playerID) then return end
  386. tempTradeItemContainer[playerID][2][slotNum] = nil
  387. end
  388.  
  389. function restoreFromSavedSell(playerID)
  390. if not mb_igshop.hasTempArray(playerID) then return end
  391. tempTradeItemContainer[playerID][2] = deepcopy(tempTradeItemContainer[playerID][3])
  392. end
  393.  
  394. function applyNewTempSell(playerID, slotNum, itemVnum, itemCount, attrTable)
  395. mb_igshop.makeTempArray(playerID)
  396. if tempTradeItemContainer[playerID][2][slotNum] == nil then
  397. tempTradeItemContainer[playerID][2][slotNum] = {}
  398. else
  399. syschat(loadLang(13))
  400. return false
  401. end
  402. local sqlrec = game.mysql_query("SELECT socket_pct FROM "..igshop_player_database_name.."."..igshop_player_item_proto_table_name.." WHERE vnum = "..itemVnum.." LIMIT 1")
  403. if table.getn(sqlrec) != 1 then syschat("mb_igshop Error->failed_read_socket_pct_durningTempSell") return false end
  404. local socketNum = tonumber(sqlrec[1][1])
  405. if socketNum < 4 then tempTradeItemContainer[playerID][4][4] = {0,0} end
  406. if socketNum < 3 then tempTradeItemContainer[playerID][4][3] = {0,0} end
  407. if socketNum < 2 then tempTradeItemContainer[playerID][4][2] = {0,0} end
  408. if socketNum < 1 then tempTradeItemContainer[playerID][4][1] = {0,0} end
  409. tempTradeItemContainer[playerID][2][slotNum][1] = itemVnum
  410. tempTradeItemContainer[playerID][2][slotNum][2] = itemCount
  411. tempTradeItemContainer[playerID][2][slotNum][3] = {}
  412. for i = 1, table.getn(tempTradeItemContainer[playerID][4]) do
  413. table.insert(tempTradeItemContainer[playerID][2][slotNum][3], {})
  414. table.insert(tempTradeItemContainer[playerID][2][slotNum][3][i], tempTradeItemContainer[playerID][4][i][1])
  415. table.insert(tempTradeItemContainer[playerID][2][slotNum][3][i], tempTradeItemContainer[playerID][4][i][2])
  416. table.insert(tempTradeItemContainer[playerID][2][slotNum][3][i], tempTradeItemContainer[playerID][4][i][3])
  417. end
  418. tempTradeItemContainer[playerID][2][slotNum][4] = attrTable
  419. return true
  420. end
  421.  
  422. function hasTempArray(playerID)
  423. if tempTradeItemContainer[playerID] != nil then
  424. if tempTradeItemContainer[playerID][1] == playerID then
  425. return true
  426. end
  427. return false
  428. else
  429. return false
  430. end
  431. end
  432.  
  433. function makeTempArray(playerID)
  434. if mb_igshop.hasTempArray(playerID) then return end
  435. tempTradeItemContainer[playerID] = {playerID, {}, {}, {{1,0}, {1,0}, {1,0}, {1,0}}, {}, {}, {}}
  436. end
  437.  
  438. function deleteTempArray(playerID)
  439. if not mb_igshop.hasTempArray(playerID) then return end
  440. tempTradeItemContainer[playerID] = nil
  441. end
  442.  
  443. function prepareSellDataForTxt(playerID)
  444. if not mb_igshop.hasTempArray(playerID) then return {} end
  445. if tempTradeItemContainer[playerID][3] == {} then return {} end
  446. local returnTable = {}
  447. local temp = {}
  448. local unsusedShit = 0
  449. for i = 1, igshop_maximumSlotSize do
  450. if tempTradeItemContainer[playerID][3][i] == nil then unsusedShit = 0
  451. else
  452. temp = {}
  453. table.insert(temp, i) --slotID
  454. table.insert(temp, tempTradeItemContainer[playerID][3][i][1]) --itemVnum
  455. table.insert(temp, tempTradeItemContainer[playerID][3][i][2]) --itemCount
  456. table.insert(temp, tempTradeItemContainer[playerID][3][i][3]) --socketTable (only the first record used on save (socketVnum))
  457. table.insert(temp, tempTradeItemContainer[playerID][3][i][4]) --attrTable -> type, value
  458. table.insert(returnTable, temp)
  459. end
  460. end
  461. return returnTable
  462. end
  463.  
  464. function appendWantsContainer(playerID, item)
  465. if not mb_igshop.hasTempArray(playerID) then return false end
  466. local pos = tonumber(item[1])
  467. tempTradeItemContainer[playerID][5][pos] = {}
  468. table.insert(tempTradeItemContainer[playerID][5][pos], tonumber(item[2])) --vnum
  469. table.insert(tempTradeItemContainer[playerID][5][pos], tonumber(item[3])) --count
  470. table.insert(tempTradeItemContainer[playerID][5][pos], {}) --table for sockets
  471. table.insert(tempTradeItemContainer[playerID][5][pos][3], tonumber(item[4]))
  472. table.insert(tempTradeItemContainer[playerID][5][pos][3], tonumber(item[5]))
  473. table.insert(tempTradeItemContainer[playerID][5][pos][3], tonumber(item[6]))
  474. table.insert(tempTradeItemContainer[playerID][5][pos][3], tonumber(item[7]))
  475. table.insert(tempTradeItemContainer[playerID][5][pos], {}) --table for attrs
  476. table.insert(tempTradeItemContainer[playerID][5][pos][4], {}) --attr1
  477. table.insert(tempTradeItemContainer[playerID][5][pos][4][1], tonumber(item[8])) --attr1 type
  478. table.insert(tempTradeItemContainer[playerID][5][pos][4][1], tonumber(item[9])) --attr1 value
  479. table.insert(tempTradeItemContainer[playerID][5][pos][4], {}) --attr2
  480. table.insert(tempTradeItemContainer[playerID][5][pos][4][2], tonumber(item[10])) --attr2 type
  481. table.insert(tempTradeItemContainer[playerID][5][pos][4][2], tonumber(item[11])) --attr2 value
  482. table.insert(tempTradeItemContainer[playerID][5][pos][4], {}) --attr3
  483. table.insert(tempTradeItemContainer[playerID][5][pos][4][3], tonumber(item[12])) --attr3 type
  484. table.insert(tempTradeItemContainer[playerID][5][pos][4][3], tonumber(item[13])) --attr3 value
  485. table.insert(tempTradeItemContainer[playerID][5][pos][4], {}) --attr4
  486. table.insert(tempTradeItemContainer[playerID][5][pos][4][4], tonumber(item[14])) --attr4 type
  487. table.insert(tempTradeItemContainer[playerID][5][pos][4][4], tonumber(item[15])) --attr4 value
  488. table.insert(tempTradeItemContainer[playerID][5][pos][4], {}) --attr5
  489. table.insert(tempTradeItemContainer[playerID][5][pos][4][5], tonumber(item[16])) --attr5 type
  490. table.insert(tempTradeItemContainer[playerID][5][pos][4][5], tonumber(item[17])) --attr5 value
  491. table.insert(tempTradeItemContainer[playerID][5][pos][4], {}) --attr6
  492. table.insert(tempTradeItemContainer[playerID][5][pos][4][6], tonumber(item[18])) --attr6 type
  493. table.insert(tempTradeItemContainer[playerID][5][pos][4][6], tonumber(item[19])) --attr6 value
  494. table.insert(tempTradeItemContainer[playerID][5][pos][4], {}) --attr7
  495. table.insert(tempTradeItemContainer[playerID][5][pos][4][7], tonumber(item[20])) --attr7 type
  496. table.insert(tempTradeItemContainer[playerID][5][pos][4][7], tonumber(item[21])) --attr7 value
  497. table.insert(tempTradeItemContainer[playerID][5][pos][4], {}) --attr8
  498. table.insert(tempTradeItemContainer[playerID][5][pos][4][8], tonumber(item[22])) --attr8 type
  499. table.insert(tempTradeItemContainer[playerID][5][pos][4][8], tonumber(item[23])) --attr8 value
  500. return true
  501. end
  502.  
  503. function loadWantsData(playerID)
  504. if not mb_igshop.hasTempArray(playerID) then return {} end
  505. return tempTradeItemContainer[playerID][5]
  506. end
  507.  
  508. function loadGivesData(playerID)
  509. if not mb_igshop.hasTempArray(playerID) then return {} end
  510. return tempTradeItemContainer[playerID][6]
  511. end
  512.  
  513. function appendGivesItem(playerID, appendTable, pos)
  514. if not mb_igshop.hasTempArray(playerID) then return end
  515. tempTradeItemContainer[playerID][6][pos] = appendTable
  516. end
  517.  
  518. function removeGivesItem(playerID, pos)
  519. if not mb_igshop.hasTempArray(playerID) then return end
  520. tempTradeItemContainer[playerID][6][pos] = nil
  521. end
  522.  
  523. function registerSafeItemData(playerID, safeItemData)
  524. mb_igshop.makeTempArray(playerID)
  525. tempTradeItemContainer[playerID][7] = safeItemData
  526. end
  527.  
  528. function getSafeItemData(playerID)
  529. if not mb_igshop.hasTempArray(playerID) then return {} end
  530. return tempTradeItemContainer[playerID][7]
  531. end
  532.  
  533. ----------------------------------
  534. --Temporary array controller End--
  535. ----------------------------------
  536.  
  537. --------------------------
  538. --New trade system Start--
  539. --------------------------
  540.  
  541. function DoTrade()
  542. local safeData = mb_igshop.getSafeItemData(pc.get_player_id())
  543. if table.getn(safeData) <= 0 then syschat(loadLang(14)) return end
  544. if mb_igshop.IsTradeItem(safeData[1]) != 1 then syschat(loadLang(15)) return end
  545. local givesData = mb_igshop.loadGivesData(pc.get_player_id())
  546. local wantsData = mb_igshop.loadWantsData(pc.get_player_id())
  547. local itemsInList = 0
  548. local maxItem = 0
  549. for i = 1, igshop_maximumSlotSize do
  550. if givesData[i] != nil then
  551. itemsInList = 1 + itemsInList
  552. if not item.select_cell(givesData[i][6]) then syschat(loadLang(16)) return end
  553. if item.get_id() != givesData[i][1] or item.get_count() != givesData[i][3] or item.get_vnum() != givesData[i][2] then syschat(loadLang(16)) return end
  554. end
  555. if wantsData[i] != nil then
  556. maxItem = maxItem + 1
  557. end
  558. end
  559. if maxItem <= 0 or maxItem != itemsInList then syschat(loadLang(17)) return end
  560. local stringWriter = ""
  561. for i = 1, igshop_maximumSlotSize do
  562. if givesData[i] != nil then
  563. stringWriter = stringWriter..""..i.."#"
  564. stringWriter = stringWriter..""..givesData[i][2].."#"
  565. stringWriter = stringWriter..""..givesData[i][3]
  566. for x = 1, table.getn(givesData[i][4]) do
  567. stringWriter = stringWriter.."".."#"..givesData[i][4][x]
  568. end
  569. for x = 1, table.getn(givesData[i][5]) do
  570. stringWriter = stringWriter.."".."#"..givesData[i][5][x][1]
  571. stringWriter = stringWriter.."".."#"..givesData[i][5][x][2]
  572. end
  573. stringWriter = stringWriter.."\\n"
  574. item.select_cell(givesData[i][6])
  575. item.remove()
  576. end
  577. end
  578. local fOpen = io.open(igshop_path.."data/"..safeData[4].."/"..safeData[1]..".txt", "w+")
  579. fOpen:write(stringWriter)
  580. fOpen:flush()
  581. fOpen:close()
  582.  
  583. local itemdata = split_(tostring(safeData[7][((safeData[2]-1)*5)+safeData[3]]), "#")
  584. local fOpen = io.open(igshop_path.."data/"..safeData[4].."/trade_data_list.txt", "a+")
  585. fOpen:write(safeData[1].."#"..itemdata[2].."#"..itemdata[3].."#"..pc.get_name().."#"..itemdata[7].."#"..itemdata[8].."#"..itemdata[9].."#"..itemdata[10].."#"..itemdata[11].."#"..itemdata[12].."#"..itemdata[13].."#"..itemdata[14].."#"..itemdata[15].."#"..itemdata[16].."#"..itemdata[17].."#"..itemdata[18].."#"..itemdata[19].."#"..itemdata[20].."#"..itemdata[21].."#"..itemdata[22].."#"..itemdata[23].."#"..itemdata[24].."#"..itemdata[25].."#"..itemdata[26].."#"..itemdata[27].."#"..itemdata[28].."\\n")
  586. fOpen:flush()
  587. fOpen:close()
  588.  
  589. os.remove(igshop_path.."tradedata/"..safeData[1]..".txt")
  590.  
  591. mb_igshop.ItemRemoveFromOwnerTxt(safeData[4], safeData[1], safeData[5], safeData[5])
  592. mb_igshop.ItemRemoveFromGroupTxt(safeData[6], safeData[7], ((safeData[2]-1)*5)+safeData[3], safeData[5], safeData[5])
  593. mb_igshop.GiveItemToTxt(tostring(safeData[7][((safeData[2]-1)*5)+safeData[3]]), safeData[5], safeData[5])
  594. end
  595.  
  596. function SecondChance(itemVnum, itemCount, sockets, attrs, representedPos, wantsData)
  597. if itemVnum != wantsData[representedPos][1] or itemCount != wantsData[representedPos][2] then syschat(loadLang(18)) return false end
  598.  
  599. for x = 1, 4 do
  600. if wantsData[representedPos][3][x] == 1 then
  601. if sockets[x] < 1 then syschat(loadLang(18)) return false end
  602. elseif wantsData[representedPos][3][x] > 1 and wantsData[representedPos][3][x] != 28960 then
  603. for y = 1, 4 do
  604. if wantsData[representedPos][3][x] == sockets[y] then break end
  605. if y >= 4 then syschat(loadLang(18)) return false end
  606. end
  607. end
  608. end
  609.  
  610. for x = 1, 6 do
  611. if wantsData[representedPos][4][x][1] > 0 then
  612. for y = 1, 6 do
  613. if wantsData[representedPos][4][x][1] == attrs[y][1] then
  614. if attrs[y][2] >= wantsData[representedPos][4][x][2] then break end
  615. end
  616. if y >= 6 then syschat(loadLang(18)) return false end
  617. end
  618. end
  619. end
  620.  
  621. for x = 7, 8 do
  622. if wantsData[representedPos][4][x][1] > 0 then
  623. for y = 7, 8 do
  624. if wantsData[representedPos][4][x][1] == attrs[y][1] then
  625. if attrs[y][2] >= wantsData[representedPos][4][x][2] then break end
  626. end
  627. if y >= 8 then syschat(loadLang(18)) return false end
  628. end
  629. end
  630. end
  631.  
  632. return true
  633. end
  634.  
  635. function SecondWave(old_newID, old_myPos, my_ID, myPos, inventoryPos)
  636. local wantsData = mb_igshop.loadWantsData(pc.get_player_id())
  637. if not mb_igshop.gm_buy_check() then syschat(loadLang(56)) cmdchat("IGSHOP SecondFail/"..old_newID.."/"..my_ID) return end
  638. if wantsData[my_ID] == nil then syschat(loadLang(19)) cmdchat("IGSHOP SecondFail/"..old_newID.."/"..my_ID) return end
  639. if table.getn(wantsData[my_ID]) != 4 then syschat(loadLang(19)) cmdchat("IGSHOP SecondFail/"..old_newID.."/"..my_ID) return end
  640.  
  641. local givesData = mb_igshop.loadGivesData(pc.get_player_id())
  642. if not item.select_cell(inventoryPos) then syschat(loadLang(54)) cmdchat("IGSHOP SecondFail/"..old_newID.."/"..my_ID) return end
  643. local itemID = item.get_id()
  644. local maxItem = 0
  645. local itemsInList = 0
  646.  
  647. for i = 1, igshop_maximumSlotSize do
  648. if givesData[i] != nil then
  649. if givesData[i][1] == itemID then syschat(loadLang(20)) cmdchat("IGSHOP SecondFail/"..old_newID.."/"..my_ID) return end
  650. itemsInList = 1 + itemsInList
  651. end
  652. if wantsData[i] != nil then
  653. maxItem = maxItem + 1
  654. end
  655. end
  656. if itemsInList >= maxItem then syschat(loadLang(21)) cmdchat("IGSHOP SecondFail/"..old_newID.."/"..my_ID) return end
  657.  
  658. if givesData[myPos] != nil then syschat(loadLang(13)) cmdchat("IGSHOP SecondFail/"..old_newID.."/"..my_ID) return end
  659.  
  660. local itemVnum = item.get_vnum()
  661. if not mb_igshop.check_always_available(itemVnum) then
  662. if not mb_igshop.check_type(iType, iSubType) then syschat(loadLang(57)) cmdchat("IGSHOP SecondFail/"..old_newID.."/"..my_ID) return end
  663. if not mb_igshop.check_antiflag(itemVnum) then syschat(loadLang(57)) cmdchat("IGSHOP SecondFail/"..old_newID.."/"..my_ID) return end
  664. if not mb_igshop.check_sellableItems(itemVnum) then syschat(loadLang(57)) cmdchat("IGSHOP SecondFail/"..old_newID.."/"..my_ID) return end
  665. end
  666. local itemCount = item.get_count()
  667. local sockets = {item.get_socket(0), item.get_socket(1), item.get_socket(2), item.get_socket(3)}
  668. local attrs = {{item.get_attr_type(0), item.get_attr_value(0)}, {item.get_attr_type(1), item.get_attr_value(1)}, {item.get_attr_type(2), item.get_attr_value(2)}, {item.get_attr_type(3), item.get_attr_value(3)},{item.get_attr_type(4), item.get_attr_value(4)},{item.get_attr_type(5), item.get_attr_value(5)}, {item.get_attr_type(6), item.get_attr_value(6)}, {item.get_attr_type(7), item.get_attr_value(7)}}
  669.  
  670. if givesData[old_myPos] == nil then syschat("mb_igshop Error->previous_item_not_found") cmdchat("IGSHOP SecondFail/"..old_newID.."/"..my_ID) return end
  671. if table.getn(givesData[old_myPos]) != 6 then syschat("mb_igshop Error->previous_item_not_found") cmdchat("IGSHOP SecondFail/"..old_newID.."/"..my_ID) return end
  672. if not mb_igshop.SecondChance(itemVnum, itemCount, sockets, attrs, my_ID, wantsData) then cmdchat("IGSHOP SecondFail/"..old_newID.."/"..my_ID) return end
  673. if not mb_igshop.SecondChance(givesData[old_myPos][2], givesData[old_myPos][3], givesData[old_myPos][4], givesData[old_myPos][5], old_newID, wantsData) then cmdchat("IGSHOP SecondFail/"..old_newID.."/"..my_ID) return end
  674.  
  675. local appendTable = {}
  676. table.insert(appendTable, itemID)
  677. table.insert(appendTable, itemVnum)
  678. table.insert(appendTable, itemCount)
  679. table.insert(appendTable, sockets)
  680. table.insert(appendTable, attrs)
  681. table.insert(appendTable, inventoryPos)
  682. mb_igshop.appendGivesItem(pc.get_player_id(), appendTable, myPos)
  683. cmdchat("IGSHOP SuccessAppend/"..myPos)
  684. end
  685.  
  686. function CheckTradeItem(representedPos, inventoryPos, lastPYArrayPos, givePos)
  687. local wantsData = mb_igshop.loadWantsData(pc.get_player_id())
  688. if not mb_igshop.gm_buy_check() then syschat(loadLang(56)) cmdchat("IGSHOP RecvTradeError/"..lastPYArrayPos.."/"..representedPos) return end
  689. if wantsData[representedPos] == nil then syschat(loadLang(19)) cmdchat("IGSHOP RecvTradeError/"..lastPYArrayPos.."/"..representedPos) return end
  690. if table.getn(wantsData[representedPos]) != 4 then syschat(loadLang(19)) cmdchat("IGSHOP RecvTradeError/"..lastPYArrayPos.."/"..representedPos) return end
  691.  
  692. local givesData = mb_igshop.loadGivesData(pc.get_player_id())
  693. if not item.select_cell(inventoryPos) then syschat(loadLang(54)) cmdchat("IGSHOP RecvTradeError/"..lastPYArrayPos.."/"..representedPos) return end
  694. local itemID = item.get_id()
  695. local maxItem = 0
  696. local itemsInList = 0
  697.  
  698. for i = 1, igshop_maximumSlotSize do
  699. if givesData[i] != nil then
  700. if givesData[i][1] == itemID then syschat(loadLang(20)) cmdchat("IGSHOP RecvTradeError/"..lastPYArrayPos.."/"..representedPos) return end
  701. itemsInList = 1 + itemsInList
  702. end
  703. if wantsData[i] != nil then
  704. maxItem = maxItem + 1
  705. end
  706. end
  707. if itemsInList >= maxItem then syschat(loadLang(21)) cmdchat("IGSHOP RecvTradeError/"..lastPYArrayPos.."/"..representedPos) return end
  708.  
  709. if givesData[givePos] != nil then syschat(loadLang(13)) cmdchat("IGSHOP RecvTradeError/"..lastPYArrayPos.."/"..representedPos) return end
  710.  
  711. local itemVnum = item.get_vnum()
  712. if not mb_igshop.check_always_available(itemVnum) then
  713. if not mb_igshop.check_type(item.get_type(), item.get_sub_type()) then syschat(loadLang(57)) cmdchat("IGSHOP RecvTradeError/"..lastPYArrayPos.."/"..representedPos) return end
  714. if not mb_igshop.check_antiflag(itemVnum) then syschat(loadLang(57)) cmdchat("IGSHOP RecvTradeError/"..lastPYArrayPos.."/"..representedPos) return end
  715. if not mb_igshop.check_sellableItems(itemVnum) then syschat(loadLang(57)) cmdchat("IGSHOP RecvTradeError/"..lastPYArrayPos.."/"..representedPos) return end
  716. end
  717. local itemCount = item.get_count()
  718. local sockets = {item.get_socket(0), item.get_socket(1), item.get_socket(2), item.get_socket(3)}
  719. local attrs = {{item.get_attr_type(0), item.get_attr_value(0)}, {item.get_attr_type(1), item.get_attr_value(1)}, {item.get_attr_type(2), item.get_attr_value(2)}, {item.get_attr_type(3), item.get_attr_value(3)},{item.get_attr_type(4), item.get_attr_value(4)},{item.get_attr_type(5), item.get_attr_value(5)}, {item.get_attr_type(6), item.get_attr_value(6)}, {item.get_attr_type(7), item.get_attr_value(7)}}
  720.  
  721. if itemVnum != wantsData[representedPos][1] or itemCount != wantsData[representedPos][2] then syschat(loadLang(18)) cmdchat("IGSHOP RecvTradeError/"..lastPYArrayPos.."/"..representedPos) return end
  722.  
  723. for x = 1, 4 do
  724. if wantsData[representedPos][3][x] == 1 then
  725. if sockets[x] < 1 then syschat(loadLang(18)) cmdchat("IGSHOP RecvTradeError/"..lastPYArrayPos.."/"..representedPos) return end
  726. elseif wantsData[representedPos][3][x] > 1 and wantsData[representedPos][3][x] != 28960 then
  727. for y = 1, 4 do
  728. if wantsData[representedPos][3][x] == sockets[y] then break end
  729. if y >= 4 then syschat(loadLang(18)) cmdchat("IGSHOP RecvTradeError/"..lastPYArrayPos.."/"..representedPos) return end
  730. end
  731. end
  732. end
  733.  
  734. for x = 1, 6 do
  735. if wantsData[representedPos][4][x][1] > 0 then
  736. for y = 1, 6 do
  737. if wantsData[representedPos][4][x][1] == attrs[y][1] then
  738. if attrs[y][2] >= wantsData[representedPos][4][x][2] then break end
  739. end
  740. if y >= 6 then syschat(loadLang(18)) cmdchat("IGSHOP RecvTradeError/"..lastPYArrayPos.."/"..representedPos) return end
  741. end
  742. end
  743. end
  744.  
  745. for x = 7, 8 do
  746. if wantsData[representedPos][4][x][1] > 0 then
  747. for y = 7, 8 do
  748. if wantsData[representedPos][4][x][1] == attrs[y][1] then
  749. if attrs[y][2] >= wantsData[representedPos][4][x][2] then break end
  750. end
  751. if y >= 8 then syschat(loadLang(18)) cmdchat("IGSHOP RecvTradeError/"..lastPYArrayPos.."/"..representedPos) return end
  752. end
  753. end
  754. end
  755.  
  756. local appendTable = {}
  757. table.insert(appendTable, itemID)
  758. table.insert(appendTable, itemVnum)
  759. table.insert(appendTable, itemCount)
  760. table.insert(appendTable, sockets)
  761. table.insert(appendTable, attrs)
  762. table.insert(appendTable, inventoryPos)
  763. mb_igshop.appendGivesItem(pc.get_player_id(), appendTable, givePos)
  764.  
  765. cmdchat("IGSHOP SuccessAppend/"..givePos)
  766. end
  767.  
  768. function ClaimTradeItem(itemID, page, slot, itemPos)
  769. local data = {}
  770. local fOpen = io.open(igshop_path.."data/"..pc.get_name().."/trade_data_list.txt", "r")
  771. if fOpen != nil then
  772. for i in fOpen:lines() do
  773. table.insert(data, i)
  774. end
  775. end
  776. if table.getn(data) <= 0 then syschat(loadLang(22)) return end
  777. mb_igshop.refresh_pages(data)
  778. if tonumber(pc.getqf("pages")) < page then syschat(loadLang(22)) return end
  779. local item = split_(data[((page-1)*5)+slot],"#")
  780. if tonumber(item[1]) != itemID then syschat(loadLang(22)) return end
  781. local sOpen = io.open(igshop_path.."data/"..pc.get_name().."/"..item[1]..".txt", "r")
  782. if sOpen == nil then syschat(loadLang(22)) return end
  783. local tradeItems = {}
  784. for i in sOpen:lines() do
  785. table.insert(tradeItems, i)
  786. end
  787. if table.getn(tradeItems) <= 0 then syschat(loadLang(22)) mb_igshop.RemoveClaimedTradeItem(tonumber(item[1]), data, ((page-1)*5)+slot) cmdchat("IGSHOP REFRESHAFTERBUY") return end
  788. local foundItem = {}
  789. for i = 1, table.getn(tradeItems) do
  790. local thisItem = split_(tradeItems[i], "#")
  791. if tonumber(thisItem[1]) == itemPos then foundItem = thisItem break end
  792. end
  793. if table.getn(foundItem) <= 0 then syschat(loadLang(22)) return end
  794. pc.give_item_with(tonumber(foundItem[2]), tonumber(foundItem[3]), tonumber(foundItem[7]), tonumber(foundItem[8]), tonumber(foundItem[9]), tonumber(foundItem[10]), tonumber(foundItem[11]), tonumber(foundItem[12]), tonumber(foundItem[13]), tonumber(foundItem[14]), tonumber(foundItem[15]), tonumber(foundItem[16]), tonumber(foundItem[17]), tonumber(foundItem[18]), tonumber(foundItem[19]), tonumber(foundItem[20]), tonumber(foundItem[4]), tonumber(foundItem[5]), tonumber(foundItem[6]))
  795. if table.getn(tradeItems) > 1 then
  796. local sOpen2 = io.open(igshop_path.."data/"..pc.get_name().."/"..item[1]..".txt", "w+")
  797. for i = 1, table.getn(tradeItems) do
  798. local thisItem = split_(tradeItems[i], "#")
  799. if tonumber(thisItem[1]) != itemPos then
  800. sOpen2:write(tradeItems[i].."\\n")
  801. end
  802. end
  803. sOpen2:flush()
  804. sOpen2:close()
  805. else
  806. mb_igshop.RemoveClaimedTradeItem(tonumber(item[1]), data, ((page-1)*5)+slot)
  807. cmdchat("IGSHOP REFRESHAFTERBUY")
  808. end
  809. end
  810.  
  811. function RemoveClaimedTradeItem(itemID, itemdata, pos)
  812. os.remove(igshop_path.."data/"..pc.get_name().."/"..itemID..".txt")
  813. table.remove(itemdata, pos)
  814. local fOpen = io.open(igshop_path.."data/"..pc.get_name().."/trade_data_list.txt", "w+")
  815. for i = 1, table.getn(itemdata) do
  816. fOpen:write(itemdata[i].."\\n")
  817. end
  818. fOpen:flush()
  819. fOpen:close()
  820. end
  821.  
  822. function OpenTradeToPreview(itemID, page, slot)
  823. local data = mb_igshop.get_myitems()
  824. if table.getn(data) <= 0 then syschat(loadLang(23)) return end
  825. mb_igshop.refresh_pages(data)
  826. if tonumber(pc.getqf("pages")) < page then syschat(loadLang(23)) return end
  827. local item = split_(data[((page-1)*5)+slot],"#")
  828. if tonumber(item[1]) != itemID then syschat(loadLang(23)) return end
  829. local sOpen = io.open(igshop_path.."tradedata/"..item[1]..".txt", "r")
  830. if sOpen == nil then syschat(loadLang(23)) return end
  831. local tradeItems = {}
  832. for i in sOpen:lines() do
  833. table.insert(tradeItems, i)
  834. end
  835.  
  836. cmdchat("IGSHOP OpenGetDialog/"..itemID.."/"..page.."/"..slot.."/1")
  837. for i = 1, table.getn(tradeItems) do
  838. local thisItem = split_(tradeItems[i], "#")
  839. cmdchat("trade.AppendGetItem "..thisItem[1].." "..thisItem[2].." "..thisItem[3].." "..thisItem[4].." "..thisItem[5].." "..thisItem[6].." "..thisItem[7].." "..thisItem[8].." "..thisItem[9].." "..thisItem[10].." "..thisItem[11].." "..thisItem[12].." "..thisItem[13].." "..thisItem[14].." "..thisItem[15].." "..thisItem[16].." "..thisItem[17].." "..thisItem[18].." "..thisItem[19].." "..thisItem[20].." "..thisItem[21].." "..thisItem[22])
  840. end
  841. end
  842.  
  843. function OpenTradeToGet(itemID, page, slot)
  844. local data = {}
  845. local fOpen = io.open(igshop_path.."data/"..pc.get_name().."/trade_data_list.txt", "r")
  846. if fOpen != nil then
  847. for i in fOpen:lines() do
  848. table.insert(data, i)
  849. end
  850. end
  851. if table.getn(data) <= 0 then syschat(loadLang(22)) return end
  852. mb_igshop.refresh_pages(data)
  853. if tonumber(pc.getqf("pages")) < page then syschat(loadLang(22)) return end
  854. local item = split_(data[((page-1)*5)+slot],"#")
  855. if tonumber(item[1]) != itemID then syschat(loadLang(22)) return end
  856. local sOpen = io.open(igshop_path.."data/"..pc.get_name().."/"..item[1]..".txt", "r")
  857. if sOpen == nil then syschat(loadLang(22)) return end
  858. local tradeItems = {}
  859. for i in sOpen:lines() do
  860. table.insert(tradeItems, i)
  861. end
  862.  
  863. cmdchat("IGSHOP OpenGetDialog/"..itemID.."/"..page.."/"..slot.."/0")
  864. for i = 1, table.getn(tradeItems) do
  865. local thisItem = split_(tradeItems[i], "#")
  866. cmdchat("trade.AppendGetItem "..thisItem[1].." "..thisItem[2].." "..thisItem[3].." "..thisItem[4].." "..thisItem[5].." "..thisItem[6].." "..thisItem[7].." "..thisItem[8].." "..thisItem[9].." "..thisItem[10].." "..thisItem[11].." "..thisItem[12].." "..thisItem[13].." "..thisItem[14].." "..thisItem[15].." "..thisItem[16].." "..thisItem[17].." "..thisItem[18].." "..thisItem[19].." "..thisItem[20].." "..thisItem[21].." "..thisItem[22])
  867. end
  868. end
  869.  
  870. function MakeRequestTrade(itemID, page, slot, group)
  871. for i = 1, table.getn(availableBuyClass) do
  872. if availableBuyClass[i] == group then break end
  873. if i == table.getn(availableBuyClass) then syschat("mb_igshop Error->WrongGroup") syschat(group) return end
  874. end
  875. if group == "get_trade_items" then
  876. mb_igshop.OpenTradeToGet(itemID, page, slot)
  877. return
  878. elseif group == "my_sales" then
  879. mb_igshop.OpenTradeToPreview(itemID, page, slot)
  880. return
  881. end
  882. local data
  883. if group == "Kereses" then
  884. local file = io.open(igshop_path.."data/"..pc.get_name().."/search.txt", "r")
  885. local tbl = {}
  886. for item in file:lines() do
  887. table.insert(tbl, split_(item, "#"))
  888. end
  889. file:close()
  890. data = mb_igshop.searchItem(tbl[1][1],tbl[1][2], page, 2)
  891. else
  892. data = mb_igshop.get_items(group)
  893. end
  894. if table.getn(data) > 0 then
  895. mb_igshop.refresh_pages(data)
  896. if tonumber(pc.getqf("pages")) < page then syschat(loadLang(15)) return end
  897. local item = split_(data[((page-1)*5)+slot],"#")
  898. if tonumber(item[1]) != itemID then syschat(loadLang(15)) return end
  899. if mb_igshop.IsTradeItem(itemID) != 1 then syschat(loadLang(24)) return end
  900. local mOpen = io.open(igshop_path.."tradedata/"..itemID..".txt", r)
  901. if mOpen == nil then return end
  902. local iData = {}
  903. for i in mOpen:lines() do
  904. table.insert(iData, i)
  905. end
  906. if iData == {} then return end
  907.  
  908. mb_igshop.clearAllArraySell(pc.get_player_id())
  909. local safeItemData = {}
  910. table.insert(safeItemData, itemID)
  911. table.insert(safeItemData, page)
  912. table.insert(safeItemData, slot)
  913. table.insert(safeItemData, item[4])
  914. table.insert(safeItemData, tonumber(item[3]))
  915. table.insert(safeItemData, group)
  916. table.insert(safeItemData, data)
  917. mb_igshop.registerSafeItemData(pc.get_player_id(), safeItemData)
  918. local item = {}
  919. cmdchat("IGSHOP OpenTradeDiag")
  920. for x = 1, table.getn(iData) do
  921. item = split_(iData[x], "#")
  922. if not mb_igshop.appendWantsContainer(pc.get_player_id(), item) then syschat(loadLang(25)) return end
  923. cmdchat("trade.SendData "..item[1].." "..item[2].." "..item[3].." "..item[4].." "..item[5].." "..item[6].." "..item[7].." "..item[8].." "..item[9].." "..item[10].." "..item[11].." "..item[12].." "..item[13].." "..item[14].." "..item[15].." "..item[16].." "..item[17].." "..item[18].." "..item[19].." "..item[20].." "..item[21].." "..item[22])
  924. end
  925. else
  926. syschat(loadLang(15))
  927. end
  928. end
  929.  
  930. function IsTradeItem(iID)
  931. local mOpen = io.open(igshop_path.."tradedata/"..iID..".txt", "r")
  932. if mOpen == nil then
  933. return 0
  934. else
  935. return 1
  936. end
  937. end
  938.  
  939. function FindTradeItemAndPut(iName, slot)
  940. local object = mb_igshop.get_itemdata()
  941. local itemIDs = {}
  942. local gtype
  943.  
  944. if string.len(iName) < 2 then syschat(loadLang(26)) return end
  945.  
  946. if iName != "" then
  947. for i = 1, table.getn(object) do
  948. if string.lower(tostring(item_name(tonumber(object[i])))) == iName then
  949. table.insert(itemIDs, tonumber(object[i]))
  950. end
  951. end
  952. if table.getn(itemIDs) < 1 then syschat(loadLang(27)) syschat(string.gsub(iName,"%%","").." ") return end
  953. if table.getn(itemIDs) > 1 then syschat(loadLang(28)) return end
  954. end
  955.  
  956. local iFlag = mb_igshop.get_flag(itemIDs[1])
  957. local flags = {2^14, 2^13, 2^12, 2^11, 2^10, 2^9, 2^8, 2^7, 2^6, 2^5, 2^4, 2^3, 2^2, 2^1, 2^0}
  958. local flag_table = {}
  959. local isStackable = 0
  960.  
  961. table.foreach(flags, function(_, v) if iFlag >= v then table.insert(flag_table, v) iFlag = iFlag - v end end)
  962.  
  963. for i = 1, table.getn(flag_table) do
  964. if flag_table[i] == 4 then isStackable = 1 break end
  965. end
  966.  
  967. local recv = game.mysql_query("SELECT type, subtype, socket_pct FROM "..igshop_player_database_name.."."..igshop_player_item_proto_table_name.." WHERE vnum = '"..itemIDs[1].."' LIMIT 1")
  968. local iType = 0
  969. local iSubType = 0
  970. local maxStoneSlot = 0
  971. if table.getn(recv) != 1 then syschat(loadLang(29)) return end
  972. iType = tonumber(recv[1][1])
  973. iSubType = tonumber(recv[1][2])
  974. maxStoneSlot = tonumber(recv[1][3])
  975.  
  976. local itemVnum = tonumber(itemIDs[1])
  977. if not mb_igshop.check_always_available(itemVnum) then
  978. if not mb_igshop.check_type(iType, iSubType) then syschat(loadLang(57)) return end
  979. if not mb_igshop.check_antiflag(itemVnum) then syschat(loadLang(57)) return end
  980. if not mb_igshop.check_sellableItems(itemVnum) then syschat(loadLang(57)) return end
  981. end
  982. local addOns = 0
  983. if (iType == 1 and iSubType != 6) or (iType == 2 and iSubType == 0) then --stone items
  984. addOns = 2
  985. elseif (iType == 2 and iSubType == 1) or (iType == 2 and iSubType == 2) or (iType == 2 and iSubType == 4) then -- attr only items
  986. addOns = 1
  987. elseif (iType == 2 and iSubType == 3) or (iType == 2 and iSubType == 5) or (iType == 2 and iSubType == 6) then --ore items
  988. addOns = 3
  989. end
  990.  
  991. pc.setqf("lastSearch", itemVnum)
  992. mb_igshop.clearStoneSlotsArray(pc.get_player_id())
  993. cmdchat("trade.ReturnSearchItem "..itemVnum.." "..slot.." "..isStackable.." "..addOns.." "..maxStoneSlot)
  994. end
  995.  
  996. function FindStoneItemAndPut(slot, iName)
  997. local object = mb_igshop.get_itemdata()
  998. local itemIDs = {}
  999. local gtype
  1000.  
  1001. if string.len(iName) < 2 then syschat(loadLang(26)) return end
  1002.  
  1003. if iName != "" then
  1004. for i = 1, table.getn(object) do
  1005. if string.lower(tostring(item_name(tonumber(object[i])))) == iName then
  1006. table.insert(itemIDs, tonumber(object[i]))
  1007. end
  1008. end
  1009. if table.getn(itemIDs) < 1 then syschat(loadLang(27)) syschat(string.gsub(iName,"%%","").." ") return end
  1010. if table.getn(itemIDs) > 1 then syschat(loadLang(28)) return end
  1011. end
  1012.  
  1013. local lastVnum = pc.getqf("lastSearch")
  1014. if lastVnum <= 0 then syschat(loadLang(30)) return end
  1015.  
  1016. local recv = game.mysql_query("SELECT type, subtype, wearflag, applytype0 FROM "..igshop_player_database_name.."."..igshop_player_item_proto_table_name.." WHERE vnum = '"..itemIDs[1].."' LIMIT 1")
  1017. local iType = 0
  1018. local iSubType = 0
  1019. local iWearflag = 0
  1020. local iApplyType = 0
  1021. if table.getn(recv) != 1 then syschat(loadLang(29)) return end
  1022. iType = tonumber(recv[1][1])
  1023. iSubType = tonumber(recv[1][2])
  1024. iWearflag = tonumber(recv[1][3])
  1025. iApplyType = tonumber(recv[1][4])
  1026.  
  1027. if iType != 10 and iSubType != 0 then syschat(loadLang(31)) return end
  1028. if mb_igshop.hasSameSocket(pc.get_player_id(), slot, iApplyType) and itemIDs[1] != 28960 then syschat(loadLang(32)) return end
  1029.  
  1030. local targetType = 0
  1031. local targetSubType = 0
  1032. local socket_pct = 0
  1033. local recv2 = game.mysql_query("SELECT type, subtype, socket_pct FROM "..igshop_player_database_name.."."..igshop_player_item_proto_table_name.." WHERE vnum = '"..lastVnum.."' LIMIT 1")
  1034. if table.getn(recv2) != 1 then syschat(loadLang(29)) return end
  1035. targetType = tonumber(recv2[1][1])
  1036. targetSubType = tonumber(recv2[1][2])
  1037. socket_pct = tonumber(recv2[1][3])
  1038. if socket_pct < slot then syschat(loadLang(33)) return end
  1039. if targetType == 1 and targetSubType != 6 and iWearflag != 16 then
  1040. if itemIDs[1] != 28960 then
  1041. syschat(loadLang(34))
  1042. return
  1043. end
  1044. elseif targetType == 2 and targetSubType == 0 and iWearflag != 1 then
  1045. if itemIDs[1] != 28960 then
  1046. syschat(loadLang(34))
  1047. return
  1048. end
  1049. end
  1050.  
  1051. mb_igshop.registerSocketTempArray(pc.get_player_id(), slot, itemIDs[1], iApplyType)
  1052.  
  1053. cmdchat("trade.ApplySocket "..slot.." "..itemIDs[1])
  1054. end
  1055.  
  1056. ------------------------
  1057. --New trade system End--
  1058. ------------------------
  1059.  
  1060. -- send quest index
  1061. when login begin
  1062. os.setlocale("fr_FR.ISO8859-1","ctype")
  1063. cmdchat("IGShopqID "..q.getcurrentquestindex())
  1064. end
  1065. -----------------
  1066. --Put Item Start-
  1067. -----------------
  1068. function SellItem(priceY, priceS)
  1069. if igshopEnableTrade then mb_igshop.restoreFromSavedSell(pc.get_player_id()) end
  1070. if not mb_igshop.gm_sell_check() then syschat(loadLang(55)) return end
  1071. if not mb_igshop.expandable_limited_storage("get") then syschat(loadLang(2)) return end
  1072. if not mb_igshop.has_itemlist() then mb_igshop.make_igshop() end
  1073. if priceY < 1 and priceS < 1 and not mb_igshop.checkTradeDataSell(pc.get_player_id()) then syschat(loadLang(35)) return end
  1074. local cell = tonumber(pc.getqf("itemcell"))
  1075. if not item.select_cell(cell) then syschat(loadLang(54)) return end
  1076. if item.get_cell() != cell then syschat(loadLang(36)) return end
  1077. if item.get_id() != pc.getqf("sellitemid") then syschat(loadLang(36)) return end
  1078. local attr = {{item.get_attr_type(0), item.get_attr_value(0)}, {item.get_attr_type(1), item.get_attr_value(1)}, {item.get_attr_type(2), item.get_attr_value(2)}, {item.get_attr_type(3), item.get_attr_value(3)},{item.get_attr_type(4), item.get_attr_value(4)},{item.get_attr_type(5), item.get_attr_value(5)}, {item.get_attr_type(6), item.get_attr_value(6)}, {item.get_attr_type(7), item.get_attr_value(7)}}
  1079. local socket, itemVnum, itemCount, itemID = {item.get_socket(0), item.get_socket(1), item.get_socket(2),item.get_socket(3),item.get_socket(4),item.get_socket(5)}, item.get_vnum(), item.get_count(), item.get_id()
  1080.  
  1081. local iType = item.get_type()
  1082. local iSubType = item.get_sub_type()
  1083. if not mb_igshop.check_always_available(itemVnum) then
  1084. if not mb_igshop.check_type(iType, iSubType) then syschat(loadLang(3)) return end
  1085. if not mb_igshop.check_antiflag(itemVnum) then syschat(loadLang(5)) return end
  1086. if not mb_igshop.check_sellableItems(itemVnum) then syschat(loadLang(5)) return end
  1087. end
  1088. for i = 1, 6 do
  1089. if itype == 1 or itype == 2 then
  1090. if tonumber(socket[i]) == 1 then
  1091. socket[i] = 28960
  1092. end
  1093. end
  1094. end
  1095. if pc.count_item(itemVnum) != pc.getqf("itemcount")then syschat(loadLang(36)) return end
  1096. if item.get_cell() != cell then syschat(loadLang(36)) return end
  1097. for i = 1, itemCount do
  1098. item.select_cell(cell)
  1099. item.remove()
  1100.  
  1101. end
  1102. local open = io.open(igshop_path.."data/"..pc.get_name().."/itemlist.txt", "a+")
  1103. open:write(itemID.."#"..itemVnum.."#"..itemCount.."#"..pc.get_name().."#"..priceS.."#"..priceY.."#"..socket[1].."#"..socket[2].."#"..socket[3].."#"..socket[4].."#"..socket[5].."#"..socket[6].."#"..attr[1][1].."#"..attr[1][2].."#"..attr[2][1].."#"..attr[2][2].."#"..attr[3][1].."#"..attr[3][2].."#"..attr[4][1].."#"..attr[4][2].."#"..attr[5][1].."#"..attr[5][2].."#"..attr[6][1].."#"..attr[6][2].."#"..attr[7][1].."#"..attr[7][2].."#"..attr[8][1].."#"..attr[8][2].."#"..pc.get_account_id().."#"..(get_global_time() + 60*60*48).."\\n")
  1104. open:flush()
  1105. open:close()
  1106. local gtype = ""
  1107. if iType == 1 and iSubType != 6 then
  1108. gtype = "Fegyverek"
  1109. elseif iType == 2 and iSubType == 0 then
  1110. gtype = "Vertek"
  1111. elseif iType == 2 and iSubType == 1 then
  1112. gtype = "Sisakok"
  1113. elseif iType == 2 and iSubType == 2 then
  1114. gtype = "Pajzsok"
  1115. elseif iType == 2 and iSubType == 3 then
  1116. gtype = "Karkotok"
  1117. elseif iType == 2 and iSubType == 4 then
  1118. gtype = "Cipok"
  1119. elseif iType == 2 and iSubType == 5 then
  1120. gtype = "Nyaklancok"
  1121. elseif iType == 2 and iSubType == 6 then
  1122. gtype = "Fulbevalok"
  1123. elseif iType == 28 then
  1124. gtype = "Kosztumok"
  1125. else
  1126. gtype = "Egyebek"
  1127. end
  1128. local open = io.open(igshop_path.."data/"..gtype..".txt", "a+")
  1129. open:write(itemID.."#"..itemVnum.."#"..itemCount.."#"..pc.get_name().."#"..priceS.."#"..priceY.."#"..socket[1].."#"..socket[2].."#"..socket[3].."#"..socket[4].."#"..socket[5].."#"..socket[6].."#"..attr[1][1].."#"..attr[1][2].."#"..attr[2][1].."#"..attr[2][2].."#"..attr[3][1].."#"..attr[3][2].."#"..attr[4][1].."#"..attr[4][2].."#"..attr[5][1].."#"..attr[5][2].."#"..attr[6][1].."#"..attr[6][2].."#"..attr[7][1].."#"..attr[7][2].."#"..attr[8][1].."#"..attr[8][2].."#"..pc.get_account_id().."#"..(get_global_time() + 60*60*48).."\\n")
  1130. open:flush()
  1131. open:close()
  1132.  
  1133. if not igshopEnableTrade then cmdchat("IGSHOP recvSuccessSaleItem") return end
  1134. if not mb_igshop.checkTradeDataSell(pc.get_player_id()) then cmdchat("IGSHOP recvSuccessSaleItem") return end
  1135. local tbl = mb_igshop.prepareSellDataForTxt(pc.get_player_id())
  1136. if tbl == {} then syschat("igshop Error -> sell_table_ret_zero") return end
  1137. local open = io.open(igshop_path.."tradedata/"..itemID..".txt", "r")
  1138. if open == nil then
  1139. open = io.open(igshop_path.."tradedata/"..itemID..".txt", "w+")
  1140. for i = 1, table.getn(tbl) do
  1141. open:write(tbl[i][1].."#"..tbl[i][2].."#"..tbl[i][3].."#"..tbl[i][4][1][1].."#"..tbl[i][4][2][1].."#"..tbl[i][4][3][1].."#"..tbl[i][4][4][1].."#"..tbl[i][5][1][1].."#"..tbl[i][5][1][2].."#"..tbl[i][5][2][1].."#"..tbl[i][5][2][2].."#"..tbl[i][5][3][1].."#"..tbl[i][5][3][2].."#"..tbl[i][5][4][1].."#"..tbl[i][5][4][2].."#"..tbl[i][5][5][1].."#"..tbl[i][5][5][2].."#"..tbl[i][5][6][1].."#"..tbl[i][5][6][2].."#"..tbl[i][5][7][1].."#"..tbl[i][5][7][2].."#"..tbl[i][5][8][1].."#"..tbl[i][5][8][2].."\\n")
  1142. end
  1143. open:flush()
  1144. open:close()
  1145. mb_igshop.clearAllArraySell(pc.get_player_id(9))
  1146. cmdchat("IGSHOP recvSuccessSaleItem")
  1147. else
  1148. syschat("igshop Error -> sell_itemID_exists")
  1149. end
  1150. end
  1151.  
  1152. ---------------
  1153. --Put Item End-
  1154. ---------------
  1155.  
  1156. function check_itemc() -- ez a funkció neve, lol
  1157. if igshop_maxitem_per_char == 0 then return true end -- amennyiben maxitem változó értéke 0, nincs limit
  1158. local data = mb_igshop.get_myitems() -- lekérjük a játékos kirakott itemeit tartalmazó txt tartalmát, és táblában kapjuk vissza a sorokat (1 item 1 sor)
  1159. if table.getn(data) >= igshop_maxitem_per_char then -- amennyiben a táblában lévő rekordok száma nagyobb vagy egyenlő mint maxitem változó értéke hamis állítást válaszol a funkció, tehát a visszatérő érték a hamis
  1160. return false
  1161. else -- ellenkező esetben, ha kisebb mint maxitem, igaz értéket küld vissza a funkció
  1162. return true
  1163. end
  1164. end
  1165.  
  1166. function gm_sell_check()
  1167. if not pc.is_gm() or not igshop_gm_sell_check_enabled then return true end
  1168. if igshop_minimum_gm_level_to_sell <= 0 then return false end
  1169. if pc.get_gm_level() < igshop_minimum_gm_level_to_sell then return false end
  1170. return true
  1171. end
  1172.  
  1173. function gm_buy_check()
  1174. if not pc.is_gm() or not igshop_gm_buy_check_enabled then return true end
  1175. if igshop_minimum_gm_level_to_buy <= 0 then return false end
  1176. if pc.get_gm_level() < igshop_minimum_gm_level_to_buy then return false end
  1177. return true
  1178. end
  1179.  
  1180. function get_account_caracters()
  1181. local playersInAccount = {}
  1182. local query = "SELECT name FROM "..igshop_player_database_name.."."..igshop_player_table_name.." WHERE account_id = '"..pc.get_account_id().."' LIMIT "..igshop_player_per_account
  1183. local retQuery = game.mysql_query(query)
  1184. for i = 1, table.getn(retQuery) do
  1185. table.insert(playersInAccount,retQuery[i][1])
  1186. end
  1187. return playersInAccount or {}
  1188. end
  1189.  
  1190. function check_accIC()
  1191. if igshop_maxitem_per_acc == 0 then return true end -- amennyiben maxitem változó értéke 0, nincs limit
  1192. local playersInAccount = mb_igshop.get_account_caracters() -- lekérjük a felhasználón lévő karaktereket
  1193. local total_items = 0 -- ebben a változóban lesz összeadva az összes berakott tárgy
  1194. for i = 1, table.getn(playersInAccount) do -- 1-től x-ig-szer lefuttatja a megadott függvényt, ahol az x értéke egyenlő a karakterek neveit tartalmazó tábla méretével(rekordjainak számával)
  1195. if io.open(igshop_path.."data/"..playersInAccount[i].."/itemlist.txt", "r") != nil then -- ellenőrzi, hogy az aktuális karakternek van e itemlist.txt fájlja, ez azért kell, hogy legyen egyáltalán mit megnyitni, és ne errorozzon
  1196. total_items = table.getn(mb_igshop.get_itemsfromowner(playersInAccount[i])) + total_items -- hozzáadja az aktuális karakter itemlist.txt-ben szerepő tárgyak számát a fent említett változó értékéhez
  1197. end
  1198. end
  1199. if total_items >= igshop_maxitem_per_acc then -- ismét ha nagyobb vagy egyenlő a bepakolt tárgyak száma, mint a berakható tárgyak száma, akkor hamis értéket küld vissza
  1200. return false
  1201. else
  1202. return true
  1203. end
  1204. end
  1205.  
  1206. function check_always_available(vnum)
  1207. if table.getn(igshop_always_available) <= 0 then return false end
  1208. for i = 1, table.getn(igshop_always_available) do
  1209. if igshop_always_available[i] == vnum then return true end
  1210. end
  1211. return false
  1212. end
  1213.  
  1214. function check_antiflag(vnum, only_table)
  1215. if not igshop_enable_antiflag_check and not only_table then return true end
  1216. local antiflags = igshop_antiflag_table -- antiflagok CSÖKKENŐ sorrendben
  1217. local anti_table = {} -- ide kerülnek majd a valódi antiflagok
  1218. local sql = {}
  1219. if string.find(vnum, ";") == nil and string.find(vnum, " ") == nil then
  1220. sql = game.mysql_query("SELECT antiflag FROM "..igshop_player_database_name.."."..igshop_player_item_proto_table_name.." WHERE vnum = '"..vnum.."' LIMIT 1")
  1221. else
  1222. syschat("mb_igshop Error->potential_sql_inject_string#1")
  1223. return false
  1224. end
  1225. local antiflag = tonumber(sql[1][1])
  1226.  
  1227.  
  1228. table.foreach(antiflags, function(_, v) if antiflag >= v then table.insert(anti_table, v) antiflag = antiflag - v end end) -- itt kapjuk meg a valódi antiflagot, a lényeg, hogy ha az antiflag nagyobb vagy egyenlő mint az éppen soron lévő antiflag az antiflags táblából, akkor levonja azt az értéket az mysqlből szedett antiflag értékéből, és beírja ezt az antiflagot az anti_table-ba
  1229.  
  1230. if only_table then return anti_table end
  1231. if table.getn(igshop_antiflag_filter) <= 0 then return true end
  1232. for i = 1, table.getn(anti_table) do
  1233. for x = 1, table.getn(igshop_antiflag_filter) do
  1234. if anti_table[i] == igshop_antiflag_filter[x] then return false end
  1235. end
  1236. end
  1237. return true
  1238. end
  1239.  
  1240. function check_sellableItems(vnum)
  1241. if table.getn(igshop_not_sellable_items) <= 0 then return true end
  1242.  
  1243. for i = 1, table.getn(igshop_not_sellable_items) do
  1244. if igshop_not_sellable_items[i] == vnum then return false end
  1245. end
  1246. return true
  1247. end
  1248.  
  1249. function check_type(item_type, item_sub_type)
  1250. if igshop_enable_type_filtering then
  1251. for i = 1, table.getn(igshop_disabled_types) do
  1252. if igshop_disabled_types[i] == item_type then return false end
  1253. end
  1254. end
  1255.  
  1256. if igshop_enable_sub_type_filtering then
  1257. for i = 1, table.getn(igshop_disabled_sub_types) do
  1258. if igshop_disabled_sub_types[i] == item_sub_type then return false end
  1259. end
  1260. end
  1261.  
  1262. return true
  1263. end
  1264.  
  1265. function char_filters()
  1266. if igshop_enable_char_level_filter and pc.get_level() < igshop_min_level then return false end
  1267. if igshop_enable_char_playtime_filter and pc.get_playtime() < igshop_min_playtime then return false end
  1268.  
  1269. return true
  1270. end
  1271.  
  1272. function get_prevdata()
  1273. local prev_data = 0
  1274. local open2 = io.open(igshop_path.."accids/"..pc.get_account_id().."/storage_limit.txt", "r")
  1275. for line in open2:lines() do
  1276. prev_data = prev_data + tonumber(line)
  1277. end
  1278. open2:close()
  1279. return prev_data
  1280. end
  1281.  
  1282. function expandable_limited_storage(s_type)
  1283. local current_items = 0
  1284.  
  1285. if expandable_limited_storage_enable == 0 and s_type == "get" then
  1286. return true
  1287. elseif expandable_limited_storage_enable == 1 and s_type == "get" then
  1288. local base_limit = base_limit_for_expandable_storage + mb_igshop.get_prevdata()
  1289.  
  1290. local caracters = mb_igshop.get_account_caracters()
  1291.  
  1292. for i = 1, table.getn(caracters) do
  1293. if io.open(igshop_path.."data/"..caracters[i].."/itemlist.txt", "r") != nil then -- ellenőrzi, hogy az aktuális karakternek van e itemlist.txt fájlja, ez azért kell, hogy legyen egyáltalán mit megnyitni, és ne errorozzon
  1294. current_items = table.getn(mb_igshop.get_itemsfromowner(caracters[i])) + current_items -- hozzáadja az aktuális karakter itemlist.txt-ben szerepő tárgyak számát a fent említett változó értékéhez
  1295. end
  1296. end
  1297.  
  1298. if base_limit <= current_items then return false end
  1299.  
  1300. return true
  1301.  
  1302. elseif string.find(tostring(s_type), "set") != nil then
  1303. local a = split_(s_type, "|")
  1304. local old = mb_igshop.get_prevdata()
  1305. local open = io.open(igshop_path.."accids/"..pc.get_account_id().."/storage_limit.txt", "w+")
  1306. open:write(old+tonumber(a[2]))
  1307. open:flush()
  1308. open:close()
  1309. end
  1310. end
  1311.  
  1312. function igshop_gold_manager(what, vnum, count, cell)
  1313. local gold_items = {}
  1314.  
  1315. for i = 1, table.getn(igshop_gold_items) do
  1316. table.insert(gold_items, {})
  1317. table.insert(gold_items[table.getn(gold_items)], igshop_gold_items[i][1])
  1318. table.insert(gold_items[table.getn(gold_items)], igshop_gold_items[i][2])
  1319. table.insert(gold_items[table.getn(gold_items)], igshop_gold_items[i][3])
  1320. end
  1321.  
  1322. if what == "put_in" then
  1323. for i = 1, table.getn(gold_items) do
  1324. if gold_items[i][1] == vnum then
  1325. mb_igshop.set_gold(pc.get_account_id(), gold_items[i][2]*count)
  1326. for i = 1, count do item.select_cell(cell) item.remove() end
  1327. return true
  1328. end
  1329. end
  1330.  
  1331. return false
  1332. elseif what == "get_out" then
  1333. table.sort(gold_items, function(i,v) return i[2]>v[2] end)
  1334. local money = vnum
  1335. local base_money = vnum
  1336.  
  1337. local gold = mb_igshop.get_gold(pc.get_account_id())
  1338. if money > gold then
  1339. syschat(loadLang(37))
  1340. return (-1)
  1341. end
  1342.  
  1343. local temp_money = 0
  1344. local id = pc.get_account_id()
  1345.  
  1346. for i = 1, table.getn(gold_items) do
  1347. if money >= gold_items[i][2] then
  1348. local calculated = math.floor(money / gold_items[i][2])
  1349. gold_items[i][3] = calculated + gold_items[i][3]
  1350. money = money - gold_items[i][2] * calculated
  1351. end
  1352. end
  1353.  
  1354. local append_antiflag = {}
  1355.  
  1356. for i = 1, table.getn(gold_items) do
  1357. if gold_items[i][3] > 0 then
  1358. append_antiflag = mb_igshop.check_antiflag(gold_items[i][1], true)
  1359. for x = 1, table.getn(append_antiflag) do
  1360. if append_antiflag[x] == 32768 then
  1361. table.insert(gold_items[i], 4, false)
  1362. break
  1363. end
  1364. end
  1365.  
  1366. local mItemFlag = game.mysql_query("SELECT flag FROM "..igshop_player_database_name.."."..igshop_player_item_proto_table_name.." WHERE vnum = "..gold_items[i][1].." LIMIT 1")
  1367. local rItemFlag = tonumber(mItemFlag[1][1])
  1368. local fItemFlag = {}
  1369.  
  1370. table.foreach(igshop_flag_table, function(_, v) if rItemFlag >= v then table.insert(fItemFlag, v) rItemFlag = rItemFlag - v end end)
  1371. if table.getn(gold_items[i]) != 4 then
  1372. table.foreachi(fItemFlag, function (pos, val) if val == 4 then table.insert(gold_items[i], 4, true) end end)
  1373. if table.getn(gold_items[i]) != 4 then
  1374. table.insert(gold_items[i], 4, false)
  1375. end
  1376. end
  1377.  
  1378. if gold_items[i][4] then
  1379. while (gold_items[i][3] > 0) do
  1380. if pc.get_empty_inventory_count() < 1 then return (base_money - temp_money) end
  1381. if gold_items[i][3] > 999 then
  1382. temp_money = temp_money + 999 * gold_items[i][2]
  1383. pc.give_item2(gold_items[i][1], 999)
  1384. gold_items[i][3] = gold_items[i][3] - 999
  1385. else
  1386. temp_money = temp_money + gold_items[i][3] * gold_items[i][2]
  1387. pc.give_item2(gold_items[i][1], gold_items[i][3])
  1388. gold_items[i][3] = 0
  1389. end
  1390. end
  1391. else
  1392. while (gold_items[i][3] > 0) do
  1393. if pc.get_empty_inventory_count() < 1 then return (base_money - temp_money) end
  1394. temp_money = temp_money + gold_items[i][2]
  1395. pc.give_item2(gold_items[i][1], 1)
  1396. gold_items[i][3] = gold_items[i][3] - 1
  1397. end
  1398. end
  1399. end
  1400. end
  1401.  
  1402. if 50000000000 < pc.get_gold()+money then return (base_money - temp_money) end
  1403. pc.changemoney(money)
  1404.  
  1405. temp_money = temp_money + money
  1406. money = 0
  1407. return (base_money - temp_money)
  1408. end
  1409. end
  1410.  
  1411. function can_change_name(playerName)
  1412. local tab = mb_igshop.get_itemsfromowner(playerName)
  1413. if table.getn(tab) > 0 then return false end
  1414.  
  1415. local tab2 = {}
  1416. local mOpen = io.open(igshop_path.."data/"..playerName.."/trade_data_list.txt", "r")
  1417. if mOpen != nil then
  1418. for i in mOpen:lines() do
  1419. table.insert(tab2, i)
  1420. end
  1421. if table.getn(tab2) > 0 then return false end
  1422. end
  1423.  
  1424. local tab2 = {}
  1425. local mOpen = io.open(igshop_path.."data/"..playerName.."/boughtitems.txt", "r")
  1426. if mOpen != nil then
  1427. for i in mOpen:lines() do
  1428. table.insert(tab2, i)
  1429. end
  1430. if table.getn(tab2) > 0 then return false end
  1431. end
  1432.  
  1433. return true
  1434. end
  1435.  
  1436. function expand_storage()
  1437. if not igshop_enable_storage_expand then return end
  1438. if item.get_vnum() <= 0 then return end
  1439. for i = 1, table.getn(igshop_storage_expand_table) do
  1440. if vnum == igshop_storage_expand_table[i][1] then
  1441. mb_igshop.expandable_limited_storage("set|"..igshop_storage_expand_table[i][2])
  1442. item.remove()
  1443. break
  1444. end
  1445. end
  1446. end
  1447.  
  1448. function openallrecord()
  1449. local records = {}
  1450. local file = io.open(igshop_path.."data/Fegyverek.txt", "r")
  1451. for items in file:lines() do
  1452. table.insert(records, items)
  1453. end
  1454. file:close()
  1455. file = io.open(igshop_path.."data/Egyebek.txt", "r")
  1456. for items in file:lines() do
  1457. table.insert(records, items)
  1458. end
  1459. file:close()
  1460. file = io.open(igshop_path.."data/Vertek.txt", "r")
  1461. for items in file:lines() do
  1462. table.insert(records, items)
  1463. end
  1464. file:close()
  1465. file = io.open(igshop_path.."data/Cipok.txt", "r")
  1466. for items in file:lines() do
  1467. table.insert(records, items)
  1468. end
  1469. file:close()
  1470. file = io.open(igshop_path.."data/Karkotok.txt", "r")
  1471. for items in file:lines() do
  1472. table.insert(records, items)
  1473. end
  1474. file:close()
  1475. file = io.open(igshop_path.."data/Pajzsok.txt", "r")
  1476. for items in file:lines() do
  1477. table.insert(records, items)
  1478. end
  1479. file:close()
  1480. file = io.open(igshop_path.."data/Fulbevalok.txt", "r")
  1481. for items in file:lines() do
  1482. table.insert(records, items)
  1483. end
  1484. file:close()
  1485. file = io.open(igshop_path.."data/Kosztumok.txt", "r")
  1486. for items in file:lines() do
  1487. table.insert(records, items)
  1488. end
  1489. file:close()
  1490. file = io.open(igshop_path.."data/Nyaklancok.txt", "r")
  1491. for items in file:lines() do
  1492. table.insert(records, items)
  1493. end
  1494. file:close()
  1495. file = io.open(igshop_path.."data/Sisakok.txt", "r")
  1496. for items in file:lines() do
  1497. table.insert(records, items)
  1498. end
  1499. file:close()
  1500. return records or 0
  1501. end
  1502.  
  1503. function searchItem(oname, iname, page, ftype)
  1504. local data = {}
  1505. local tempdata1, tempdata2, tempdata3, tempdata4, tempdata5, tempdata6, tempdata7, tempdata8, tempdata9, tempdata10 = {}
  1506. local object = mb_igshop.get_itemdata()
  1507. local itemIDs = {}
  1508. local gtype
  1509.  
  1510. if string.len(iname) < 2 and oname == "" then syschat(loadLang(26)) return end
  1511.  
  1512. if iname != "" then
  1513. for i = 1, table.getn(object) do
  1514. if string.find(string.lower(tostring(item_name(tonumber(object[i])))), tostring(iname)) != nil then
  1515. table.insert(itemIDs, tonumber(object[i]))
  1516. end
  1517. end
  1518. if table.getn(itemIDs) < 1 then syschat(loadLang(27)) syschat(string.gsub(iname,"%%","").." ") return end
  1519. end
  1520. if oname != "" then
  1521. data = mb_igshop.get_itemsfromowner(oname)
  1522. if table.getn(data) < 1 then syschat(loadLang(38)) return end
  1523. else
  1524. data = mb_igshop.openallrecord()
  1525. if table.getn(data) < 1 then syschat(loadLang(39)) return end
  1526. end
  1527. local records = {}
  1528. local items = {}
  1529. for i = 1, table.getn(data) do
  1530. table.insert(items, split_(data[i], "#"))
  1531. end
  1532. if iname != "" then
  1533. for i = 1, table.getn(data) do
  1534. for x = 1, table.getn(itemIDs) do
  1535. if tonumber(items[i][2]) == itemIDs[x] then
  1536. table.insert(records, data[i])
  1537. end
  1538. end
  1539. end
  1540. else
  1541. records = data
  1542. end
  1543.  
  1544. if table.getn(records) < 1 then syschat(loadLang(40)) return end
  1545. mb_igshop.refresh_pages(records)
  1546. if page > tonumber(pc.getqf("pages")) then page = tonumber(pc.getqf("pages")) end
  1547. if ftype == 1 then
  1548. mb_igshop.add_items(tonumber(pc.getqf("pages")), page, records, tonumber(pc.getqf("itemsOnLastPage")), "SpecS")
  1549. cmdchat("IGSHOP MANAGEPAGES/"..tonumber(pc.getqf("pages")).."/"..page)
  1550. cmdchat("IGSHOP SETGOLD/"..mb_igshop.get_gold(pc.get_account_id()))
  1551. cmdchat("IGSHOP SETCASH/"..get_coins())
  1552. else
  1553. return records or 0
  1554. end
  1555.  
  1556. end
  1557.  
  1558. function ClaimItem(id, page, slot)
  1559. local data = mb_igshop.get_myboughtitems()
  1560. if table.getn(data) > 0 then
  1561. mb_igshop.refresh_pages(data)
  1562. if tonumber(pc.getqf("pages")) < page then
  1563. syschat(loadLang(41))
  1564. else
  1565. local itema = split_(data[((page-1)*5)+slot],"#")
  1566. if tonumber(itema[1]) != id then
  1567. syschat(loadLang(41))
  1568. else
  1569. if pc.get_empty_inventory_count() < 3 then syschat(loadLang(42)) return end
  1570. if not pc.give_item_with(tonumber(itema[2]), tonumber(itema[3]), itema[13], itema[14], itema[15], itema[16], itema[17], itema[18], itema[19], itema[20], itema[21], itema[22], itema[23], itema[24], itema[25], itema[26], itema[26], itema[27], itema[7], itema[8], itema[9], itema[10]) then syschat("<Kereskedőház> Nem sikerült átvenni a tárgyat!") end
  1571. mb_igshop.RemoveAfterClaim(tostring(pc.get_name()), id, 1, 1)
  1572. cmdchat("IGSHOP REFRESHAFTERBUY")
  1573. syschat(loadLang(43))
  1574. end
  1575. end
  1576. else
  1577. syschat(loadLang(41))
  1578. end
  1579. end
  1580.  
  1581. function ClaimMyItem(id, page, slot)
  1582. local data = mb_igshop.get_myitems()
  1583. if table.getn(data) > 0 then
  1584. mb_igshop.refresh_pages(data)
  1585. if tonumber(pc.getqf("pages")) < page then
  1586. syschat(loadLang(44))
  1587. else
  1588. local itema = split_(data[((page-1)*5)+slot],"#")
  1589. if tonumber(itema[1]) != id then
  1590. syschat(loadLang(44))
  1591. else
  1592. if pc.get_empty_inventory_count() < 3 then syschat(loadLang(42)) return end
  1593. if not pc.give_item_with(tonumber(itema[2]), tonumber(itema[3]), itema[13], itema[14], itema[15], itema[16], itema[17], itema[18], itema[19], itema[20], itema[21], itema[22], itema[23], itema[24], itema[25], itema[26], itema[27], itema[28], itema[7], itema[8], itema[9], itema[10]) then syschat("<Kereskedőház> Nem sikerült átvenni a tárgyat!") end
  1594. local iType = mb_igshop.get_type(itema[2])
  1595. local iSubType = mb_igshop.get_sub_type(itema[2])
  1596. local gtype = ""
  1597. if iType == 1 and iSubType != 6 then
  1598. gtype = "Fegyverek"
  1599. elseif iType == 2 and iSubType == 0 then
  1600. gtype = "Vertek"
  1601. elseif iType == 2 and iSubType == 1 then
  1602. gtype = "Sisakok"
  1603. elseif iType == 2 and iSubType == 2 then
  1604. gtype = "Pajzsok"
  1605. elseif iType == 2 and iSubType == 3 then
  1606. gtype = "Karkotok"
  1607. elseif iType == 2 and iSubType == 4 then
  1608. gtype = "Cipok"
  1609. elseif iType == 2 and iSubType == 5 then
  1610. gtype = "Nyaklancok"
  1611. elseif iType == 2 and iSubType == 6 then
  1612. gtype = "Fulbevalok"
  1613. elseif iType == 28 then
  1614. gtype = "Kosztumok"
  1615. else
  1616. gtype = "Egyebek"
  1617. end
  1618. mb_igshop.ItemRemoveFromGTxt(gtype, id)
  1619. mb_igshop.ItemRemoveFromOwnerTxt(tostring(pc.get_name()), id, 1, 1)
  1620. if mb_igshop.IsTradeItem(tonumber(id)) then os.remove(igshop_path.."tradedata/"..id..".txt") end
  1621. cmdchat("IGSHOP REFRESHAFTERBUY")
  1622. syschat(loadLang(45))
  1623. end
  1624. end
  1625. else
  1626. syschat(loadLang(46))
  1627. end
  1628. end
  1629.  
  1630. function BuyItem(id, buytype, page, slot, count, money, group)
  1631. if math.floor(count) != count then syschat(loadLang(47)) return end
  1632. local data
  1633. if group == "Kereses" then
  1634. local file = io.open(igshop_path.."data/"..pc.get_name().."/search.txt", "r")
  1635. local tbl = {}
  1636. for item in file:lines() do
  1637. table.insert(tbl, split_(item, "#"))
  1638. end
  1639. file:close()
  1640. data = mb_igshop.searchItem(tbl[1][1],tbl[1][2], page, 2)
  1641. else
  1642. data = mb_igshop.get_items(group)
  1643. end
  1644. if table.getn(data) > 0 then
  1645. mb_igshop.refresh_pages(data)
  1646. if tonumber(pc.getqf("pages")) < page then
  1647. syschat(loadLang(15))
  1648. else
  1649. local item = split_(data[((page-1)*5)+slot],"#")
  1650. if tonumber(item[1]) != id then
  1651. syschat(loadLang(15))
  1652. else
  1653. if buytype == "CASH" then
  1654. if money < tonumber(item[5])*count then
  1655. cmdchat("IGSHOP SETCASH/"..money)
  1656. syschat(loadLang(48))
  1657. else
  1658. if count > tonumber(item[3]) then
  1659. syschat(loadLang(49)..tonumber(item[3])..loadLangOnly(50))
  1660. elseif count > 0 then
  1661. if igshopEnableTrade then
  1662. if mb_igshop.IsTradeItem(id) == 1 then count = tonumber(item[3]) end
  1663. end
  1664. set_coins(money - tonumber(item[5])*count)
  1665. mb_igshop.set_coins_accid(tonumber(item[5])*count, tonumber(item[27]))
  1666. mb_igshop.GiveItemToTxt(tostring(data[((page-1)*5)+slot]), count, tonumber(item[3]))
  1667. mb_igshop.ItemRemoveFromGroupTxt(group, data, ((page-1)*5)+slot, count, tonumber(item[3]))
  1668. mb_igshop.ItemRemoveFromOwnerTxt(tostring(item[4]), id, count, tonumber(item[3]))
  1669. cmdchat("IGSHOP REFRESHAFTERBUY")
  1670. syschat(loadLang(51))
  1671. end
  1672. end
  1673. else
  1674. if money < tonumber(item[6])*count then
  1675. cmdchat("IGSHOP SETGOLD/"..money)
  1676. syschat(loadLang(52))
  1677. else
  1678. if count > tonumber(item[3]) then
  1679. syschat(loadLang(49)..tonumber(item[3])..loadLangOnly(50))
  1680. elseif count > 0 then
  1681. if igshopEnableTrade then
  1682. if mb_igshop.IsTradeItem(id) == 1 then count = tonumber(item[3]) end
  1683. end
  1684. mb_igshop.GiveItemToTxt(tostring(data[((page-1)*5)+slot]), count, tonumber(item[3]))
  1685. mb_igshop.ItemRemoveFromGroupTxt(group, data, ((page-1)*5)+slot, count, tonumber(item[3]))
  1686. mb_igshop.ItemRemoveFromOwnerTxt(tostring(item[4]), id, count, tonumber(item[3]))
  1687. cmdchat("IGSHOP REFRESHAFTERBUY")
  1688. mb_igshop.set_gold(tonumber(item[27]), tonumber(item[6]*count))
  1689. mb_igshop.set_gold(pc.get_account_id(), 0 - tonumber(item[6])*count)
  1690. syschat(loadLang(51))
  1691. end
  1692. end
  1693. end
  1694. end
  1695. end
  1696. else
  1697. syschat(loadLang(15))
  1698. end
  1699. end
  1700.  
  1701. function get_type(vnum)
  1702. if string.find(vnum, ";") == nil and string.find(vnum, " ") == nil then
  1703. local tbl = 0
  1704. local query = game.mysql_query("SELECT type FROM "..igshop_player_database_name.."."..igshop_player_item_proto_table_name.." WHERE vnum = '"..vnum.."' LIMIT 1")
  1705. tbl = tonumber(query[1][1])
  1706. return tbl
  1707. else
  1708. syschat("mb_igshop Error->potential_sql_inject_string#2")
  1709. return 0
  1710. end
  1711. end
  1712.  
  1713. function get_sub_type(vnum)
  1714. if string.find(vnum, ";") == nil and string.find(vnum, " ") == nil then
  1715. local tbl = 0
  1716. local query = game.mysql_query("SELECT subtype FROM "..igshop_player_database_name.."."..igshop_player_item_proto_table_name.." WHERE vnum = '"..vnum.."' LIMIT 1")
  1717. tbl = tonumber(query[1][1])
  1718. return tbl
  1719. else
  1720. syschat("mb_igshop Error->potential_sql_inject_string#3")
  1721. return false
  1722. end
  1723. end
  1724.  
  1725. function get_flag(vnum)
  1726. if string.find(vnum, ";") == nil and string.find(vnum, " ") == nil then
  1727. local tbl = 0
  1728. local query = game.mysql_query("SELECT flag FROM "..igshop_player_database_name.."."..igshop_player_item_proto_table_name.." WHERE vnum = '"..vnum.."' LIMIT 1")
  1729. tbl = tonumber(query[1][1])
  1730. return tbl
  1731. else
  1732. syschat("mb_igshop Error->potential_sql_inject_string#4")
  1733. return false
  1734. end
  1735. end
  1736.  
  1737. function ItemRemoveFromGroupTxt(group, data, line, count, all)
  1738.  
  1739. local items = {}
  1740. for i = 1 , table.getn(data) do
  1741. table.insert(items,split_(data[i],"#"))
  1742. end
  1743. local id = tonumber(items[line][1])
  1744.  
  1745. if group == "Kereses" then
  1746. local iType = mb_igshop.get_type(tonumber(items[line][2]))
  1747. local iSubType = mb_igshop.get_sub_type(tonumber(items[line][2]))
  1748. local gtype = ""
  1749. if iType == 1 and iSubType != 6 then
  1750. gtype = "Fegyverek"
  1751. elseif iType == 2 and iSubType == 0 then
  1752. gtype = "Vertek"
  1753. elseif iType == 2 and iSubType == 1 then
  1754. gtype = "Sisakok"
  1755. elseif iType == 2 and iSubType == 2 then
  1756. gtype = "Pajzsok"
  1757. elseif iType == 2 and iSubType == 3 then
  1758. gtype = "Karkotok"
  1759. elseif iType == 2 and iSubType == 4 then
  1760. gtype = "Cipok"
  1761. elseif iType == 2 and iSubType == 5 then
  1762. gtype = "Nyaklancok"
  1763. elseif iType == 2 and iSubType == 6 then
  1764. gtype = "Fulbevalok"
  1765. elseif iType == 28 then
  1766. gtype = "Kosztumok"
  1767. else
  1768. gtype = "Egyebek"
  1769. end
  1770. items = {}
  1771. group = gtype
  1772. data = mb_igshop.get_items(gtype)
  1773. for i = 1 , table.getn(data) do
  1774. table.insert(items,split_(data[i],"#"))
  1775. end
  1776.  
  1777. for i = 1, table.getn(items) do
  1778. if tonumber(items[i][1]) == id then
  1779. if all > 1 and all != count then
  1780. local oldcount = tonumber(items[i][3])
  1781. items[i][3] = tostring(oldcount - count)
  1782. else
  1783. table.remove(items, i)
  1784. end
  1785. break
  1786. end
  1787. end
  1788. else
  1789. if all > 1 and all != count then
  1790. local oldcount = tonumber(items[line][3])
  1791. items[line][3] = tostring(oldcount - count)
  1792. else
  1793. table.remove(items, line)
  1794. end
  1795. end
  1796. local open = io.open(igshop_path.."data/"..group..".txt", "w+")
  1797. for i = 1, table.getn(items) do
  1798. open:write(items[i][1]..'#'..items[i][2]..'#'..items[i][3]..'#'..items[i][4]..'#'..items[i][5]..'#'..items[i][6]..'#'..items[i][7]..'#'..items[i][8]..'#'..items[i][9]..'#'..items[i][10]..'#'..items[i][11]..'#'..items[i][12]..'#'..items[i][13]..'#'..items[i][14]..'#'..items[i][15]..'#'..items[i][16]..'#'..items[i][17]..'#'..items[i][18]..'#'..items[i][19]..'#'..items[i][20]..'#'..items[i][21]..'#'..items[i][22]..'#'..items[i][23]..'#'..items[i][24]..'#'..items[i][25]..'#'..items[i][26]..'#'..items[i][27]..'#'..items[i][28]..'#'..items[i][29]..'#'..items[i][30]..'\\n')
  1799. end
  1800. open:flush()
  1801. open:close()
  1802. end
  1803.  
  1804. function ItemRemoveFromGTxt(group, id)
  1805.  
  1806. local data = mb_igshop.get_items(group)
  1807. local open = io.open(igshop_path.."data/"..group..".txt", "w+")
  1808. local items = {}
  1809. for i = 1 , table.getn(data) do
  1810. table.insert(items,split_(data[i],"#"))
  1811. end
  1812.  
  1813. for i = 1, table.getn(items) do
  1814. if tonumber(items[i][1]) == id then
  1815. table.remove(items, i)
  1816. break
  1817. end
  1818. end
  1819.  
  1820. for i = 1, table.getn(items) do
  1821. open:write(items[i][1]..'#'..items[i][2]..'#'..items[i][3]..'#'..items[i][4]..'#'..items[i][5]..'#'..items[i][6]..'#'..items[i][7]..'#'..items[i][8]..'#'..items[i][9]..'#'..items[i][10]..'#'..items[i][11]..'#'..items[i][12]..'#'..items[i][13]..'#'..items[i][14]..'#'..items[i][15]..'#'..items[i][16]..'#'..items[i][17]..'#'..items[i][18]..'#'..items[i][19]..'#'..items[i][20]..'#'..items[i][21]..'#'..items[i][22]..'#'..items[i][23]..'#'..items[i][24]..'#'..items[i][25]..'#'..items[i][26]..'#'..items[i][27]..'#'..items[i][28]..'#'..items[i][29]..'#'..items[i][30]..'\\n')
  1822. end
  1823. open:flush()
  1824. open:close()
  1825. end
  1826.  
  1827. function RemoveAfterClaim(owner, id, count, all)
  1828. local data = mb_igshop.get_myboughtitems()
  1829. local open = io.open(igshop_path.."data/"..owner.."/boughtitems.txt", "w+")
  1830. local items = {}
  1831. for i = 1 , table.getn(data) do
  1832. table.insert(items,split_(data[i],"#"))
  1833. end
  1834.  
  1835. for i = 1, table.getn(items) do
  1836. if tonumber(items[i][1]) == id then
  1837. if all > 1 and all != count then
  1838. local oldcount = tonumber(items[i][3])
  1839. items[i][3] = tostring(oldcount - count)
  1840. else
  1841. table.remove(items, i)
  1842. end
  1843. break
  1844. end
  1845. end
  1846.  
  1847. for i = 1, table.getn(items) do
  1848. open:write(items[i][1]..'#'..items[i][2]..'#'..items[i][3]..'#'..items[i][4]..'#'..items[i][5]..'#'..items[i][6]..'#'..items[i][7]..'#'..items[i][8]..'#'..items[i][9]..'#'..items[i][10]..'#'..items[i][11]..'#'..items[i][12]..'#'..items[i][13]..'#'..items[i][14]..'#'..items[i][15]..'#'..items[i][16]..'#'..items[i][17]..'#'..items[i][18]..'#'..items[i][19]..'#'..items[i][20]..'#'..items[i][21]..'#'..items[i][22]..'#'..items[i][23]..'#'..items[i][24]..'#'..items[i][25]..'#'..items[i][26]..'#'..items[i][27]..'#'..items[i][28]..'#'..items[i][29]..'#'..items[i][30]..'\\n')
  1849. end
  1850. open:flush()
  1851. open:close()
  1852. end
  1853.  
  1854. function ItemRemoveFromOwnerTxt(owner, id, count, all)
  1855. local data = mb_igshop.get_itemsfromowner(owner)
  1856. local items = {}
  1857. for i = 1 , table.getn(data) do
  1858. table.insert(items,split_(data[i],"#"))
  1859. end
  1860.  
  1861. for i = 1, table.getn(items) do
  1862. if tonumber(items[i][1]) == id then
  1863. if all > 1 and all != count then
  1864. local oldcount = tonumber(items[i][3])
  1865. items[i][3] = tostring(oldcount - count)
  1866. else
  1867. table.remove(items, i)
  1868. end
  1869. break
  1870. end
  1871. end
  1872.  
  1873. local open = io.open(igshop_path.."data/"..owner.."/itemlist.txt", "w+")
  1874. for i = 1, table.getn(items) do
  1875. open:write(items[i][1]..'#'..items[i][2]..'#'..items[i][3]..'#'..items[i][4]..'#'..items[i][5]..'#'..items[i][6]..'#'..items[i][7]..'#'..items[i][8]..'#'..items[i][9]..'#'..items[i][10]..'#'..items[i][11]..'#'..items[i][12]..'#'..items[i][13]..'#'..items[i][14]..'#'..items[i][15]..'#'..items[i][16]..'#'..items[i][17]..'#'..items[i][18]..'#'..items[i][19]..'#'..items[i][20]..'#'..items[i][21]..'#'..items[i][22]..'#'..items[i][23]..'#'..items[i][24]..'#'..items[i][25]..'#'..items[i][26]..'#'..items[i][27]..'#'..items[i][28]..'#'..items[i][29]..'#'..items[i][30]..'\\n')
  1876. end
  1877. open:flush()
  1878. open:close()
  1879. end
  1880.  
  1881. function GiveItemToTxt(data, count, all)
  1882. if all >= 1 then
  1883. local items = {}
  1884. table.insert(items,split_(data,"#"))
  1885.  
  1886. local myitemsTable = {}
  1887. local myitems = mb_igshop.get_myboughtitems()
  1888. for i = 1, table.getn(myitems) do
  1889. table.insert(myitemsTable, split_(myitems[i], "#"))
  1890. end
  1891.  
  1892. alertson = 0
  1893. for i = 1, table.getn(myitemsTable) do
  1894. if tonumber(myitemsTable[i][1]) == tonumber(items[1][1]) then
  1895. myitemsTable[i][3] = tonumber(myitemsTable[i][3]) + count
  1896. alertson = 1
  1897. break
  1898. end
  1899. end
  1900. if alertson == 0 then
  1901. if all != count then
  1902. local open = io.open(igshop_path.."data/"..pc.get_name().."/boughtitems.txt", "a+")
  1903. for i = 1, table.getn(items) do
  1904. open:write(items[i][1]..'#'..items[i][2]..'#'..count..'#'..items[i][4]..'#'..items[i][5]..'#'..items[i][6]..'#'..items[i][7]..'#'..items[i][8]..'#'..items[i][9]..'#'..items[i][10]..'#'..items[i][11]..'#'..items[i][12]..'#'..items[i][13]..'#'..items[i][14]..'#'..items[i][15]..'#'..items[i][16]..'#'..items[i][17]..'#'..items[i][18]..'#'..items[i][19]..'#'..items[i][20]..'#'..items[i][21]..'#'..items[i][22]..'#'..items[i][23]..'#'..items[i][24]..'#'..items[i][25]..'#'..items[i][26]..'#'..items[i][27]..'#'..items[i][28]..'#'..items[i][29]..'#'..items[i][30]..'\\n')
  1905. end
  1906. open:flush()
  1907. open:close()
  1908. else
  1909. local open = io.open(igshop_path.."data/"..pc.get_name().."/boughtitems.txt", "a+")
  1910. open:write(data.."\\n")
  1911. open:flush()
  1912. open:close()
  1913. end
  1914. else
  1915. local open = io.open(igshop_path.."data/"..pc.get_name().."/boughtitems.txt", "w+")
  1916.  
  1917. for i = 1, table.getn(myitemsTable) do
  1918. open:write(myitemsTable[i][1]..'#'..myitemsTable[i][2]..'#'..myitemsTable[i][3]..'#'..myitemsTable[i][4]..'#'..myitemsTable[i][5]..'#'..myitemsTable[i][6]..'#'..myitemsTable[i][7]..'#'..myitemsTable[i][8]..'#'..myitemsTable[i][9]..'#'..myitemsTable[i][10]..'#'..myitemsTable[i][11]..'#'..myitemsTable[i][12]..'#'..myitemsTable[i][13]..'#'..myitemsTable[i][14]..'#'..myitemsTable[i][15]..'#'..myitemsTable[i][16]..'#'..myitemsTable[i][17]..'#'..myitemsTable[i][18]..'#'..myitemsTable[i][19]..'#'..myitemsTable[i][20]..'#'..myitemsTable[i][21]..'#'..myitemsTable[i][22]..'#'..myitemsTable[i][23]..'#'..myitemsTable[i][24]..'#'..myitemsTable[i][25]..'#'..myitemsTable[i][26]..'#'..myitemsTable[i][27]..'#'..myitemsTable[i][28]..'#'..myitemsTable[i][29]..'#'..myitemsTable[i][30]..'\\n')
  1919. end
  1920.  
  1921. open:flush()
  1922. open:close()
  1923. end
  1924. end
  1925. end
  1926.  
  1927. function add_items(maxpage, page, items, itemsOnLastPage, group)
  1928. if page <= 0 then page = 1 end
  1929. if page > maxpage then page = maxpage end
  1930. local from = (page - 1)*5 + 1
  1931. local to = 0
  1932. if maxpage > page then
  1933. to = ((page - 1 )*5) + 5
  1934. else
  1935. to = ((page - 1)*5) + itemsOnLastPage
  1936. end
  1937. local slot = 1
  1938. local item
  1939. local commandL
  1940. if group == "my_buys" then
  1941. commandL = "IGShop_BOUGHTITEMS"
  1942. elseif group == "my_sales" then
  1943. commandL = "IGShop_MYSALES"
  1944. else
  1945. commandL = "IGShop_ITEMS"
  1946. end
  1947.  
  1948. for i = from, to do
  1949. item = split_(items[i],"#")
  1950. if igshopEnableTrade then
  1951. if group == "get_trade_items" then
  1952. cmdchat("trade.GetTradeItems "..slot.." "..item[1].." "..item[2].." "..item[3].." "..item[4].." "..item[5].." "..item[6].." "..item[7].." "..item[8].." "..item[9].." "..item[10].." "..item[11].." "..item[12].." "..item[13].." "..item[14].." "..item[15].." "..item[16].." "..item[17].." "..item[18].." "..item[19].." "..item[20].." "..item[21].." "..item[22].." "..item[23].." "..item[24].." "..item[25].." "..item[26])
  1953. else
  1954. cmdchat(commandL.." "..slot.." "..item[1].." "..item[2].." "..item[3].." "..item[4].." "..item[5].." "..item[6].." "..item[4+3]..' '..item[5+3]..' '..item[6+3]..' '..item[7+3]..' '..item[8+3]..' '..item[9+3]..' '..item[10+3]..' '..item[11+3]..' '..item[12+3]..' '..item[13+3]..' '..item[14+3]..' '..item[15+3]..' '..item[16+3]..' '..item[17+3]..' '..item[18+3]..' '..item[19+3]..' '..item[20+3]..' '..item[21+3]..' '..item[22+3]..' '..item[23+3]..' '..item[24+3]..' '..item[25+3]..' '..item[30]..' '..mb_igshop.IsTradeItem(item[1]))
  1955. end
  1956. else
  1957. cmdchat(commandL.." "..slot.." "..item[1].." "..item[2].." "..item[3].." "..item[4].." "..item[5].." "..item[6].." "..item[4+3]..' '..item[5+3]..' '..item[6+3]..' '..item[7+3]..' '..item[8+3]..' '..item[9+3]..' '..item[10+3]..' '..item[11+3]..' '..item[12+3]..' '..item[13+3]..' '..item[14+3]..' '..item[15+3]..' '..item[16+3]..' '..item[17+3]..' '..item[18+3]..' '..item[19+3]..' '..item[20+3]..' '..item[21+3]..' '..item[22+3]..' '..item[23+3]..' '..item[24+3]..' '..item[25+3]..' '..item[30]..' -1')
  1958. end
  1959. -- 1. slot, 2. item id, 3. item vnum, 4. item count, 5. owner name, 6. price se, 7. price yang
  1960. slot = slot + 1
  1961. end
  1962. end
  1963.  
  1964. function get_items(group)
  1965. local igshoplist = {}
  1966. local file = io.open(igshop_path.."data/"..group..".txt", "r")
  1967. for item in file:lines() do
  1968. table.insert(igshoplist,item)
  1969. end
  1970. return igshoplist or 0
  1971. end
  1972.  
  1973. function get_itemdata()
  1974. if igshop_itemindex_readlevel == 1 then
  1975. local itemdata = game.mysql_query("SELECT vnum FROM "..igshop_player_database_name.."."..igshop_player_item_proto_table_name)
  1976. local retTable = {}
  1977. for i = 1, table.getn(itemdata) do
  1978. table.insert(retTable, tonumber(itemdata[i][1]))
  1979. end
  1980. return retTable
  1981. elseif igshop_itemindex_readlevel == 2 then
  1982. if igshop_savedVnums == nil then
  1983. local itemdata = game.mysql_query("SELECT vnum FROM "..igshop_player_database_name.."."..igshop_player_item_proto_table_name)
  1984. igshop_savedVnums = {}
  1985. for i = 1, table.getn(itemdata) do
  1986. table.insert(igshop_savedVnums, tonumber(itemdata[i][1]))
  1987. end
  1988. end
  1989. return igshop_savedVnums
  1990. else
  1991. local itemdata = {}
  1992. local mfile = io.open(igshop_path.."itemindex.txt", "r")
  1993. if mfile == nil then syschat("mb_igshop Error->unable_to_read_itemindex.txt") return {} end
  1994. for item in mfile:lines() do
  1995. table.insert(itemdata,tonumber(item))
  1996. end
  1997. return itemdata or 0
  1998. end
  1999. end
  2000. function get_myboughtitems()
  2001. local igshoplist = {}
  2002. local file = io.open(igshop_path.."data/"..pc.get_name().."/boughtitems.txt", "r")
  2003. for item in file:lines() do
  2004. table.insert(igshoplist,item)
  2005. end
  2006. return igshoplist or 0
  2007. end
  2008.  
  2009. function get_myitems()
  2010. local igshoplist = {}
  2011. local file = io.open(igshop_path.."data/"..pc.get_name().."/itemlist.txt", "r")
  2012. for item in file:lines() do
  2013. table.insert(igshoplist,item)
  2014. end
  2015. return igshoplist or 0
  2016. end
  2017.  
  2018. function get_itemsfromowner(owner)
  2019. local igshoplist = {}
  2020. local file = io.open(igshop_path.."data/"..owner.."/itemlist.txt", "r")
  2021. if file == nil then syschat(loadLang(53)) return 0 end
  2022. for item in file:lines() do
  2023. table.insert(igshoplist,item)
  2024. end
  2025. return igshoplist or 0
  2026. end
  2027.  
  2028. when 9005.chat."Tradehouse" begin
  2029. setskin(NOWINDOW)
  2030. mb_igshop.OpenIgShop()
  2031. end
  2032.  
  2033. function OpenIgShop()
  2034. if not mb_igshop.has_itemlist() then mb_igshop.make_igshop() end
  2035. local tradeVar = 0
  2036. if igshopEnableTrade then
  2037. tradeVar = 1
  2038. end
  2039.  
  2040. if pc.getqf("langVar") <= 0 then pc.setqf("langVar", igshop_default_language) end
  2041. cmdchat("IGSHOP OPEN/"..get_coins().."/"..tradeVar.."/"..pc.getqf("langVar"))
  2042. end
  2043.  
  2044. function has_itemlist()
  2045. local igshop = io.open(igshop_path.."data/"..pc.get_name().."/itemlist.txt", "r")
  2046. if igshop == nil then
  2047. return false
  2048. else
  2049. local fix2 = io.open(igshop_path.."data/"..pc.get_name().."/trade_data_list.txt", "r")
  2050. if fix2 == nil then
  2051. fix2 = io.open(igshop_path.."data/"..pc.get_name().."/trade_data_list.txt", "w+")
  2052. fix2:close()
  2053. end
  2054. local fix = io.open(igshop_path.."accids/"..pc.get_account_id().."/storage_limit.txt", "r")
  2055. if fix == nil then
  2056. local open2 = io.open(igshop_path.."accids/"..pc.get_account_id().."/storage_limit.txt", "w+")
  2057. open2:write("0")
  2058. open2:flush()
  2059. open2:close()
  2060. end
  2061. return true
  2062. end
  2063. end
  2064.  
  2065. function make_igshop()
  2066. local igshop1 = io.open(igshop_path.."accids/"..pc.get_account_id().."/gold.txt", "r")
  2067. if igshop1 == nil then
  2068. os.execute("mkdir "..igshop_path.."accids/"..pc.get_account_id())
  2069. local igshop = io.open(igshop_path.."accids/"..pc.get_account_id().."/gold.txt", "w+")
  2070. igshop:write("0")
  2071. igshop:flush()
  2072. igshop:close()
  2073. local open2 = io.open(igshop_path.."accids/"..pc.get_account_id().."/storage_limit.txt", "w+")
  2074. open2:write("0")
  2075. open2:flush()
  2076. open2:close()
  2077. end
  2078.  
  2079. os.execute("mkdir "..igshop_path.."data/"..pc.get_name())
  2080. local igshop = io.open(igshop_path.."data/"..pc.get_name().."/itemlist.txt", "w+")
  2081. igshop:close()
  2082. local igshop = io.open(igshop_path.."data/"..pc.get_name().."/boughtitems.txt", "w+")
  2083. igshop:close()
  2084. local igshop = io.open(igshop_path.."data/"..pc.get_name().."/search.txt", "w+")
  2085. igshop:close()
  2086. local igshop = io.open(igshop_path.."data/"..pc.get_name().."/trade_data_list.txt", "w+")
  2087. igshop:close()
  2088.  
  2089. end
  2090.  
  2091. function get_gold(accid)
  2092. local open = io.open(igshop_path.."accids/"..accid.."/gold.txt", "r")
  2093. for line in open:lines() do
  2094. return tonumber(line)
  2095. end
  2096. end
  2097.  
  2098. function set_gold(accid, gold)
  2099. local oldgold = mb_igshop.get_gold(accid)
  2100. local open = io.open(igshop_path.."accids/"..accid.."/gold.txt", "w+")
  2101. open:write(oldgold+gold)
  2102. open:flush()
  2103. open:close()
  2104. end
  2105.  
  2106. function set_coins_accid(coins, id)
  2107. if string.find(coins, ";") == nil and string.find(coins, " ") == nil and string.find(id, ";") == nil and string.find(id, " ") == nil then
  2108. game.mysql_query("UPDATE "..igshop_account_database_name.."."..igshop_account_table_name.." SET "..igshop_coins_column_name.." = "..igshop_coins_column_name.." + "..tonumber(coins).." WHERE id = "..tonumber(id)..";")
  2109. else
  2110. syschat("mb_igshop Error->potential_sql_inject_string#5")
  2111. end
  2112. return
  2113. end
  2114.  
  2115. function refresh_pages(get)
  2116. local lines = table.getn(get)
  2117. local formated = math.floor(lines/5)
  2118. if formated != lines/5 then
  2119. pc.setqf("pages",formated + 1)
  2120. local tempiOLP = lines - formated * 5
  2121. if formated < 1 then tempiOLP = lines end
  2122. pc.setqf("itemsOnLastPage",tempiOLP)
  2123. else
  2124. pc.setqf("pages",lines/5)
  2125. pc.setqf("itemsOnLastPage",5)
  2126. end
  2127. end
  2128. end
  2129. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement