Игровая почта

L2relax44

Путник
Пользователь
Сообщения
9
Розыгрыши
0
Репутация
0
Реакции
2
Баллы
6
Хроники
  1. Chaotic Throne: High Five
Сборка
l2scripts
Доброго времени суток , подскажите пожалуйста как сделать такую систему, При входе нового игрока на сервер он получал письмо и получал награду.
 
I don't know if it is copy-paste applicable to the High-Five version, but it should be something similar to this:

Java:
private void sendRewardMail(Player receiver)
    {
        Mail mail = new Mail();
        mail.setSenderId(receiver.getObjectId());
        mail.setSenderName(receiver.getName());
        mail.setReceiverId(receiver.getObjectId());
        mail.setReceiverName(receiver.getName());
        mail.setTopic("SOME_HEADLINE");
        mail.setBody("SOME_MESSAGE");
        mail.setPrice(0L);
        mail.setUnread(true);
        mail.setType(Mail.SenderType.NEWS_INFORMER);
        mail.setExpireTime((int) (TimeUnit.DAYS.toSeconds(365) + (System.currentTimeMillis() / 1000L)));
        mail.setSystemTopic(SystemMsg.SOME_SYSTEM_MESSAGE); //change to something else
        mail.setSystemBody(SystemMsg.SOME_SYSTEM_MESSAGE); //change to something else

        ItemInstance rewardItem = ItemFunctions.createItem(ItemTemplate.ITEM_ID_ADENA); // change to whatever you need. this example is for adena
        Objects.requireNonNull(rewardItem);
        rewardItem.setOwnerId(receiver.getObjectId());
        rewardItem.setCount(5_000_000); // amount of the rewardItem
        rewardItem.setLocation(ItemInstance.ItemLocation.MAIL);
        rewardItem.setJdbcState(JdbcEntityState.UPDATED);
        rewardItem.update();

        mail.addAttachment(rewardItem);
        mail.save();

        receiver.sendPacket(ExNoticePostArrived.STATIC_TRUE);
        receiver.sendPacket(new ExUnReadMailCount(receiver));
        receiver.sendPacket(SystemMsg.THE_MAIL_HAS_ARRIVED);
    }


You can remove whatever you don't need, or rather, whatever field of the mail.setXX or the rewardItem.setXX is not required for your version.

Also, you can further improve/generalise the method by adding additional inbound parameters other than Player, such as a list of Items for reward, along with their amount, String headline, String Message, some system message IDs, etc, and then properly adapting the method to use the new parameters.
 
Я не знаком с l2scripts, но то что можно сделать как в L2J так это написать квест. Таким способом не надо модифицировать ярдро сервера. Квест будет подписываться на евент когда игрок входит в игру, посмотри квест Q00255_Tutorial как пример.
Ну а после этого, можно добавить код который пересылает почту.

В место письма например, я использую Dimensional Merchant. Немного другая система, но меньше заморочек чем с почтой (там и лимит по сообщениям, да и куча различных видов почты; зачем? если только надо вручить предметы игроку).
 
Тут ещё вопрос имел ввиду оно нового игрока или персонажа )
Зачем эти лишние телодвижения не пойму) Выдайте персонажу при создании )
 
Тут ещё вопрос имел ввиду оно нового игрока или персонажа )
Зачем эти лишние телодвижения не пойму) Выдайте персонажу при создании )
Тут конечно зависит от того будут ли предметы утилизированны сразу или через некоторое время. Например возмем адену, она просто добавляется и сразу используется. Но если взять soulshot или более тяжелые предметы, то будет не так удобно. Конечно, все зависит от того сколько и кому.


Because they don't know how to compile the source into a jar. :D
I think message got lost in translation. It is not a question why bother with all these options, but rather why not just give items when player is created. After all does it matter if player gets it right away or he needs to do a bit more work clicking things?
 
Тут конечно зависит от того будут ли предметы утилизированны сразу или через некоторое время. Например возмем адену, она просто добавляется и сразу используется. Но если взять soulshot или более тяжелые предметы, то будет не так удобно. Конечно, все зависит от того сколько и кому.



I think message got lost in translation. It is not a question why bother with all these options, but rather why not just give items when player is created. After all does it matter if player gets it right away or he needs to do a bit more work clicking things?


Here's another question, why bother with writing a whole quest, when you can just add the item IDs to the list of "Starting Items", which already exists on L2Scripts sources?

I hope you catch my drift here.
There are many approaches that would lead to the same result, but the person asked about mail in particular, so how to do MAIL is what he got in response. Maybe he would like to use that Mail Reward System down the road for something else, such as MASS Rewards and stuff like that. You never know.

And on a more personal note, for me, reusability and scalability > quick-fixing.
 
Here's another question, why bother with writing a whole quest, when you can just add the item IDs to the list of "Starting Items", which already exists on L2Scripts sources?

I hope you catch my drift here.
There are many approaches that would lead to the same result, but the person asked about mail in particular, so how to do MAIL is what he got in response. Maybe he would like to use that Mail Reward System down the road for something else, such as MASS Rewards and stuff like that. You never know.
Oh I agree. If there is another way then maybe it is preferred after understanding that they can just do simpler things.

The problem is that author may not realize that other options exist, nor even considered that he can do less work (aka no need to dive into sources and compilation) to have same effect.
 
А что вобще мешает просто сделать листенер на вход в игру и в нем же и выдать награду, без всяких изощрений с почтой?
 
Назад
Сверху Снизу