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

how to show assist in myacc lastkills.php

Tbol

Well-Known Member
Joined
Apr 7, 2019
Messages
526
Reaction score
54
TFS 1.2
MYACC 0.7.9

Hello so right now i have last kills like this

- Killed at level 30 by a minotaur ...... or ...... Killed at level 30 by Player (a)
But I want to show the whole list. like this \/
- Killed at level 30 by Player (a), Player (b) and a minotaur

this is my
lastkills.php

and this is
ondeath in creature.cpp
C++:
void Creature::onDeath()
{
    bool lastHitUnjustified = false;
    bool mostDamageUnjustified = false;
    Creature* _lastHitCreature = g_game.getCreatureByID(lastHitCreature);
    Creature* lastHitCreatureMaster;
    if (_lastHitCreature) {
        lastHitUnjustified = _lastHitCreature->onKilledCreature(this);
        lastHitCreatureMaster = _lastHitCreature->getMaster();
    } else {
        lastHitCreatureMaster = nullptr;
    }

    Creature* mostDamageCreature = nullptr;

    const int64_t timeNow = OTSYS_TIME();
    const uint32_t inFightTicks = g_config.getNumber(ConfigManager::PZ_LOCKED);
    int32_t mostDamage = 0;
    std::map<Creature*, uint64_t> experienceMap;
    uint16_t deathAssists = 0;
    uint16_t deathAssistsConfig = g_config.getNumber(ConfigManager::DEATH_ASSIST_COUNT);
    for (const auto& it : damageMap) {
        if (Creature* attacker = g_game.getCreatureByID(it.first)) {
            CountBlock_t cb = it.second;
            if ((cb.total > mostDamage && (timeNow - cb.ticks <= inFightTicks))) {
                mostDamage = cb.total;
                mostDamageCreature = attacker;
            }

            if (attacker != this) {
                if (Player* victimPlayer = getPlayer()) {
                    if (Player* attackerPlayer = attacker->getPlayer()) {
                        if (deathAssists < deathAssistsConfig) {
                            attackerPlayer->addUnjustifiedDead(victimPlayer);
                            deathAssists++;
                        }
                    }
                }
                uint64_t gainExp = getGainedExperience(attacker);
                if (Player* player = attacker->getPlayer()) {
                    Party* party = player->getParty();
                    if (party && party->getLeader() && party->isSharedExperienceActive() && party->isSharedExperienceEnabled()) {
                        attacker = party->getLeader();
                    }
                }

                auto tmpIt = experienceMap.find(attacker);
                if (tmpIt == experienceMap.end()) {
                    experienceMap[attacker] = gainExp;
                } else {
                    tmpIt->second += gainExp;
                }
            }
        }
    }

    for (const auto& it : experienceMap) {
        it.first->onGainExperience(it.second, this);
    }

    if (mostDamageCreature) {
        if (mostDamageCreature != _lastHitCreature && mostDamageCreature != lastHitCreatureMaster) {
            Creature* mostDamageCreatureMaster = mostDamageCreature->getMaster();
            if (_lastHitCreature != mostDamageCreatureMaster && (lastHitCreatureMaster == nullptr || mostDamageCreatureMaster != lastHitCreatureMaster)) {
                mostDamageUnjustified = mostDamageCreature->onKilledCreature(this, false);
            }
        }
    }

    bool droppedCorpse = dropCorpse(_lastHitCreature, mostDamageCreature, lastHitUnjustified, mostDamageUnjustified);
    death(_lastHitCreature);

    if (master) {
        master->removeSummon(this);
    }

    if (droppedCorpse) {
        g_game.removeCreature(this, false);
    }
}
 
Solution
This is how it works in TFS 1.2.

Table structure is very simple: it saves only killed_by and mostdamage_by.

But the script in MyAAC is showing only killed_by, so we can fix it.

Still, it will display only 2 values, better than nothing tho, right? ;)

If you want to add mostdamage_by, follow:

Change this query:
Code:
$players_deaths = $db->query("SELECT `p`.`name` AS `victim`, `d`.`killed_by` as `killed_by`, `d`.`time` as `time`, `d`.`level`, `d`.`is_player` FROM `player_deaths` as `d` INNER JOIN `players` as `p` ON d.player_id = p.id ORDER BY `time` DESC LIMIT 20;");

To:
Code:
$players_deaths = $db->query("SELECT `p`.`name` AS `victim`, `d`.`killed_by` as `killed_by`, `d`.`time` as `time`, `d`.`level`, `d`.`is_player`...
This is how it works in TFS 1.2.

Table structure is very simple: it saves only killed_by and mostdamage_by.

But the script in MyAAC is showing only killed_by, so we can fix it.

Still, it will display only 2 values, better than nothing tho, right? ;)

If you want to add mostdamage_by, follow:

Change this query:
Code:
$players_deaths = $db->query("SELECT `p`.`name` AS `victim`, `d`.`killed_by` as `killed_by`, `d`.`time` as `time`, `d`.`level`, `d`.`is_player` FROM `player_deaths` as `d` INNER JOIN `players` as `p` ON d.player_id = p.id ORDER BY `time` DESC LIMIT 20;");

To:
Code:
$players_deaths = $db->query("SELECT `p`.`name` AS `victim`, `d`.`killed_by` as `killed_by`, `d`.`time` as `time`, `d`.`level`, `d`.`is_player`, `d`.`mostdamage_by` as `mostdamage_by`, `d`.`mostdamage_is_player` as `mostdamage_is_player` FROM `player_deaths` as `d` INNER JOIN `players` as `p` ON d.player_id = p.id ORDER BY `time` DESC LIMIT 20;");

After this:
Code:
if($death['is_player'] == '1')
   $players_rows .= getPlayerLink($death['killed_by']);
else
   $players_rows .= $death['killed_by'];

Add:
Code:
if (!empty($death['mostdamage_by'])) {
   $player_rows .= ' and ';
   if($death['mostdamage_is_player'] == '1')
      $players_rows .= getPlayerLink($death['mostdamage_by']);
   else
      $players_rows .= $death['mostdamage_by'];
}

End note: if you want something more advanced, that save ALL deaths, you can look how it was done in TFS 0.3, using more tables like: player_killers, player_deaths, killers etc. Maybe it can be converted to 1.2

It's this function:
 
Solution
Back
Top