Jump to content

manif14102

Members
  • Posts

    6
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

manif14102's Achievements

Vic

Vic (3/54)

0

Reputation

  1. local box = { } ; -- table with gui elements of inventory slots -- init draw inventory gui blank slots function getFreeSlot ( x, y ) --func get placing item dimension and return free slot for i, j in ipairs ( box ) do if ( j[4] == false ) and ( x == 1 ) and ( y == 1 ) then return i, j[2], j[3] end --return free id, x, y of slot when placing item has 1x1 dimension end end --show inventory when press key addCommandHandler("inv", function ( ) for i = 1, 25 do -- 25 slots by y for j = 1, 7 do -- 7 slots by x local slotBoxImg = dgsCreateImage( 64 * j, 64 * i, 64, 64, nil, false, scrollpane, tocolor( 255, 255, 121, 50 ) ); -- ? table.insert( box, { slotBoxImg, j, i, false } ); -- link to blank box image, pos x, pos y, slot statement(false is slot free) end end end --[[for example: add item in inventory when player pickup this]] slotid, x, y = getFreeSlot( 1, 1 ); --get free slot box[slotid][4] = true; -- mark slot as used local item = dgsCreateImage( 64 * x, 64 * y, 64, 64, nil, false, scrollpane, tocolor( 255, 235, 1250, 100 ) ); -- draw item icon for example But i dont understand how to match slots if item has dimension > 1, like 3x3 or 5x2. And I'm not sure at all that this algorithm is correct That's what happened so far with two 1x1 items:
  2. Thank you, but I still do not understand how to use this. Will it be normal to create a table for the slots, and when adding an item to the inventory, check with a loop whether the next slot is free if the item is for example 3x3, or is this a bad idea? I tried a couple of algorithms, but something fails.
  3. Hi. What is the best way to make a grid if items can have different cell sizes? Example 1x1, 2x3, 3x3, etc. I use DGS GUI system. First create empty images for slots in the grid, or something else? I can `t get it. Screen of what I want: Thanks.
  4. Hi, I want to authorize a player only by his serial number (without username and password) and I have a question. Which option is better? 1. Take the number through getPlayerSerial and use it as a login: local serial = getPlayerSerial(source) local account = getAccount(serial, "dsfsdfdsf") if account then logIn... else account =... end 2. Or use getAccountsBySerial() local serial = getPlayerSerial(source) local account = getAccountsBySerial(serial) if #account > 1 then logIn... else account =... end something like this. What is the best way to proceed? Or maybe there is some more correct way? Thanks.
  5. Доброго времени суток, пробую реализовать систему инвентаря, на данный момент представляю себе это так. что есть общая таблица со списком всех возможных штук. Вроде такой: local ITEMS = { {id = 1, name = "M4', model="6541", damage="100", ... } } Но суть в том, что у всех предметов ведь могут быть разные свойства. если это оружие - то секция с его характеристиками, если аптечка например - уровень её хила и т.д. Второй вопрос уже касательно содержимого инвентаря каждого игрока. Хочу реализовать это так, что у каждого предмета есть ещё и характеристики, которые уникальны для каждого. Ну например качество, в процентах, если же это еда, то она может быть съедена на половину, да много такого может быть. Какую лучше структуру таблицы использовать в обоих случаях? Пару вариантов попробовал, но они очень уж костыльные выходят. Может кто сталкивался с таким. Спасибо.
  6. Hi, tell me, please, how to do the right thing. I have an inventory system. The first table with all possible items, like this one: --ITEMS DEFENITION local ITEMS = { {id, name, type, weaponID, ...} } Each item has different keys in the table, depending on its type. The players inventory table contains only a link to the item, amount, slot. So, each player can have several identical objects and they stack. But my idea is that each item has a quality, and if two items have a quality of 100%, and one 36%, then it should become independent, as in the example: Water (Quality 100%; Amount 2) Water (Quality 36%; Amount 1) In addition to quality, the subject may have other characteristics, such as modifications to weapons (silencer, sight), etc. How to create this correctly? What structure for the table to use? I need some kind of algorithm or something. Thank, sorry for my English?
×
×
  • Create New...