Jump to content
  • 0

[DeathMatch]Find winner


Question

Posted

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

5 answers to this question

Recommended Posts

  • 0
Posted

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?

  • 0
Posted

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++;

  • 0
Posted

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

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...