• 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:
Take a screenshot of your console when the error is thrown please. Then copy and paste the entire script that it says the error is in. I don't care if the script is 5,000 lines long ill look through it... at this point I just want to know wtf the problem is cuz its killing me.
 
Haha, then you can write it for us XD
I have choice to make a free script to Whi World or script for other servers.
Making this particular script for "us" gives me no benefits if not only more scripts expected from me.
Making script for Whi World takes me 1 step closer for my game release.

The choice what I choose to do with my time is not that hard on this one.
However helping someone to fix errors most of time doesn't take much time. That's why I'm still lurking in support section and guide ppl with things I know.

If you want this LUA system for whole community PM me after you read my scripting service.
 
Code:
function onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
  
    if not creature:isMonster() then
        return true
    end

    creature:setDropLoot(false)
    local monsterMaxHealth = creature:getMaxHealth()
    local str = 'Your deeds have been noticed and the following items are available in your reward chest: '
    for pid, damage in pairs(creature:getDamageMap()) do
        if pid:isPlayer() then
            local attackerPlayer = Player(pid)
            if damage.total >= ((monsterMaxHealth / 100) * 5) and damage.total < ((monsterMaxHealth / 100) * 30) then -- COMMOM
                   ----
            end

            if attackerPlayer == mostdamagekiller then
                rewardbag:addItem(5903, 1)
                attackerPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, str .. rewardbag:getContentDescription() )
            end
           
            if rewardchest then
                ---
            end
        end
    end
    return true
end
 
I have choice to make a free script to Whi World or script for other servers.
Making this particular script for "us" gives me no benefits if not only more scripts expected from me.
Making script for Whi World takes me 1 step closer for my game release.

The choice what I choose to do with my time is not that hard on this one.
However helping someone to fix errors most of time doesn't take much time. That's why I'm still lurking in support section and guide ppl with things I know.

If you want this LUA system for whole community PM me after you read my scripting service.
So to sum up this post, you are lurking in support to get people to hire you for scripting services so you can make money from them?
No offense but that is pretty pathetic.
 
Then wtf are you doing in support / request, go work on your shit server, go cater to your 6 players.
I don't do anything in request threads.
In support ones I guide players to write codes correctly or help with the issues at hand.
 
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.
I not hide anything about the error
the code that I cut is the same, I remove just the another things, not important to the "main" script
Take a screenshot of your console when the error is thrown please. Then copy and paste the entire script that it says the error is in. I don't care if the script is 5,000 lines long ill look through it... at this point I just want to know wtf the problem is cuz its killing me.
here:
HcmELPi.png

also, @whitevo you don't need all my script, this script is based on:
Code:
https://github.com/orts/server/blob/master/data/creaturescripts/scripts/quests/bigfoot%20burden/WarzoneKill.lua
see the base of my script? all is there.
 
see the base of my script? all is there.
The fucking problem is up to this point there still has not been an error in the script you provided.
Up until now we have not known what line in your script is throwing the error.
And even now that we know the line at which the error occurs, we still cannot see the damn line 93.

This is the last time I am going to tell you to post the entire script. I will not be posting here again until it is pasted here correctly.
 
Code:
function onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
 
    if not creature:isMonster() then
        return true
    end

    creature:setDropLoot(false)
    local monsterMaxHealth = creature:getMaxHealth()
    local str = 'Your deeds have been noticed and the following items are available in your reward chest: '
    for pid, damage in pairs(creature:getDamageMap()) do
        if pid:isPlayer() then
            local attackerPlayer = Player(pid)
            if damage.total >= ((monsterMaxHealth / 100) * 5) and damage.total < ((monsterMaxHealth / 100) * 30) then -- COMMOM
                   ----
            end

            if attackerPlayer == mostdamagekiller then
                rewardbag:addItem(5903, 1)
                attackerPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, str .. rewardbag:getContentDescription() )
            end
          
            if rewardchest then
                ---
            end
        end
    end
    return true
end
I've tried use it, now the error is different :eek::eek::eek::eek::eek::eek:
zeR8STy.png
 
The fucking problem is up to this point there still has not been an error in the script you provided.
Up until now we have not known what line in your script is throwing the error.
And even now that we know the line at which the error occurs, we still cannot see the damn line 93.

