• 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!

Randomize Item

flaviiojr

Active Member
Joined
Jan 20, 2017
Messages
230
Solutions
13
Reaction score
39
LUA:
local rewards = {
    {id = 2160, msg = "aaaaaaaa"},
    {id = 2127, msg = "bbbbbbb"}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    for i = 1, #rewards do
        local items = rewards[i]
        player:addItem(items[math.random(#rewards)], 1)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg[math.random(#rewards)], 1)
    end
    return true
end

how do I run math.random by choosing only one item and executing the respective message when receiving the chosen item ...
I thank you all !

TFS 1.3
 
Back
Top