• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Item name

jestem pro

That is the question
Joined
Apr 20, 2013
Messages
650
Solutions
14
Reaction score
88
Hello. I have a stupid problem.
How can I take the name of a item from the table "items". To the function getItemNameById:
LUA:
local items = {2160, 2158}

           if getPlayerStorageValue(cid, 111234) == -1 then
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Znalazles "..getItemNameById(itemEx).." !")
               doPlayerAddItem(cid, items[math.random(#items)], 1)
               setPlayerStorageValue(cid, 1234, -1)
           else
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Zabij najpierw Bossa, aby otrzymac nagrode.")
           end
       return true
end[/CODE=lua]
 
Solution
Roll a reward before you get it's name, so try like this:
LUA:
local items = {2160, 2158}
           if getPlayerStorageValue(cid, 111234) == -1 then
               local reward = items[math.random(#items)]
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Znalazles "..getItemNameById(reward).." !")
               doPlayerAddItem(cid, reward, 1)
               setPlayerStorageValue(cid, 1234, -1)
           else
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Zabij najpierw Bossa, aby otrzymac nagrode.")
           end
       return true
end
Roll a reward before you get it's name, so try like this:
LUA:
local items = {2160, 2158}
           if getPlayerStorageValue(cid, 111234) == -1 then
               local reward = items[math.random(#items)]
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Znalazles "..getItemNameById(reward).." !")
               doPlayerAddItem(cid, reward, 1)
               setPlayerStorageValue(cid, 1234, -1)
           else
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Zabij najpierw Bossa, aby otrzymac nagrode.")
           end
       return true
end
 
Solution
Back
Top