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

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock