• 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 Help! [tfs 0.4]

Status
Not open for further replies.

kikol

New Member
Joined
May 3, 2019
Messages
17
Reaction score
0
Killing the boss does not give item, 0 errors in the console

Lua:
local monster = "Magnum Boss"

local t = {
    {8301, 1, chance = 70},
    {2299, 1, chance = 10},
    {2314, 1, chance = 30},
    {11230, 1, chance = 40}
}

function onKill(cid, target, lastHit)
    local chance = math.random(1, 100)
    local r = t[math.random(#t)]
    if isPlayer(cid) and getCreatureName(target) == monster then
        if r.chance >= chance then
            doPlayerAddItem(cid, r[1], r[2], math.random(1, r.count))  
            doPlayerSendTextMessage(cid, 20, "add items from boss.")                  
        end
    end
    return true
end
 
Last edited:
maybe you haven't registered the onKill event to the player, you should do it in the onLogin event not here.
secondly there is the possibility of not getting any items, as you can see each item has a chance, I don't see any with 100, you should try in these cases with items with 100%, so you don't waste time.

third learn to write code with the correct format:

1667939456904.png
 
doPlayerAddItem(cid, r[1], r[2], math.random(1, r.count)) i changed to doPlayerAddItem(cid, r[1], r[2]) and it works, the topic to close
 
Status
Not open for further replies.
Back
Top