Jump to content

Recommended Posts

I'm trying to create a simple script that will give an item to anyone who help destroy a metin. So far the script is: 

quest metin_8002_killed begin
    state start begin
        when 8002.kill begin
            local pids = {party.get_member_pids()}
            for i, pid in next, pids, nil do
				q.begin_other_pc_block(pid)
                pc.give_item2(1000, 1) 
                q.end_other_pc_block()
            end
        end
    end
end

This only works when people are in a party. If there is just one player, or more attacking, no one get anything.  If I add the give_item2 before the for, only one player gets the item.

what I'm trying to achieve is something like 

 

local pids = {getAllPlayerPidsThatDamagedTheMob()}


is this possible?

Edited by thebrickslayer
Link to comment
https://metin2.dev/topic/33870-reward-those-who-helped-destroy-the-metin/
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

AI-generated code, untested, but serves as an example.

void CHARACTER::RewardBossParticipants(int iMinPercent, DWORD dwItemVnum, int iItemCount)
{
    if (!IsMonster() || !IsAggressive()) // Só boss agressivo
        return;

    int iMinDamage = GetMaxHP() * iMinPercent / 100;

    for (TDamageMap::iterator it = m_map_kDamage.begin(); it != m_map_kDamage.end(); ++it)
    {
        LPCHARACTER ch = CHARACTER_MANAGER::instance().Find(it->first);

        if (!ch || !ch->IsPC())
            continue;

        if (it->second.iTotalDamage >= iMinDamage)
        {
            ch->ChatPacket(CHAT_TYPE_INFO, "Você participou da morte do BOSS.");
            if (dwItemVnum > 0 && iItemCount > 0)
                ch->AutoGiveItem(dwItemVnum, iItemCount);
        }
    }
}

int pc_reward_boss_participants(lua_State* L)
{
    LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();

    if (!ch)
        return 0;

    int minPercent = luaL_checknumber(L, 1);
    DWORD itemVnum = luaL_checknumber(L, 2);
    int itemCount = luaL_checknumber(L, 3);

    ch->RewardBossParticipants(minPercent, itemVnum, itemCount);
    return 0;
}

{ "reward_boss_participants", pc_reward_boss_participants },quest boss_reward_example begin
    state start begin
        when kill with npc.get_race() == 1093 begin -- Exemplo: BOSS Dragão Azul
            pc.reward_boss_participants(10, 50011, 1) -- 10% de dano ou mais, recompensa: 1x item 50011
        end
    end
end
Quote

 

Edited by Klaus

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.