Release autoloot with item

09/21/2022 19:58 redbull2905#1
I quibbled a bit with the autoloot and I said to myself that it's boring for some players to wait for a reboot to deactivate or not the autoloot. So I modified it a bit. It can definitely be improved I think. Like click on it again and it deactivates instantly but I free for those who are beginners and who don't really know how to do it.

Code:
if (VNum == 1143) // Auto-Loot 
            {
                if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.AutoLoot))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId = session.Character.CharacterId,
                        DateEnd = DateTime.Now.AddMinutes(20),
                        StaticBonusType = StaticBonusType.AutoLoot
                    });
                    session.SendPacket(
                           session.Character.GenerateSay(
                               Language.Instance.GetMessageFromKey("AUTOLOOT_ON"), 0));


                    Observable.Timer(TimeSpan.FromMinutes(20)).Subscribe(observer =>
                    {
                        session.SendPacket(
                               session.Character.GenerateSay(
                                   Language.Instance.GetMessageFromKey("AUTOLOOT_OFF"), 0));
                    });
  

                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }


            }
In this case the autoloot is activated for 20 minutes and it will deactivate automatically
09/21/2022 20:42 Fizo55#2
Your observable timer is kinda useless btw
09/21/2022 20:46 redbull2905#3
Quote:
Originally Posted by Fizo55 View Post
Your observable timer is kinda useless btw
it's just for " session.SendPacket(
session.Character.GenerateSay(
Language.Instance.GetMessageFromKey("AUTOLOOT_OFF" ), 0));"
09/21/2022 21:07 Fizo55#4
Quote:
Originally Posted by redbull2905 View Post
it's just for " session.SendPacket(
session.Character.GenerateSay(
Language.Instance.GetMessageFromKey("AUTOLOOT_OFF" ), 0));"
[Only registered and activated users can see links. Click Here To Register...]
09/21/2022 23:14 ZroIsHere#5
Quote:
Originally Posted by redbull2905 View Post
I quibbled a bit with the autoloot and I said to myself that it's boring for some players to wait for a reboot to deactivate or not the autoloot. So I modified it a bit. It can definitely be improved I think. Like click on it again and it deactivates instantly but I free for those who are beginners and who don't really know how to do it.

Code:
if (VNum == 1143) // Auto-Loot 
            {
                if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.AutoLoot))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId = session.Character.CharacterId,
                        DateEnd = DateTime.Now.AddMinutes(20),
                        StaticBonusType = StaticBonusType.AutoLoot
                    });
                    session.SendPacket(
                           session.Character.GenerateSay(
                               Language.Instance.GetMessageFromKey("AUTOLOOT_ON"), 0));


                    Observable.Timer(TimeSpan.FromMinutes(20)).Subscribe(observer =>
                    {
                        session.SendPacket(
                               session.Character.GenerateSay(
                                   Language.Instance.GetMessageFromKey("AUTOLOOT_OFF"), 0));
                    });
  

                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }


            }
In this case the autoloot is activated for 20 minutes and it will deactivate automatically
Quote:
Originally Posted by Fizo55 View Post
[Only registered and activated users can see links. Click Here To Register...]
It's better to put an if when you pick up an item. After 20 minutes, if you pick up an item, the if datetime will detect that the current time is greater than the time limit and delete the record. It's not exactly 20 minutes, it's when you pick up the next item after 20 minutes, but it's better than an observable.
09/25/2022 00:52 NosBreak#6
I need contact you , is possible sent me your discord?
10/15/2022 16:06 Ripper1181#7
Is working?