• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

Adding items to players inventory

Neccta

Exalted Member
I'm sure this is very easy but I don't know the function to do it in C++. I want to reward a player with an item on a WSG win.
Here is the code in BattlegroundWS.cpp:
Code:
    // Win reward
    if (winner == ALLIANCE)
        RewardHonorToTeam(GetBonusHonorFromKill(m_HonorWinKills), ALLIANCE);
    if (winner == HORDE)
        RewardHonorToTeam(GetBonusHonorFromKill(m_HonorWinKills), HORDE);
    // Complete map_end rewards (even if no team wins)
    RewardHonorToTeam(GetBonusHonorFromKill(m_HonorEndKills), ALLIANCE);
    RewardHonorToTeam(GetBonusHonorFromKill(m_HonorEndKills), HORDE);

    Battleground::EndBattleground(winner);
 

Jpp

Administrator
It is untested, but it should work.

Code:
void BattlegroundWS::EndBattleground(uint32 winner)
{
    // Win reward
    if (winner == ALLIANCE)
    [COLOR="#00FF00"]{
        for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
            if (Player* player = _GetPlayerForTeam(ALLIANCE, itr, "RewardItemToTeam"))
                player->AddItem([COLOR="#FF0000"]itemId[/COLOR], [COLOR="#FF0000"]count[/COLOR]);[/COLOR]
        RewardHonorToTeam(GetBonusHonorFromKill(m_HonorWinKills), ALLIANCE);
    [COLOR="#00FF00"]}[/COLOR]
    if (winner == HORDE)
    [COLOR="#00FF00"]{
        for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
            if (Player* player = _GetPlayerForTeam(HORDE, itr, "RewardItemToTeam"))
                player->AddItem([COLOR="#FF0000"]itemId[/COLOR], [COLOR="#FF0000"]count[/COLOR]);[/COLOR]
        RewardHonorToTeam(GetBonusHonorFromKill(m_HonorWinKills), HORDE);
    [COLOR="#00FF00"]}[/COLOR]
    // Complete map_end rewards (even if no team wins)
    RewardHonorToTeam(GetBonusHonorFromKill(m_HonorEndKills), ALLIANCE);
    RewardHonorToTeam(GetBonusHonorFromKill(m_HonorEndKills), HORDE);

    Battleground::EndBattleground(winner);
}

Edit: This can be done in a lot cleaner way but it would require you to edit multiple files.
 
Last edited:

callmephil

Respected Member
Battleground.cpp line 774

ADD before
Code:
 // Reward winner team [code]
[code]
if (team == winner)
 {
switch(player->GetZoneId())
        {
            case 3277: // Warsong Gulch
            player->AddItem(ITEM, ITEM_count);
            break;
        default:
        break; 
	}
}

if also you need worldserver config to change item_count ask me.
 
Last edited:
Top