create_item_storage.lua

main 65 lines · 1.9 KB Raw
Alex Alex Commit Server upload 18/10/2026 23:38
1function onSay(player, words, param)
2
3 local t = param:splitTrimmed(",")
4 if(not t[2]) then
5 player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
6 return false
7 end
8
9 local tid = Player(t[1])
10 if(not tid) then
11 player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " not found.")
12 return false
13 end
14
15 local qnt = 1
16 if(not t[3]) then
17 qnt = 1
18 else
19 if isNumber(t[3]) then
20 qnt = t[3]
21 else
22 qnt = 1
23 end
24 end
25
26 if isNumber(t[2]) then
27 local id = tonumber(t[2])
28 if _ITEMS[id] then
29 local slot = _ITEMS[id].SLOT_EQUIP
30
31 local check = 0
32 for x = 01, _SYSTEM.MAX_BAG_SLOT do
33 if player:getStorageValue(_BACKPACK[slot][00][x].UID_01) <= 0 then
34 if slot == 3 then -- NOT EQUIP
35 tid:setStorageValue(_BACKPACK[slot][00][x].UID_01, tonumber(t[2])) -- ID
36 tid:setStorageValue(_BACKPACK[slot][00][x].UID_02, qnt) -- Qnt
37 tid:setStorageValue(_BACKPACK[slot][00][x].UID_03, math.random(0, 4)) -- Rare
38 tid:setStorageValue(_BACKPACK[slot][00][x].UID_04, math.random(0, 3)) -- Star
39 check = 1
40 break
41 else
42 tid:setStorageValue(_BACKPACK[slot][00][x].UID_01, tonumber(t[2])) -- ID
43 tid:setStorageValue(_BACKPACK[slot][00][x].UID_02, math.random(0, 4)) -- Rare
44 tid:setStorageValue(_BACKPACK[slot][00][x].UID_03, math.random(0, 3)) -- Star
45 check = 1
46 break
47 end
48 end
49 end
50
51 if check == 0 then
52 player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sua backpack esta cheia.")
53 else
54 player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "O player [" .. t[1] .. "] recebeu o item [" .. _ITEMS[id].NAME .. ", x" ..qnt.. "].")
55 end
56 else
57 player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Item não encontrado.")
58 end
59 else
60 player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
61 end
62
63 return false
64end
65
Top