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

Solved Reward Chest System

silveralol

Advanced OT User
Joined
Mar 16, 2010
Messages
1,480
Solutions
9
Reaction score
212
SOLVED

anyone have a reward chest prototype working ?
I'm trying to create this but is hard to divide the damage in map
-.-
using it don't work
Code:
if damage.total >= ((monsterMaxHealth / 100) * 10) and damage.total < ((monsterMaxHealth / 100) * 25) then
I tryed use it: https://otland.net/threads/reward-chest-boss-reward-tfs-1-2.233397/
but don't work properly, so I'm trying make a new way to make it
question ...
how I can make the corpse a virtual depot? to each player open the corpse and get your own reward
I have a small script, he create the loot, put into the bag and send it to player inbox, but I don't know how divide the damage
 
Last edited:
I resolve the problem to divide the loot ... are good !!!
now I need resolve this:
1 - make a reward chest C++ stuff
2 - make the corpse be a temporary reward chest
 
sorry for this bump, but I need to say!
I solve the reward chest stuff, now when I kill ferumbras his reward will go to my reward chest, the last problem is make the corpse be a reward chest temporary
 
My plans are to trade the system for new areas of the global map :eek::eek::eek::eek:

I get some errors:
if i'm killing a boss and logout and login again
give this
Code:
attempt to index local 'attackerPlayer' (a nil value)
how resolve this ? registering in login.lua?
 
Last edited:
My plans are to trade the system for new areas of the global map :eek::eek::eek::eek:

I get some errors:
if i'm killing a boss and logout and login again
give this
Code:
attempt to index local 'attackerPlayer' (a nil value)
how resolve this ? registering in login.lua?
post the script, we can't help you if you don't
 
of course I'll post all my script D:
but this is the for that get the bug
Code:
for pid, damage in pairs(targetMonster:getDamageMap()) do
        local attackerPlayer = Player(pid)
        local monsterMaxHealth = targetMonster:getMaxHealth()
        if attackerPlayer then
            ---------
        end
end
 
Code:
for pid, damage in pairs(targetMonster:getDamageMap()) do
    local attackerPlayer = Player(pid)
    local monsterMaxHealth = targetMonster:getMaxHealth()
    if attackerPlayer ~= nil then
       ---------
    end
end
 
of course I'll post all my script D:
but this is the for that get the bug
Code:
for pid, damage in pairs(targetMonster:getDamageMap()) do
        local attackerPlayer = Player(pid)
        local monsterMaxHealth = targetMonster:getMaxHealth()
        if attackerPlayer then
            ---------
        end
end
TFS 1.2?
This should not be problem. because if its nil then it also means false
I have done thousands of if statements like that, no errors so far
 
TFS 1.2?
This should not be problem. because if its nil then it also means false
I have done thousands of if statements like that, no errors so far
If the guy does not want to post his script, what can we do but band-aide the issues he is having
 
If the guy does not want to post his script, what can we do but band-aide the issues he is having
we cant but copy pasting the same code he just did wont help either xD

theoretically you just changed this:
if true then return true end
into this xD
if not false then return true end
 
we cant but copy pasting the same code he just did wont help either xD

theoretically you just changed this:
if true then return true end
into this xD
if not false then return true end
Actually that isn't the case because any value -1, 0 1, '' etc.. is consider true, but nil is always false in a condition when a variable is used as a condition to meet.
Until we see the whole script we can only speculate.

Maybe it should be
Code:
for pid, damage in pairs(targetMonster:getDamageMap()) do
    local attackerPlayer = Player(pid)
    local monsterMaxHealth = targetMonster:getMaxHealth()
    if attackerPlayer:isPlayer() then
       ---------
    end
end
 
Last edited:
Actually that isn't the case because any value -1, 0 1, '' etc.. is consider true, but nil is always false in a condition when a variable is used as a condition to meet.
Until we see the whole script we can only speculate.

Maybe it should be
Code:
or pid, damage in pairs(targetMonster:getDamageMap()) do
    local attackerPlayer = Player(pid)
    local monsterMaxHealth = targetMonster:getMaxHealth()
    if attackerPlayer ~= nil or attackerPlayer ~= '' then
       ---------
    end
