Jump to content
  • 0

What Does It Take To Create A Custom Chat For Pvpers


Question

Posted (edited)

So i found a code which was supposed to enable a custom chat only for players that had reached a certain ammount of pvps

+++ java/net/sf/l2j/gameserver/network/clientpackets/Say2.java

+import net.sf.l2j.gameserver.model.L2World;
+import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;


if(Config.ENABLE_PVP_CHAT)
+                                               {
+                                                       if(_text.startsWith("-"))
+                                                       {
+                                                               if(activeChar.getPvpKills() >= Config.PVP_CHAT_COUNT)
+                                                               {
+                                                       for(L2PcInstance p:L2World.getInstance().getAllPlayers().values())
+                                                          {
+                                                               p.sendPacket(new CreatureSay(0,16,activeChar.getName(),_text));                
+                                                               return;
+                                                              }       
+                                                               }
+                                                               else
+                                                                       activeChar.sendMessage("You don't have enough pvps in order to talk to this chat");
+                                                       }
+                                               }

I think there are still lots to be done cause it pops the message when someone doesn't have enough pvps but when he does nothing happens so..

Edited by mikemaster

10 answers to this question

Recommended Posts

  • 0
Posted (edited)

You use return inside the for loop, making the whole method execution stops at the first player found. In a for loop you will almost never find return, it's either break or continue.

 

I let you search what each is doing...

 

Finally it's a nice habit to put all "invalid" states at the beginning, which avoid those nested if and make the code more readable.

if (Config.ENABLE_PVP_CHAT && _text.startsWith("-"))
{
    if (activeChar.getPvpKills() < Config.PVP_CHAT_COUNT)
    {
        activeChar.sendMessage("You don't have enough pvps in order to talk to this chat");
        return;
    }

    for (L2PcInstance p:L2World.getInstance().getAllPlayers().values())
        p.sendPacket(new CreatureSay(0,16,activeChar.getName(),_text)); 
}

If you want an internal check ot see if each receiver is able to read the chat, make the check

if (Config.ENABLE_PVP_CHAT && _text.startsWith("-"))
{
    if (activeChar.getPvpKills() < Config.PVP_CHAT_COUNT)
    {
        activeChar.sendMessage("You don't have enough pvps in order to talk to this chat");
        return;
    }

    for (L2PcInstance p:L2World.getInstance().getAllPlayers().values())
    {
        if (p.getPvpKills() < Config.PVP_CHAT_COUNT)
            continue;
    
        p.sendPacket(new CreatureSay(0,16,activeChar.getName(),_text));
    }
}
Edited by Tryskell
  • 0
Posted (edited)

But Tryskell is this enought? i mean i wanted to make it with a colour like one of the other chats for instance Dark Purple

And also make it global

Cause right now when i added the code that you kindly provided me the message is shown twice and in  a way like normal chat :P

Edited by mikemaster
  • 0
Posted

Yes, it's gonna be global, there is no region check in the code.

 

 

p.sendPacket(new CreatureSay(0,2,activeChar.getName(),_text));
  • 0
Posted

but is there a way to stop the duplicate message? 
I mean when he doesn't have the number of pvps that are required  only to show the error message and not also the -(message he typed)

 

rib0g6.jpg

  • 0
Posted

 

     if (Config.ENABLE_PVP_CHAT && _text.startsWith("-"))
     {
         if (activeChar.getPvpKills() < Config.PVP_CHAT_COUNT)
         {
             activeChar.sendMessage("You don't have enough pvps in order to talk to this chat");
             return;
         }
 
         for (L2PcInstance p:L2World.getInstance().getAllPlayers().values())
         {
             if (p.getPvpKills() < Config.PVP_CHAT_COUNT)
                 continue;
         
             p.sendPacket(new CreatureSay(0,16,activeChar.getName(),_text));
         }
         
         return;
     }
  • 0
Posted

okey no more duplicate message but  i would like the message to be seen by all players and not only those that have the ammount of pvp

 

