• 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 need help adding a chance rate to this if its possible! tfs 1.3

fig niggy

New Member
Joined
Nov 9, 2009
Messages
21
Reaction score
1
changing around the unrealistic dream item to make it do what i need if at all possible!
can some one show me or make me a lua with this that adds a chance rate of getting said item so i can make some more rare than others? or is there a better approach to something like this?
 

Attachments

-- edit -> Didn't realise it was TFS 1.3 you were after.
Guess I'll just leave both 0.4 and 1.3

1.3
Lua:
local rewardItems = {
    --[{chance}] = itemid 
    --[{low, high}] -- if chance is equal to or inbetween these 2 numbers, then give item.
    
    -- example chance 1/1700
    --[{1, 1}]  = 13537, -- Bag of Apple Slices
    
    -- example chance 100/1700 aka 1/17
    --[{1, 100}]  = 13537, -- Bag of Apple Slices
    
    
    [{   1,  100}]  = 13537, -- Bag of Apple Slices
    [{ 101,  200}]  = 22609, -- Dream Warden Claw
    [{ 201,  300}]  = 2355,  -- Stuffed Bunny
    [{ 301,  400}]  = 5792,  -- Dice
    [{ 401,  500}]  = 7459,  -- Pair of Earmuffs
    [{ 501,  600}]  = 2111,  -- Snowball
    [{ 601,  700}]  = 2114,  -- Piggy Bank
    [{ 701,  800}]  = 2657,  -- Simple Dress
    [{ 801,  900}]  = 1990,  -- Present
    [{ 901, 1000}]  = 2745,  -- Blue Rose
    [{1001, 1100}]  = 2072,  -- Lute
    [{1101, 1200}]  = 22606, -- Bronze Prison Key
    [{1201, 1300}]  = 22604, -- Silver Prison Key
    [{1301, 1400}]  = 22607, -- Golden Prison Key
    [{1401, 1500}]  = 22396, -- Cluster of Solace
    [{1501, 1600}]  = 7735,  -- Spellwand
    [{1601, 1700}]  = 22605  -- Copper Prision Key
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local rand = math.random(1700)
    for chance, item_id in pairs(rewardItems) do
        if chance[1] <= rand and chance[2] >= rand then
            player:addItem(item_id, 1, true)
            item:remove(1)
            player:getPosition():sendMagicEffect(CONST_ME_BUBBLES)
            return true
        end
    end
    return true
end

0.4
Lua:
local rewardItems = {
    --[{chance}] = itemid
    --[{low, high}] -- if chance is equal to or inbetween these 2 numbers, then give item.
   
    -- example chance 1/1700
    --[{1, 1}]  = 13537, -- Bag of Apple Slices
   
    -- example chance 100/1700 aka 1/17
    --[{1, 100}]  = 13537, -- Bag of Apple Slices
   
   
    [{   1,  100}]  = 13537, -- Bag of Apple Slices
    [{ 101,  200}]  = 22609, -- Dream Warden Claw
    [{ 201,  300}]  = 2355,  -- Stuffed Bunny
    [{ 301,  400}]  = 5792,  -- Dice
    [{ 401,  500}]  = 7459,  -- Pair of Earmuffs
    [{ 501,  600}]  = 2111,  -- Snowball
    [{ 601,  700}]  = 2114,  -- Piggy Bank
    [{ 701,  800}]  = 2657,  -- Simple Dress
    [{ 801,  900}]  = 1990,  -- Present
    [{ 901, 1000}]  = 2745,  -- Blue Rose
    [{1001, 1100}]  = 2072,  -- Lute
    [{1101, 1200}]  = 22606, -- Bronze Prison Key
    [{1201, 1300}]  = 22604, -- Silver Prison Key
    [{1301, 1400}]  = 22607, -- Golden Prison Key
    [{1401, 1500}]  = 22396, -- Cluster of Solace
    [{1501, 1600}]  = 7735,  -- Spellwand
    [{1601, 1700}]  = 22605  -- Copper Prision Key
}

function onUse(cid, item, frompos, item2, topos)
    local rand = math.random(1700)
    for chance, item_id in pairs(rewardItems) do
        if chance[1] <= rand and chance[2] >= rand then
            doPlayerAddItem(cid, item_id, 1)
            doRemoveItem(item.uid, 1)
            doSendMagicEffect(getPlayerPosition(cid), 26)
            return true
        end
    end
    return true
end
 
Last edited:
Back
Top