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...

http://pastebin.com/f74acc9ea

 

Check this code, it has option to reward players with most kills.

 

>Pasting code with over 1000+ lines and expecting somebody to actually read and understand it.

>mfw

Maybe just the relevant details would be nice.

 

@Medisept

for (L2PcInstance onlinePlayer : ples)
{
    if (onlinePlayer.isInDm() == true)
    {
        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.");
}

 

Now featuring non-shitty tabbing so it's readable.

I'm guessing you loop across the entire table of players looking for the one who has the most kills and you set maxkills equal to that. The one conclusion that I can jump too is that the variable that is being returned by onlinePlayer.getDmKills() is not doing what it should be doing. Have you used the debugger?

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...

 

have u connected that with the L2PcInstance increasePvpKills()  ?

if yes it should be like this

dmKills++;

  • Author

i tried today with only _DmKills number without getDmKills() method.

I made my addaptions and added when a player "IsInDm" mode to get _DmKills++  .

But again the same thing, dunno what is happening, but i think the whole idea is right for this

 

Create an account or sign in to comment

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.