Right now the message is Show globaly but only to those that have the pvp ammount

Guest
This topic is now closed to further replies.


  • Posts

    • this will explain better than words  
    • I would like to emphasize that I am selling the tool used to generate geodata for the client you are developing, not the geodata itself; therefore, I consider the price reasonable. As for your view that the price is high and shows a lack of respect for the customer—that is your own opinion. Thank you. I have also purchased his products, and—just as you said—he is skilled and provides very enthusiastic support. If you feel he is deserving, then you should continue buying from him.
    • Ημουν μικρος οταν τον επαιξα, οριακα δεν ηξερα τι ειναι το Lineage, θυμαμαι πηγαιναμε στα νετ με τους φιλους και προσπαθουσαμε να κανουμε log-in αλλα πολλες φορες δεν μπορουσαμε γιατι ο server ηταν heavy σε load και πολλες φορες προλαβαιναμε να παιξουμε μονο κανα τεταρτακι η εικοσαλεπτο απ την μια ωρα που βαζαμε για να ανοιξουμε pc, ωστοσο εχω πολλες αναμνησεις να βλεπω τους μεγαλυτερους τοτε να παιζουν και εγω να καθομαι διπλα και να χαζευω gameplay, Λιγα πραγματα που ξερω (δεν ξερω αν ισχυουν) ειναι οτι τον σερβερ τον ειχε ανοιξει η αλυσιδα TheWeb, επισης οτι ηταν δυο οι σερβερ, ενας rpg low rate και ενας pvp με higher rates, περα απο αυτο δεν μπορεσα να βρω καμια αλλη χρησιμη πληροφορια, ουτε στα forum του theweb.gr ουτε στo l2.thegame.gr (waybackmachine) οποτε ερχομαι εδω που ειμαι σιγουρος οτι θα υπαρχουν σιγουρα καποιοι που επαιξαν εκει και δεν ηταν οσο πιτσιρικας οσο ημουν εγω που δεν καταλαβαινε τι γινοταν.   Γενικοτερα οποιος ξερει οτιδηποτε για τον thegame ας το πει, ακομη κι ας ειναι μια μικρη ιστορια που ακουσε πριν πολλα χρονια, ακομη κι αν ειναι μια μικρη πληροφορια για κατι που θυμαται μεσα στο παιχνιδι, οπως πως λεγανε τους admins, κανα σκηνικο ιντερνετ καφε και μπουνιδια, οοοοοτι μα οτιδηποτε κι αν ειναι αυτο αρκει να εχει να κανει με τον TheGame   (εννοειται εαν εχετε φωτογραφιες η βιντεο να τα linkαρετε)   μερικες δικες μου αποριες ειναι: απο τι chronicle αρχισε και μεχρι που εφτασε? ποια χρονια ηταν το peak του και σε ποιο chronicle? επισης μεχρι πιο chronicle εξελιχθηκε? γιατι εκλεισε αφου τοτε ηταν στο peak το να πηγαινει ο κοσμος στα ιντερνετ καφε και να παιζει λ2, τι features ειχε σαν σερβερ? επι ποσο ηταν? custom πραγματα κτλπ? η ηταν ενας bone stock server?    να'στε καλα!
    • Yeah... the price for the project at this stage is the kind of disrespect to the customer I was talking about.     As for deMEV, he’s overpriced too, but he’s one of the very few people in the L2 market who is available almost 24/7.
    • Thank you all for your interest in my post. I confirm that I did indeed use L2MapConv to develop my tool, adding my own customizations. If you are already a customer of deMEV, please continue to support him; I believe his products are excellent—I have purchased from him myself, and he is truly talented. Below is the Giran 22_22 geodata file generated using my tool; feel free to take a look. Thanks again to everyone for your comments. https://drive.google.com/file/d/1owpXCGEAhAO6TjjBJTYuVFqeUDu9RNoI/view?usp=drive_link
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..