# Winner Condition

**URL:** <https://forums.unrealengine.com/t/winner-condition/490054>\
**Category:** C++\
**Tags:** condition, multiplayer-shooter, unreal-engine, Multiplayer, CPP, question\
**Created:** [October 20, 2021, 12:57pm UTC](https://forums.unrealengine.com/t/winner-condition/490054 "2021-10-20T12:57:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MongeRastafari](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MongeRastafari](https://forums.unrealengine.com/u/MongeRastafari)\
**Post date:** [October 20, 2021, 12:57pm UTC](https://forums.unrealengine.com/t/winner-condition/490054/1 "2021-10-20T12:57:22Z")

</div>

hello guys, would you like to know how do i make a winner based on who made the most kills? I have the player’s nick name and death number already programmed, even if they appear on my hud. I would like to know how do I return this player that did more kill so I can create the winner widget?  
technically it would be to do a get by player name and number of kills and return which of the people playing has won. in c++

---

<div class="post-metadata">

**Author:** ![UnhingedGoon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UnhingedGoon](https://forums.unrealengine.com/u/UnhingedGoon)\
**Post date:** [October 20, 2021, 1:13pm UTC](https://forums.unrealengine.com/t/winner-condition/490054/2 "2021-10-20T13:13:39Z")

</div>

Can’t u just compare the integer value of the kills?  
If Player1 kills \> Player2 kills do …

---

<div class="post-metadata">

**Author:** ![MongeRastafari](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MongeRastafari](https://forums.unrealengine.com/u/MongeRastafari)\
**Post date:** [October 20, 2021, 1:33pm UTC](https://forums.unrealengine.com/t/winner-condition/490054/3 "2021-10-20T13:33:40Z")

</div>

how can i do this with for()?

---

<div class="post-metadata">

**Author:** ![archimonde1111](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@archimonde1111](https://forums.unrealengine.com/u/archimonde1111)\
**Post date:** [October 20, 2021, 2:20pm UTC](https://forums.unrealengine.com/t/winner-condition/490054/4 "2021-10-20T14:20:57Z")

</div>

Create array with all players and loop thought them, use simple max algoryth ergo.

```
int32 MaxKIlls;
APlayer* PlayerWithMaxKIlls;
for(APlayer& Player : Players)
{
    if(Player.Kills > MaxKIlls)
    {
        MaxKIlls = Player.Kills;
        PlayerWithMaxKIlls = Player;
    }
}

```

This should return player with highest number of kills

---

<div class="post-metadata">

**Author:** ![MongeRastafari](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MongeRastafari](https://forums.unrealengine.com/u/MongeRastafari)\
**Post date:** [October 22, 2021, 11:25am UTC](https://forums.unrealengine.com/t/winner-condition/490054/5 "2021-10-22T11:25:42Z")

</div>

thank you very much, as it is a multiplayer pvp shooting game in LAN mode, how can I call these players? how do i get these logged in players?
