otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.57k stars 1.05k forks source link

onDeEquip properly handled at logout/death #4664

Closed EvilHero90 closed 4 months ago

EvilHero90 commented 4 months ago

Pull Request Prelude

Changes Proposed

We didn't deequip items on logout/death but we equip everytime the player login. That way onDeEquip didn't work correctly as intended. following example code shows what the problem is:

function onEquip(player, item, slot)
    player:setMaxHealth(player:getMaxHealth() + 100)
    return true
end

function onDeEquip(player, item, slot)
    player:setMaxHealth(player:getMaxHealth() - 100)
    return true
end

The above would have resulted on every logout/login that the HP would increase by 100 but not decrease on logout/death which is now fixed

Issues addressed: none

nekiro commented 4 months ago

It honestly doesn't matter, as long as the player object is deleted anyway and none of the equip stuff are persistent. Nonetheless doesn't hurt to add this.

MillhioreBT commented 4 months ago

Thanks for noticing, I added the notification at the beginning of the login and completely forgot about the logout/death