Esempio n. 1
0
 public JSONAPI(string apiKey, System.Version Version)
 {
     this.apiKey  = apiKey;
     this.Version = Version;
     this.Game    = new GameHandle(this);
     this.Me      = new MeHandle(this);
     this.Bot     = new BotHandle(this);
     this.Chat    = new ChatHandle(this);
 }
Esempio n. 2
0
 public JSONAPI(string apiKey, System.Version Version)
 {
     this.apiKey = apiKey;
     this.Version = Version;
     this.Game = new GameHandle(this);
     this.Me = new MeHandle(this);
     this.Bot = new BotHandle(this);
     this.Chat = new ChatHandle(this);
 }
        public override void Spawn()
        {
            base.Spawn();

            Vehicle = VehicleEntity.Create(VehiclePosition,
                                           NAPI.Util.VehicleNameToModel(DbModel.VehicleModel), DbModel.Name, 0, DbModel.CreatorId, new Color(0, 0, 0), new Color(0, 0, 0));
            Vehicle.GameVehicle.OpenDoor(5);
            BotHandle.PlayScenario("WORLD_HUMAN_SMOKING");

            BotShape = NAPI.ColShape.CreateCylinderColShape(BotHandle.Position, 3f, 3f);
            BotShape.OnEntityEnterColShape += BotShape_OnEntityEnterColShape;

            Timer timer = new Timer(1800000);

            timer.Start();
            timer.Elapsed += (o, e) =>
            {
                Dispose(true);
                timer.Dispose();
            };
        }
        private void CornerPlayerSaidHandler(object sender, SaidEventArgs e)
        {
            //Brak TransactionLevel bot przychodzi i pyta o narkotyk
            //TransactionLevel == 1 PedEntity czeka na cenę
            //TransactionLevel == 2 Podana cena była za wysoka i bot wynegocjował zgodnie z tym co może dać, czeka aż gracz powie tak lub poda cenę

            //Jeśli gracz powie że nie ma
            if ((!BotHandle.HasData("TransactionLevel") || BotHandle.GetData("TransactionLevel") == 2) &&
                e.Character == Seller &&
                (e.ChatMessageType == ChatMessageType.Normal || e.ChatMessageType == ChatMessageType.Quiet || e.ChatMessageType == ChatMessageType.Loud) &&
                Messages.NoMessagesList.Any(e.Message.Contains))
            {
                GoAllPoints(true);
            }
            else if (BotHandle.HasData("TransactionLevel") &&
                     BotHandle.GetData("TransactionLevel") == 1 &&
                     e.Character == Seller &&
                     (e.ChatMessageType == ChatMessageType.Normal || e.ChatMessageType == ChatMessageType.Quiet || e.ChatMessageType == ChatMessageType.Loud) &&
                     !e.Message.All(char.IsDigit))
            {
                //Jeśli gracz nie napisze zadnej liczby
                Seller.SendInfo("Aby podać cenę kupującemu NPC musisz używać liczb np. 70.");
            }
            //Jeśli gracz powie tak
            else if (!BotHandle.HasData("TransactionLevel") && e.Character == Seller && (e.ChatMessageType == ChatMessageType.Normal || e.ChatMessageType == ChatMessageType.Quiet || e.ChatMessageType == ChatMessageType.Loud) && Messages.YesMessagesList.Any(e.Message.Contains))
            {
                BotHandle.SetData("TransactionLevel", 1);
                SendMessageToNerbyPlayers("Ile za to cudo?", ChatMessageType.Normal);
            }
            //Jeśli gracz poda za wysoką cenę, ale w granicach rozsądku
            else if (BotHandle.HasData("TransactionLevel") &&
                     BotHandle.GetData("TransactionLevel") == 1 &&
                     e.Character == Seller &&
                     (e.ChatMessageType == ChatMessageType.Normal || e.ChatMessageType == ChatMessageType.Quiet || e.ChatMessageType == ChatMessageType.Loud) &&
                     MostlyGoodMoneyCounts.Any(Convert.ToDecimal(e.Message).Equals))
            {
                SendMessageToNerbyPlayers($"Co powiesz na ${MoneyCount}?", ChatMessageType.Normal);
                BotHandle.SetData("TransactionLevel", 2);
            }
            //Jeśli gracz poda właściwą lub niższą cenę
            else if (BotHandle.HasData("TransactionLevel") &&
                     BotHandle.GetData("TransactionLevel") == 1 &&
                     e.Character == Seller &&
                     (e.ChatMessageType == ChatMessageType.Normal || e.ChatMessageType == ChatMessageType.Quiet || e.ChatMessageType == ChatMessageType.Loud) &&
                     (e.Message.Contains(MoneyCount.ToString(CultureInfo.InvariantCulture)) || LowerMoneyCounts.Any(Convert.ToDecimal(e.Message).Equals)))
            {
                //Sprawdzamy czy gracz posiada dany narkotyk
                if (Seller.DbModel.Items.Any(i => i.ItemEntityType == ItemEntityType.Drug && i.FirstParameter == (int)DrugType))
                {
                    EndTransaction(LowerMoneyCounts.Any(Convert.ToDecimal(e.Message).Equals) ? LowerMoneyCounts.First(Convert.ToDecimal(e.Message).Equals) : MoneyCount);
                }
                //Jeśli gracz nie ma narkotyku
                else
                {
                    SendFailMessage();
                }
                GoAllPoints(true);
            }
            //Po negocjacji
            else if (BotHandle.HasData("TransactionLevel") &&
                     BotHandle.GetData("TransactionLevel") == 2 &&
                     e.Character == Seller &&
                     (e.ChatMessageType == ChatMessageType.Normal || e.ChatMessageType == ChatMessageType.Quiet || e.ChatMessageType == ChatMessageType.Loud) &&
                     (Messages.YesMessagesList.Any(e.Message.Contains) || e.Message.Contains(MoneyCount.ToString(CultureInfo.InvariantCulture)) || LowerMoneyCounts.Any(Convert.ToDecimal(e.Message).Equals)))
            {
                //Jeśli gracz zgodzi się na cenę bota
                //Sprawdzamy czy gracz posiada dany narkotyk
                if (Seller.DbModel.Items.Any(i => i.ItemEntityType == ItemEntityType.Drug && i.FirstParameter == (int)DrugType))
                {
                    if (!e.Message.All(char.IsDigit))
                    {
                        EndTransaction(MoneyCount);
                    }
                    else
                    {
                        EndTransaction(LowerMoneyCounts.Any(Convert.ToDecimal(e.Message).Equals) ? LowerMoneyCounts.First(Convert.ToDecimal(e.Message).Equals) : MoneyCount);
                    }
                }
                //Jeśli gracz nie ma narkotyku po negocjacji
                else
                {
                    SendFailMessage();
                }
                GoAllPoints(true);
            }
            else
            {
                SendMessageToNerbyPlayers(BadFarewell, ChatMessageType.Normal);
                GoAllPoints(true);
            }
        }