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

onPrepareDeath() doubt

login12

void newbie scripter()
Joined
Feb 26, 2011
Messages
181
Reaction score
30
Location
Brazil
I'm trying to prevent a player's death under the conditions imposed in the code below. The problem is that after being teleported, the player dies and their health and mana are not restored. I've never used onPrepareDeath() properly and I have doubts about why this happens and how to work around it. I thought that just returning false would prevent the player from dying. Here the code

LUA:
function onPrepareDeath(cid, corpse, deathList)
    if(not isPlayer(cid)) then
        return true
    end
    for _, area in pairs(areasProctecteds) do
        if checkProtectedArea(area[1], area[2], area[3], area[4], area[5], area[6], cid) then
            print('MAXHEALTH: '..getCreatureMaxHealth(cid))
            doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
            doCreatureAddMana(cid, getCreatureMaxMana(cid))
            doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
            return false
        end
    end   

    return true
end
 
in player.cpp
bool Player::onDeath()
change
Code:
if(getZone() == ZONE_HARDCORE)

    {

        setDropLoot(LOOT_DROP_NONE);

        setLossSkill(false);

    }
to

LUA:
if(getZone() == ZONE_HARDCORE)
    {
        Position pos;
            pos.x = 1000;
            pos.y = 1000;
            pos.z = 7;  
           
        gainHealth(this, getMaxHealth());
        changeMana(getMaxMana());
       setNoMove(false);
       setHideHealth(false);
       g_game.addCreatureHealth(this);
       removeConditions(CONDITIONEND_CLEANUP);
       g_game.internalTeleport(this, pos, false);  
        return false;
    }
 
Thanks but this is not the solution I'm looking for. This will cause all deaths in HARDCOREPVP areas to fall under these conditions. Which is not the intention. I want to select a specific area of the map for this, so I do the table check in Lua.
 
yes but don't recommend to use this system in lua if you can make player get storage when enter area i can make it for you in c++
 
Back
Top