• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Reward script edit

Tbol

Well-Known Member
Joined
Apr 7, 2019
Messages
625
Reaction score
71
Hello so trying to add event points as a reward and items with chance to get it and without chance just a simple item give. So i will show what i got so far

TFS 1.2
LUA:
function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    local myEvent = 25335 -- event points storage
    local percent = creature:getMaxHealth() * 0.02
    for k, v in pairs(monsterSystem) do
            if v.name:lower() == creature:getName():lower() then
            for pid, info in pairs(creature:getDamageMap()) do
                local player = Player(pid)
                if player and info.total >= percent then
                    player:addExperience(v.expReward, true)
                    player:addMoney(v.goldReward)
                    player:addEventPoints(myEvent, v.pointsReward) -- So this is event points
                    player:addItem(v.itemReward) -- this is adds items dont know about amount
                    -- and dont know how to make to add item with 15% chance to get it
                    -- not even sure if my added code would work
                end
            end
        end
    end
    stopEvent(henkasEventOne)
    return true
end

Usage is
pointsReward = 5,
itemReward = 14681,15 (dont know about this itemReward either it looks stupid)
in global.lua i would add these inside this table
LUA:
monsterSystem = {
    [1] = {name = "Worm Boss", pos = Position(228, 1043, 7), expReward = 1500, goldReward = 10,   msg = "Boss spawned. Test!"}
}
 
Solution
S
Code:
function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    local myEvent = 25335 -- event points storage
    local percent = creature:getMaxHealth() * 0.02
    for k, v in pairs(monsterSystem) do
            if v.name:lower() == creature:getName():lower() then
            for pid, info in pairs(creature:getDamageMap()) do
                local player = Player(pid)
                if player and info.total >= percent then
                    player:addExperience(v.expReward, true)
                    player:addMoney(v.goldReward)
                    player:addEventPoints(myEvent, v.pointsReward) -- So this is event points
                    if math.random(1,100) <= v.chance then...
This way you will have extreme lags, congratulations.
There is so many database controlled having a small functionality extra database controlled won't receive you extreme lags. Not sure where you base this on. When I develop something which is going to take resources thinking about daily events where people can gain points. Which is the exact same as getting coins and storing them in the bank (db controlled) would be better to control them the same way. The more you write in LUA the more RAM you will need.

But sorry for arguing about it.

if you clarified your needs i can help but its too messy to try to figure out what you need also you are not sure from your code so i won't bother tracing it why do you share something not sure from it while you are asking for "help" <-- something nobody forced to do it for you, keep in mind that i don't know you why would i help if you wasn't clear didn't help me know what you need so i can really help.
@Shadow_ Very good you've written the amount needed towards the OP to get the correct information needed for his exact idea. You've done good work there!

@Tbol Enjoy your code :)
 

Similar threads

Back
Top