This is the last time I am going to tell you to post the entire script. I will not be posting here again until it is pasted here correctly.
aff man, see my comment about the base of the script, the fucking line 93 is:
Code:
local attackerPlayer = Player(pid)
here the shit script
Code:
function onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
    local targetMonster = creature:getMonster()
    if not targetMonster:isMonster() then
        return true
    end
    targetMonster:setDropLoot(false)
    local monsterMaxHealth = targetMonster:getMaxHealth()
    for pid, damage in pairs(targetMonster:getDamageMap()) do
        if pid:isPlayer() then
            local attackerPlayer = Player(pid)
            local rewardchest = attackerPlayer:getRewardChest()
            local rewardbag = Game.createItem(21518, 1)
            if attackerPlayer:isPlayer() then
                if damage.total >= ((monsterMaxHealth / 100) * 5) and damage.total < ((monsterMaxHealth / 100) * 30) then
                          SMALL SHIT CODE TO PUT THE LOOT INTO THE BAG
                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
                    rewardchest:addItemEx(rewardbag, INDEX_WHEREEVER, FLAG_NOLIMIT)
                    rewardbag:decay()
                end
            end
        end
    end
    return true
end
all happy now? I just remove the table of the loot ... and how the loot go to the bag
if you think that is needed is because you is a noob D:
 
aff man, see my comment about the base of the script, the fucking line 93 is:
Code:
local attackerPlayer = Player(pid)
here the shit script
Code:
function onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
    local targetMonster = creature:getMonster()
    if not targetMonster:isMonster() then
        return true
    end
    targetMonster:setDropLoot(false)
    local monsterMaxHealth = targetMonster:getMaxHealth()
    for pid, damage in pairs(targetMonster:getDamageMap()) do
        if pid:isPlayer() then
            local attackerPlayer = Player(pid)
            local rewardchest = attackerPlayer:getRewardChest()
            local rewardbag = Game.createItem(21518, 1)
            if attackerPlayer:isPlayer() then
                if damage.total >= ((monsterMaxHealth / 100) * 5) and damage.total < ((monsterMaxHealth / 100) * 30) then
                          SMALL SHIT CODE TO PUT THE LOOT INTO THE BAG
                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
                    rewardchest:addItemEx(rewardbag, INDEX_WHEREEVER, FLAG_NOLIMIT)
                    rewardbag:decay()
                end
            end
        end
    end
    return true
end
all happy now? I just remove the table of the loot ... and how the loot go to the bag
if you think that is needed is because you is a noob D:
Post THE ENTIRE SCRIPT!
Your noob code can possibly be the reason it doesn't work.. you ever think of that??
 
if you think that is needed is because you is a noob D:
@Xagul, @whitevo & myself aren't the friggen noob coders here.. we build entire servers from the ground up.. to call us noob coders is just fucking stupid, you might as well make another account.. you know what fuck you and your script.. I am out.
 
1. Remove the first if statement below the for loop, you cannot call Creature.isPlayer with a numeric value.
2. Change attackerPlayer:isPlayer() -> attackerPlayer.

Edit: Your code is changing by each post lol :p

Verify whether the Player userdata object is valid or not before calling Player methods.
Code:
if attackerPlayer then
    -- something
end
 
1. Remove the first if statement below the for loop, you cannot call Creature.isPlayer with a numeric value.
2. Change attackerPlayer:isPlayer() -> attackerPlayer.
it?
Code:
for pid, damage in pairs(targetMonster:getDamageMap()) do
        local attackerPlayer = Player(pid)
        local rewardchest = attackerPlayer:getRewardChest()
        local rewardbag = Game.createItem(20620, 1)
        if attackerPlayer then
O4S3MZG.png
 
1. Remove the first if statement below the for loop, you cannot call Creature.isPlayer with a numeric value.
2. Change attackerPlayer:isPlayer() -> attackerPlayer.

Edit: Your code is changing by each post lol :p

Verify whether the Player userdata object is valid or not before calling Player methods.
Code:
if attackerPlayer then
    -- something
end
he chance during the attempts to use what they say that can be solve this :(
how valid if the player die, or logout ?
 
Back
Top