end
He was constructing userdata and its not numerical value. My case stands
 
of course I'll post all my script D:
but this is the for that get the bug
Code:
for pid, damage in pairs(targetMonster:getDamageMap()) do
        local attackerPlayer = Player(pid)
        local monsterMaxHealth = targetMonster:getMaxHealth()
        if attackerPlayer then
            ---------
        end
end

You cannot possibly have copied/pasted the code here correctly. Given the code you provided, there is absolutely no possible way that you could get this error:
Code:
attempt to index local 'attackerPlayer' (a nil value)
The only thing wrong in your script is that you redefine the monsters max health every time it loops through the damage map which is retarded but isn't going to throw an error.


If you want help, stop being shady and just post the shit.
 
here the code "cuted"
Code:
function onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
    local targetMonster = creature:getMonster()
    if not targetMonster then
        return true
    end
    targetMonster:setDropLoot(false)
    for pid, damage in pairs(targetMonster:getDamageMap()) do
        local attackerPlayer = Player(pid)
        local monsterMaxHealth = targetMonster:getMaxHealth()
        if attackerPlayer ~= nil then
            if damage.total >= ((monsterMaxHealth / 100) * 5) and damage.total < ((monsterMaxHealth / 100) * 30) then -- COMMOM
                   ----
            end
            if attackerPlayer == mostdamagekiller then
                rewardbag:addItem(5903, 1)
            end
            local str = 'Your deeds have been noticed and the following items are available in your reward chest: ' .. rewardbag:getContentDescription()
            attackerPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, str, '')
            if rewardchest then
                ---
            end
        end
    end
    return true
end

Code:
for pid, damage in pairs(targetMonster:getDamageMap()) do
    local attackerPlayer = Player(pid)
    local monsterMaxHealth = targetMonster:getMaxHealth()
    if attackerPlayer ~= nil then
       ---------
    end
end
Actually that isn't the case because any value -1, 0 1, '' etc.. is consider true, but nil is always false in a condition when a variable is used as a condition to meet.
Maybe it should be
Code:
for pid, damage in pairs(targetMonster:getDamageMap()) do
    local attackerPlayer = Player(pid)
    local monsterMaxHealth = targetMonster:getMaxHealth()
    if attackerPlayer:isPlayer() then
       ---------
    end
end

I've tried the two attempts
~= nil or isPlayer() get the same error in the console
You cannot possibly have copied/pasted the code here correctly. Given the code you provided, there is absolutely no possible way that you could get this error:
Code:
attempt to index local 'attackerPlayer' (a nil value)
The only thing wrong in your script is that you redefine the monsters max health every time it loops through the damage map which is retarded but isn't going to throw an error.


If you want help, stop being shady and just post the shit.
about it, I'll just define out of the for something like this?
Code:
    local rewardchest = attackerPlayer:getRewardChest()
    local monsterMaxHealth = targetMonster:getMaxHealth()
    for pid, damage in pairs(targetMonster:getDamageMap()) do

also, my tfs is 1.2!
now, the error is:
attempt to index global 'attackerPlayer' (a nil value)
 
Last edited:
again.. nothing wrong with this code... this error comes elsewhere and you are not showing it.
Or you are but you are presenting it so weirdly I'm not gona bother decipher it.

The error is also useless, because its either one of your custom errors (I doubt) or you are not positing full error.

If if helps to open up your secrecy the reward chest thing you are doing is not that special.. Would take me 2-3 hours to make it from clean sheet and far more effective than what you are showing here.
 
again.. nothing wrong with this code... this error comes elsewhere and you are not showing it.
Or you are but you are presenting it so weirdly I'm not gona bother decipher it.

The error is also useless, because its either one of your custom errors (I doubt) or you are not positing full error.

If if helps to open up your secrecy the reward chest thing you are doing is not that special.. Would take me 2-3 hours to make it from clean sheet and far more effective than what you are showing here.

Haha, then you can write it for us XD
 
Back
Top