Skip to content

[DeathMatch]Find winner

Featured Replies

Hello there, i have this code.

 

 

       

for (L2PcInstance onlinePlayer : ples)
        {
            if (onlinePlayer.isInDm)
            {
                onlinePlayer.teleToLocation(81220, 148588, -3472);
                onlinePlayer.isInDm = false;
            }
            if (onlinePlayer.getDmKills() > maxkills)
            {
                winner = onlinePlayer;
                maxkills = onlinePlayer.getDmKills();
            }
            onlinePlayer.isInDm = false;
            onlinePlayer.setDmKills(0);
        }
        if (maxkills != 0)
        {
            for (int[] reward : Config.DM_EVENT_REWARDS)
            {
                winner.addItem("Death Match", reward[1], reward[2], winner, true);
                winner.broadcastUserInfo();
                winner.sendPacket(new InventoryUpdate());
                winner.sendPacket(new ItemList(winner, false));
                winner.sendPacket(new StatusUpdate(winner));
            }
            winner.sendMessage("Congratulations! You have won Death Match Event.");
        }

 

I want to find from all registered players in event (isInDm) who has most DmKills and reward him, i used that but it says me that maxkills stayed 0...

you should have at the code start:

int maxkills = -1;

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.