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

Lua [Solved] Same item with different actionid

exanime

I´m learning Lua
Joined
Oct 24, 2011
Messages
40
Reaction score
3
Location
Bogota, Colombia
Hello, I have come to ask for help, I want the same item that I get from a quest, have different actionid, some help?

It will be an item with different actionid, being the Legendary item with less possibility of being given to the player, also that the description be added

I have this script

TFS 1.3


I still do not handle the metatables very well, any explanation :p ?

Code:
local ids = {
    {thing = "Normal", chance = 85, itemID = 2475, actionID = 45113}, --85%
    {thing = "Bound", chance = 13, itemID = 2475, actionID = 45114}, --13%
    {thing = "Legendary", chance = 2, itemID = 2475, actionID = 45115} --2%
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
     local chance = math.random(1, 100)
    if chance < ids.chance then
    local Legs = player:additem(ids[chance].itemID,1,true, CONST_SLOT_WHEREEVER)
     item:setActionId(Legs, ids[chance].actionID)
     item:setAttribute(Legs, "description", ids[chance].thing)
      player:sendTextMessage(TALKTYPE_ORANGE_1, "Random Legs Acquired!")
     end
     return true
end
 
Solution
try
Code:
local weight = ItemType(ids.itemID):getWeight()


Edit: No it's not gonna work. You're doing this wrong. Hold on.

I have no idea why you compare weight to storage value.


Try this:
Code:
local storage = 10405
local ids = {
    {thing = "Legendary", chance = 2, itemID = 2475, actionID = 45115}, --2%
    {thing = "Bound", chance = 13, itemID = 2475, actionID = 45114}, --13%
    {thing = "Normal", chance = 85, itemID = 2475, actionID = 45113} --85%
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(storage) ~= -1 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
        return true
    end

    local rand = math.random(1, 100)
    for _, chanceItem in...
Back
Top