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

TFS 1.X+ tfs 1.2 getDamageMap / ondeath

emil92b

Intermediate OT User
Joined
Aug 21, 2013
Messages
335
Solutions
13
Reaction score
135
Location
Sweden
How do you use getDamageMap with onDeath to get all the things that lead up to the death of the player?
 
ty, already figured that part out tho heh ;p i know how to get the creature and monster, but
do you know how i can get info if the player died from a field, i need the id so i can get the name of it just as the other

C++:
int LuaScriptInterface::luaCreatureGetDamageMap(lua_State* L)
{
    // creature:getDamageMap()
    Creature* creature = getUserdata<Creature>(L, 1);
    if (!creature) {
        lua_pushnil(L);
        return 1;
    }

    lua_createtable(L, creature->damageMap.size(), 0);
    for (auto damageEntry : creature->damageMap) {
        lua_createtable(L, 0, 2);
        setField(L, "total", damageEntry.second.total);
        setField(L, "ticks", damageEntry.second.ticks);
        lua_rawseti(L, -2, damageEntry.first);
    }
    return 1;
}
 
Back
Top