Endymionek

Przenośny sklep

Mar 22nd, 2014
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.53 KB | None | 0 0
  1. function item.open_shop(vnum)
  2.     local shopCount = mysql_query("player", "select count(*) from shop_item where shop_vnum = '"..tonumber(vnum).."';")
  3.     local shopItems = mysql_query("player", "select item_vnum, count from shop_item where shop_vnum = '"..tonumber(vnum).."';")
  4.     local tableItem = {}
  5.     -- local tableItemNames = {}
  6.     for i = 1, tonumber(shopCount[1][1]) do
  7.         table.insert(tableItem, item_name(shopItems[i][1])" x"..tonumber(shopItems[i][2]))
  8.     end
  9.    
  10.     table.insert(tableItem, "Zamknij")
  11.     local wybor = select_table(tableItem)
  12.    
  13.     if wybor = tonumber(shopCount[1][1])+1 then
  14.         return
  15.     end
  16.    
  17.     say_title("Sklep przenośny:")
  18.     say()
  19.     say_item(tableItem[wybor][1], shopItems[wybor][1], "")
  20.     say()
  21.     -----------
  22.     local itemPrice = mysql_query("player", "select gold from player where vnum = '"..shopItems[wybor][1].."';")
  23.     local itemSize = mysql_query("player", "select size from player where vnum = '"..shopItems[wybor][1].."';")
  24.     say("Czy chcesz zakupić ten przedmiot za "..(tonumber(itemPrice[1][1]))*(tonumber(shopItems[i][2])).." Yang?")
  25.     say()
  26.     if select("Tak", "Nie") == 1 then
  27.         if pc.get_gold() < (tonumber(itemPrice[1][1]))*(tonumber(shopItems[i][2])) then
  28.             syschat("<Sklep> Nie masz wystarczającej ilości Yang.")
  29.             return
  30.         end
  31.         if pc.get_empty_inventory_count() < tonumber(itemSize[1][1]) then
  32.             syschat("<Sklep> Nie masz wolnego miejscu w ekwipunku.")
  33.             return
  34.         end
  35.         pc.change_gold(-(tonumber(itemPrice[1][1]))*(tonumber(shopItems[i][2])))
  36.         pc.give_item2(shopItems[wybor][1], shopItems[wybor][2])
  37.     end
  38. end
Advertisement
Add Comment
Please, Sign In to add comment