Advertisement
Guest User

Untitled

a guest
May 30th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.42 KB | None | 0 0
  1. --[[
  2. |---------------------------------------------------------------------------------------|
  3. | __________ _____ |
  4. | \______ \_______ ____ _/ ____\ ____ ______ ______ ____ _______ |
  5. | | ___/\_ __ \ / _ \\ __\_/ __ \ / ___/ / ___// _ \\_ __ \ |
  6. | | | | | \/( <_> )| | \ ___/ \___ \ \___ \( <_> )| | \/ |
  7. | |____| |__| \____/ |__| \___ >/____ >/____ >\____/ |__| |
  8. | \/ \/ \/ |
  9. | ___________ __ |
  10. | \_ _____/ ____ _/ |_ ____ |
  11. | | __)_ / \\ __\_/ __ \ |
  12. | | \| | \| | \ ___/ |
  13. | /_______ /|___| /|__| \___ > |
  14. | \/ \/ \/ |
  15. |---------------------------------------------------------------------------------------|
  16. ]]
  17.  
  18. quest guildstorage begin
  19. state start begin
  20. when login begin
  21. cmdchat("GUILDSTORAGE QID/"..q.getcurrentquestindex())
  22. pc.setqf('login',get_time()+15)
  23. end
  24.  
  25. when 9005.chat. "Magazyn Gildii" begin
  26. setskin(NOWINDOW)
  27. guildstorage.open_gs()
  28. end
  29.  
  30. function open_gs()
  31. if pc.getqf('login') >= get_time() then syschat'Nie możesz używać magazynu gildii przez 15 sekund.' return end --NEU 06.07.2014
  32. if game.get_event_flag('gildenlager') == 0 then syschat'Magazyn Gildii jest wyłączony.' return end
  33. if not pc.has_guild() then syschat'Musisz posiadać gildię żeby korzystać z magazynu.' setskin(NOWINDOW) return end
  34. if not guildstorage.has_guildstorage() then guildstorage.create_guildstorage() end
  35. if pc.is_polymorphed() then syschat'Nie możesz być przemieniony.' return end -- NEW
  36. if pc.is_guild_master() then
  37. cmdchat('GUILDSTORAGE OPEN/1')
  38. else
  39. cmdchat('GUILDSTORAGE OPEN/0')
  40. end
  41. guildstorage.refresh()
  42. pc.setqf("GUILDSTORAGE",1)
  43. end
  44.  
  45. when button begin
  46. if game.get_event_flag('gildenlager') == 0 then syschat'Magazyn Gildii jest wyłączony.' return end
  47. local cmd = guildstorage.client_command(getinput("GUILDSTORAGE QUESTCMD"))
  48. if pc.is_polymorphed() and cmd[1] != 'UPDATE' then syschat'Nie możesz być przemieniony.' return end -- NEW
  49. -- [ITEM]
  50. if cmd[1] == 'TAKE_ITEM' then
  51. if not guildstorage.get_authority(1) then syschat'Nie masz praw.' return end
  52. -- if pc.get_empty_inventory_count() < 3 then syschat'Nie masz wystarczająco dużo miejsca.' return end
  53. local slot = tonumber(cmd[2])+120*tonumber(cmd[3])
  54. local item = guildstorage.get_slot_item(slot)
  55. if not pc.enough_inventory(item[1]) then syschat'Nie masz wystarczająco dużo miejsca.' return end
  56.  
  57. if guildstorage.slot_empty(slot) then syschat'Ten element jest już umieszczony.' return end
  58. if game.get_event_flag('GUILDS_USE_'..pc.get_guild()) == 1 then syschat'Błąd #101' return end
  59. guildstorage.remove_item(slot)
  60. guildstorage.give_item(item)
  61. elseif cmd[1] == 'MOVE_ITEM' then
  62. item.select_cell(tonumber(cmd[3]))
  63. if not guildstorage.get_authority(0) then syschat'Nie masz uprawnień. ' return end
  64. --possible to store the item? antiflag/flag
  65. if cmd[2] == 'INVENTORY' then
  66. if not guildstorage.slot_empty(tonumber(cmd[4])+120*tonumber(cmd[5])) then syschat'Ten slot jest zajęty.' return end
  67. guildstorage.insert_item(tonumber(cmd[3]),tonumber(cmd[4]),tonumber(cmd[5]))
  68. elseif cmd[2] == 'GUILDSTORAGE' then
  69. if not guildstorage.slot_empty(tonumber(cmd[5])+120*tonumber(cmd[6])) then syschat'Ten slot jest zajęty lub przedmiot nie istnieje.' return end
  70. guildstorage.move_item(tonumber(cmd[3])+120*tonumber(cmd[4]),tonumber(cmd[5])+120*tonumber(cmd[6]))
  71. end
  72. -- [MONEY]
  73. elseif cmd[1] == 'TAKE_MONEY' then
  74. if not guildstorage.get_authority(3) then syschat'Nie masz praw.' return end
  75. local old_money = guildstorage.get_money()
  76. if old_money < tonumber(cmd[2]) then syschat'Nie ma tyle Yang.' return end
  77. local new_money = tonumber(cmd[2])
  78. if new_money < 0 then return end
  79. if new_money+pc.get_money() >= 1999999999 then syschat'Nie możesz posiadać 2.000.000.000 Yang.' return end
  80. guildstorage.change_money(-new_money)
  81. pc.change_money(new_money)
  82. guildstorage.add_log(pc.get_name(),'Yang','wypłata',new_money)
  83. cmdchat('GUILDSTORAGE REFRESH_MONEY/'..(old_money-new_money))
  84. elseif cmd[1] == 'GIVE_MONEY' then
  85. if not guildstorage.get_authority(2) then syschat'Nie masz praw.' return end
  86. local old_money = guildstorage.get_money()
  87. local new_money = tonumber(cmd[2])
  88. if new_money < 0 then return end
  89. if new_money > pc.get_money() then syschat'Nie ma tyle Yang.' return end
  90. pc.change_money(-new_money)
  91. guildstorage.change_money(new_money)
  92. guildstorage.add_log(pc.get_name(),'Yang','wpłata',new_money)
  93. cmdchat('GUILDSTORAGE REFRESH_MONEY/'..(old_money+new_money))
  94. -- [MEMBER]
  95. elseif cmd[1] == 'ADD_MEMBER' then
  96. if not pc.is_guild_master() then syschat'Nie jesteś liderem.' return end
  97. local members = guildstorage.get_members()
  98. if table.getn(members) >= 12 then syschat'Możesz wprowadzić maksymalnie 12 członków.' return end
  99. guildstorage.add_member(cmd[2])
  100. cmdchat('GUILDSTORAGE MEMBER_COMPLETE')
  101. elseif cmd[1] == 'DELETE_MEMBER' then
  102. if not pc.is_guild_master() then syschat'Nie jesteś liderem.' return end
  103. guildstorage.delete_member(cmd[2])
  104. cmdchat('GUILDSTORAGE MEMBER_COMPLETE')
  105. elseif cmd[1] == 'AUTHORITY' then
  106. if not pc.is_guild_master() then syschat'Nie jesteś liderem.' return end
  107. guildstorage.set_authority(cmd[2],tonumber(cmd[3]),cmd[4])
  108. local members = guildstorage.get_members()
  109. for i = 1, table.getn(members) do
  110. -- id, membername, authority 1-4
  111. cmdchat('GUILDSTORAGE_ADDMEMBER '..(i-1)..' '..members[i][1]..' '..members[i][2]..' '..members[i][3]..' '..members[i][4]..' '..members[i][5])
  112. end
  113. elseif cmd[1] == 'GETMEMBERLIST' then
  114. if not pc.is_guild_master() then syschat'Nie jesteś liderem.' return end
  115. local members = guildstorage.get_members()
  116. for i = 1, table.getn(members) do
  117. -- id, membername, authority 1-4
  118. cmdchat('GUILDSTORAGE_ADDMEMBER '..(i-1)..' '..members[i][1]..' '..members[i][2]..' '..members[i][3]..' '..members[i][4]..' '..members[i][5])
  119. end
  120. cmdchat('GUILDSTORAGE REFRESH_MEMBERS')
  121. elseif cmd[1] == 'UPDATE' then
  122. guildstorage.refresh_tempslots()
  123. elseif cmd[1] == 'OPEN' then
  124. guildstorage.open_gs()
  125. elseif cmd[1] == 'LOAD_LOGS' then
  126. if not pc.is_guild_master() then syschat'Nie jesteś liderem.' return end
  127. local logs = guildstorage.load_logs()
  128. local logsLen = table.getn(logs)
  129. for i = 0, logsLen-1 do
  130. local var = (logsLen-i)
  131. cmdchat('GUILDSTORAGE_ADDLOG '..(var-1)..' '..logs[var][1]..' '..logs[var][2]..' '..logs[var][3]..' '..logs[var][4]..' '..logs[var][5])
  132. end
  133. elseif cmd[1] == 'DELETE_LOGS' then
  134. if not pc.is_guild_master() then syschat'Nie jesteś liderem.' return end
  135. guildstorage.clear_logs()
  136. end
  137. end
  138.  
  139. function item_can_store(itemvnum)
  140. local antiflags = guildstorage.item_get_real_antiflags(guildstorage.item_antiflag(itemvnum))
  141. local blackListItem = {50821,50822,50823,50824,50825,50826,51002}
  142. for i = 1, table.getn(blackListItem) do
  143. if blackListItem[i] == itemvnum then
  144. return false
  145. end
  146. end
  147. for i = 1 , table.getn(antiflags) do
  148. if antiflags[i] == 128 or antiflags[i] == 131072 or antiflags[i] == 8192 or antiflags[i] == 64 then return false end
  149. -- Wenn das item die Antiflag hat wird es nicht eingelagert.
  150. end
  151. return true
  152. end
  153.  
  154. function item_get_real_antiflags(antiflag_)
  155. antiflags = {131072,65536,32768,16384,8192,4096,2048,1024,512,256,128,64,32,16,8,4,2,1}
  156. tab2 = {}
  157. table.foreach(antiflags,function(_,v) if antiflag_ >= v then table.insert(tab2,v) antiflag_ = antiflag_ - v end end)
  158. return tab2
  159. end
  160.  
  161. function item_antiflag(item_vnum)
  162. local result = mysql_query("SELECT antiflag from player.item_proto where vnum = "..item_vnum..";")
  163. return tonumber(result.antiflag[1])
  164. end
  165.  
  166. ----------------------
  167. --LOGS START
  168. ----------------------
  169.  
  170. function load_logs()
  171. local logs = {}
  172. local gs_logs = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/logs.txt", "r")
  173. for line in gs_logs:lines() do
  174. table.insert(logs,guildstorage.split_(line,"#"))
  175. end
  176. return logs
  177. end
  178.  
  179. function clear_logs()
  180. local gs_log = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/logs.txt", "w+")
  181. gs_log:flush()
  182. gs_log:close()
  183. end
  184.  
  185. function add_log(name_,type_,do_,desc_)
  186. local gs_logs = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/logs.txt", "r")
  187. local lineCount = 0
  188. for line in gs_logs:lines() do
  189. lineCount = lineCount + 1
  190. end
  191. if lineCount >= 1000 then
  192. local gs_log = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/logs.txt", "w+")
  193. gs_log:flush()
  194. gs_log:close()
  195. end
  196. local gs_log = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/logs.txt", "a+")
  197. local date_ = os.date()
  198. date_ = string.gsub(date_," ", "+-+")
  199. desc_ = string.gsub(desc_," ", "+-+")
  200. gs_log:write(name_..'#'..date_..'#'..type_..'#'..do_..'#'..desc_..'\\n')
  201. gs_log:flush()
  202. gs_log:close()
  203. end
  204.  
  205. ----------------------
  206. --LOGS END
  207. ----------------------
  208.  
  209. ----------------------
  210. --MEMBER & AUTHORITY START
  211. ----------------------
  212. -- Auth 0 = einlagern
  213. -- Auth 1 = rausnehmen
  214. -- Auth 2 = einzahlen
  215. -- Auth 3 = auszahlen
  216.  
  217. function get_members()
  218. local members = {}
  219. local gs_member = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/authority.txt", "r")
  220. for line in gs_member:lines() do
  221. table.insert(members,guildstorage.split_(line,"#"))
  222. end
  223. return members
  224. end
  225.  
  226. function get_authority(authID)
  227. if pc.is_guild_master() then return true end
  228. local members = guildstorage.get_members()
  229. for i = 1, table.getn(members) do
  230. if members[i][1] == pc.get_name() then
  231. if tonumber(members[i][authID+2]) == 0 then return false else return true end
  232. end
  233. end
  234. return false
  235. end
  236.  
  237. function set_authority(member,authID,auth)
  238. local members = guildstorage.get_members()
  239. for i = 1, table.getn(members) do
  240. if members[i][1] == member then
  241. members[i][authID+2] = auth
  242. break
  243. end
  244. end
  245. local gs_member = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/authority.txt", "w+")
  246. for i = 1, table.getn(members) do
  247. gs_member:write(members[i][1]..'#'..members[i][2]..'#'..members[i][3]..'#'..members[i][4]..'#'..members[i][5]..'\\n')
  248. end
  249. gs_member:flush()
  250. gs_member:close()
  251. end
  252.  
  253. function add_member(member)
  254. local members = guildstorage.get_members()
  255. for i = 1, table.getn(members) do
  256. if members[i][1] == member then
  257. syschat'Member ist schon eingetragen.'
  258. return
  259. end
  260. end
  261. local gs_member = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/authority.txt", "a+")
  262. gs_member:write(member..'#0#0#0#0\\n')
  263. gs_member:flush()
  264. gs_member:close()
  265. end
  266.  
  267. function delete_member(member)
  268. local members = guildstorage.get_members()
  269. for i = 1, table.getn(members) do
  270. if members[i][1] == member then
  271. table.remove(members,i)
  272. break
  273. end
  274. end
  275. local gs_member = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/authority.txt", "w+")
  276. for i = 1, table.getn(members) do
  277. gs_member:write(members[i][1]..'#'..members[i][2]..'#'..members[i][3]..'#'..members[i][4]..'#'..members[i][5]..'\\n')
  278. end
  279. gs_member:flush()
  280. gs_member:close()
  281. end
  282.  
  283. ----------------------
  284. --MEMBER & AUTHORITY END
  285. ----------------------
  286.  
  287. ----------------------
  288. --MONEY START
  289. ----------------------
  290. function get_money()
  291. local gs_money = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/money.txt", "r")
  292. for line in gs_money:lines() do
  293. return tonumber(line)
  294. end
  295. end
  296.  
  297. function change_money(money)
  298. local old_money = guildstorage.get_money()
  299. local gs_money = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/money.txt", "w+")
  300. gs_money:write(old_money+money)
  301. gs_money:flush()
  302. gs_money:close()
  303. end
  304.  
  305. ----------------------
  306. --MONEY END
  307. ----------------------
  308.  
  309. ----------------------
  310. --STORAGE START
  311. ----------------------
  312.  
  313. function has_guildstorage()
  314. local guildstorage = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/storage.txt", "r")
  315. if guildstorage == nil then
  316. return false
  317. else
  318. return true
  319. end
  320. end
  321.  
  322. function give_item(itemTab)
  323. pc.give_item2_select(itemTab[1],itemTab[2])
  324. local attr,socket = {},{}
  325. for i = 10,23 do table.insert(attr,{itemTab[i],itemTab[i+1]}) i = i+1 end
  326. for i = 4,6 do table.insert(socket,itemTab[i]) end
  327. for i = 1, table.getn(attr) do
  328. item.set_value(i-1, attr[i][1], attr[i][2])
  329. end
  330. for i = 1, table.getn(socket) do if tonumber(socket[i]) > 0 then item.set_socket(i-1, socket[i]) end end
  331. game.set_event_flag('GUILDS_USE_'..pc.get_guild(),0)
  332. end
  333.  
  334. function get_slot_item(slot)
  335. local items = guildstorage.get_items()
  336. for i = 1, table.getn(items) do
  337. local item = guildstorage.split_(items[i],"#")
  338. if tonumber(item[3]) == slot then
  339. return item
  340. end
  341. end
  342. return 0
  343. end
  344.  
  345. function refresh()
  346. cmdchat('GUILDSTORAGE REFRESH_MONEY/'..guildstorage.get_money())
  347. local items = guildstorage.get_items()
  348. if items != 0 then
  349. for i = 1, table.getn(items) do
  350. local item = guildstorage.split_(items[i],"#")
  351. -- chat(table.getn(item))
  352. cmdchat('GUILDSTORAGE_ADDITEM '..item[3]..' '..item[1]..' '..item[2]..' '..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])
  353. end
  354. end
  355. cmdchat('GUILDSTORAGE REFRESH')
  356. end
  357.  
  358. function refresh_tempslots()
  359. cmdchat('GUILDSTORAGE REFRESH_MONEY/'..guildstorage.get_money())
  360. cmdchat('GUILDSTORAGE CLEAR_TEMPSLOTS')
  361. local items = guildstorage.get_items()
  362. if items != 0 then
  363. for i = 1, table.getn(items) do
  364. local item = guildstorage.split_(items[i],"#")
  365. cmdchat('GUILDSTORAGE_ADDTEMPSLOT '..item[3]..' '..item[1]..' '..item[2]..' '..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])
  366. end
  367. end
  368. cmdchat('GUILDSTORAGE COMPARE_TEMPSLOTS')
  369. end
  370.  
  371. function slot_empty(slot)
  372. local itemList = guildstorage.get_items()
  373. for i = 1 , table.getn(itemList) do
  374. local item = guildstorage.split_(itemList[i],"#")
  375. if tonumber(item[3]) == slot then
  376. return false
  377. end
  378. end
  379. return true
  380. end
  381.  
  382. function create_guildstorage()
  383. os.execute("mkdir "..guildstorage_path.."Guildstorage/"..pc.get_guild())
  384. local guildstorage = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/storage.txt", "w+")
  385. local guildstorage = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/money.txt", "w+")
  386. guildstorage:write("0")
  387. guildstorage:close()
  388. local guildstorage = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/authority.txt", "w+")
  389. local guildstorage = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/logs.txt", "w+")
  390. guildstorage:close()
  391. end
  392.  
  393. function insert_item(cell,slot,tab)
  394. local result = item.select_cell(cell)
  395. if not result then syschat'Probier es nochmal.' return end
  396. local itemId1 = item.get_id()
  397. local itemVnum1 = item.get_vnum()
  398. item.select_cell(cell)
  399. local attr = {{item3.get_attr(0)}, {item3.get_attr(1)}, {item3.get_attr(2)}, {item3.get_attr(3)},{item3.get_attr(4)},{item3.get_attr(5)}, {item3.get_attr(6)}}
  400. local socket, itemCount, itemVnum = {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_count(),item.get_vnum()
  401. if itemId1 != item.get_id() or itemVnum1 != itemVnum then syschat'wtf?' return end
  402. if not guildstorage.item_can_store(itemVnum) then syschat'Nie możesz dodać tego przedmiotu.' return end
  403. if itemCount > 1 then
  404. for i = 1, itemCount do
  405. item.remove()
  406. item.select_cell(cell)
  407. end
  408. elseif itemCount == 1 then
  409. item.remove()
  410. else
  411. chat'Fehler'
  412. return
  413. end
  414. cmdchat('GUILDSTORAGE_ADDITEMSLOT '..slot..' '..tab..' '..itemVnum..' '..itemCount..' '..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])
  415. guildstorage.add_log(pc.get_name(),'Item','umieszczenie',item_name(itemVnum)..' ('..itemCount..')')
  416. local guildstorage = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/storage.txt", "a+")
  417. -- syschat(itemVnum.."#"..itemCount.."#"..(slot+120*tab).."#"..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])
  418. guildstorage:write(itemVnum.."#"..itemCount.."#"..(slot+120*tab).."#"..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].."\\n")
  419. guildstorage:flush()
  420. guildstorage:close()
  421. end
  422.  
  423. function remove_item(slot)
  424. game.set_event_flag('GUILDS_USE_'..pc.get_guild(),1)
  425. local gsPath = guildstorage_path.."Guildstorage/"..pc.get_guild().."/storage.txt"
  426. local items = {}
  427. local itemList = guildstorage.get_items()
  428. if slot > 720 then syschat'Ten slot nie istnieje.' return end
  429. for i = 1 , table.getn(itemList) do
  430. table.insert(items,guildstorage.split_(itemList[i],"#"))
  431. end
  432. for i = 1, table.getn(items) do
  433. if items[i][3] == tostring(slot) then
  434. guildstorage.add_log(pc.get_name(),'Item','pobranie',item_name(items[i][1])..' ('..items[i][2]..')')
  435. table.remove(items,i)
  436. break
  437. end
  438. end
  439. local gs = io.open(gsPath, "w+")
  440. for i = 1, table.getn(items) do
  441. gs: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]..'\\n')
  442. end
  443. gs:flush()
  444. gs:close()
  445. end
  446.  
  447. function get_items()
  448. local guildstorageTab = {}
  449. local guildstorage = io.open(guildstorage_path.."Guildstorage/"..pc.get_guild().."/storage.txt", "r")
  450. for item in guildstorage:lines() do
  451. table.insert(guildstorageTab,item)
  452. end
  453. return guildstorageTab or 0
  454. end
  455.  
  456. function move_item(from,to)
  457. local gsPath = guildstorage_path.."Guildstorage/"..pc.get_guild().."/storage.txt"
  458. local items = {}
  459. local itemList = guildstorage.get_items()
  460. for i = 1 , table.getn(itemList) do
  461. table.insert(items,guildstorage.split_(itemList[i],"#"))
  462. end
  463. for i = 1, table.getn(items) do
  464. if items[i][3] == tostring(from) then items[i][3] = tostring(to) end
  465. end
  466. local gs = io.open(gsPath, "w+")
  467. for i = 1, table.getn(items) do
  468. gs: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]..'\\n')
  469. end
  470. gs:flush()
  471. gs:close()
  472. end
  473. ----------------------
  474. --STORAGE END
  475. ----------------------
  476. function client_command(command_)
  477. return guildstorage.split_(command_,"#")
  478. end
  479.  
  480. function split_(string_,delimiter)
  481. local result = { }
  482. local from = 1
  483. local delim_from, delim_to = string.find( string_, delimiter, from )
  484. while delim_from do
  485. table.insert( result, string.sub( string_, from , delim_from-1 ) )
  486. from = delim_to + 1
  487. delim_from, delim_to = string.find( string_, delimiter, from )
  488. end
  489. table.insert( result, string.sub( string_, from ) )
  490. return result
  491. end
  492. end
  493. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement