Example #1
0
        public void addItem(Player player, int indexRaft, string item, int price)
        {
            if (playerManager.doesPlayerHasAdmin(player) <= 0)
            {
                player.SendChatMessage("!{#CEF0AC}You need to be an admin.");
                return;
            }
            if (!player.HasData("inShopCreation"))
            {
                player.SendChatMessage("Nu esti in creearea unui shop.");
                return;
            }
            var itemDB = inventory.items.Find(a => a.name.ToLower() == item.ToLower());

            if (itemDB == null)
            {
                player.SendChatMessage("item-ul nu exista.");
                return;
            }

            business.model shop = player.GetData <business.model>("inShopCreation");

            if (shop.external.rafts[indexRaft] == null)
            {
                player.SendChatMessage($"Raft invalid. Foloseste comanda /viewrafts {shop.bizId} pentru a vedea rafturile.");
                return;
            }
            shop.external.rafts[indexRaft].items.Add(new item(itemDB.name, price));
            player.SendChatMessage("a fost sters itemu");
        }
Example #2
0
        public void addraft(Player player, int id)
        {
            if (playerManager.doesPlayerHasAdmin(player) <= 0)
            {
                player.SendChatMessage("!{#CEF0AC}You need to be an admin.");
                return;
            }
            if (!player.HasData("inShopCreation"))
            {
                player.SendChatMessage("Nu esti in creearea unui shop.");
                return;
            }

            business.model shop = player.GetData <business.model>("inShopCreation");

            bool exist = shop.external.rafts[id] != null ? true : false;

            if (!exist)
            {
                player.SendChatMessage("Raftul nu exista. Foloseste comanda /viewrafts pentru a vedea rafturile.");

                return;
            }
            player.SendChatMessage("A fost sters raftul.");
        }
Example #3
0
        public void viewItems(Player player, int id)
        {
            if (playerManager.doesPlayerHasAdmin(player) <= 0)
            {
                player.SendChatMessage("!{#CEF0AC}You need to be an admin.");
                return;
            }
            if (!player.HasData("inShopCreation"))
            {
                player.SendChatMessage("Nu esti in creearea unui shop.");
                return;
            }

            business.model shop = player.GetData <business.model>("inShopCreation");

            if (shop.external.rafts[id] == null)
            {
                player.SendChatMessage($"Raft invalid. Foloseste comanda /viewrafts {shop.bizId} pentru a vedea rafturile.");
                return;
            }

            for (int i = 0; i < shop.external.rafts[id].items.Count; i++)
            {
                var item = shop.external.rafts[id].items[i];
                player.SendChatMessage($"ID: {i} Item: {item.type} Price: {item.price}");
            }
        }
Example #4
0
        public void onPlayerEntercolShape(ColShape shape, Player player)
        {
            if (shape.HasData("gunshop") && shape.HasData("bizid"))
            {
                business.model gs = business.businessList.Find(shop => shop.bizId == shape.GetData <int>("bizid"));

                player.TriggerEvent("EnterInGunShop", gs);
            }
        }
Example #5
0
 public void OnPlayerEnterColshape(ColShape shape, Player player)
 {
     if (shape.HasData("shop") && shape.HasData("bizid"))
     {
         business.model shop = business.businessList.Find(x => x.bizId == shape.GetData <int>("bizid"));
         Console.WriteLine($"{NAPI.Util.ToJson(shop)}");
         player.TriggerEvent("onEnterShop", shop);
     }
 }
Example #6
0
        public void createBank(Player player, string name)
        {
            var bank = new business.model();

            bank.enterPos          = player.Position;
            bank.owner             = "AdmBot";
            bank.name              = name;
            bank.external          = new external( );
            bank.external.atms     = new List <atm>( );
            bank.external.counters = new List <counter>( );
            player.SetData("inBankCreator", bank);
        }
Example #7
0
 public static async Task readAllShops()
 {
     await databaseManager.selectQuery($"SELECT * FROM business WHERE type = '{(int)type.shop}'", (DbDataReader reader) =>
     {
         business.model shop = new business.model();
         shop.bizId          = (int)reader["id"];
         shop.owner          = (string)reader["owner"];
         shop.external       = NAPI.Util.FromJson <external>((string)reader["external"]);
         shop.enterPos       = NAPI.Util.FromJson <Vector3>((string)reader["enterPos"]);
         shop.type           = type.shop;
         shop.balance        = ( int )reader["balance"];
         shop.sale           = ( int )reader["sale"];
         shop.name           = (string)reader["name"];
         business.businessList.Add(shop);
     }).Execute();
 }
Example #8
0
        public void setCenter(Player player)
        {
            if (playerManager.doesPlayerHasAdmin(player) <= 0)
            {
                player.SendChatMessage("!{#CEF0AC}You need to be an admin.");
                return;
            }
            if (!player.HasData("inShopCreation"))
            {
                player.SendChatMessage("Nu esti in creearea unui shop.");
                return;
            }

            business.model shop = player.GetData <business.model>("inShopCreation");
            shop.external.center = player.Position;
        }
Example #9
0
        public void addGunShop(Player player)
        {
            if (playerManager.doesPlayerHasAdmin(player) <= 0)
            {
                player.SendChatMessage("!{#CEF0AC}You need to be an admin.");
                return;
            }
            business.model gs = new business.model();

            gs.owner = "AdmBot";

            gs.sale     = 0;
            gs.enterPos = player.Position;
            gs.external = new gunshop.external();
            player.SetData("gunShopCreator", gs);
            player.SendChatMessage($"Bizul de tip GunShop a fost adaugat cu id-ul {gs.bizId}. acesta find al lui {gs.owner} fiind spre vnzare cu pretu  de {gs.sale}.");
        }
Example #10
0
 public void onPlayerAddGasStation(Player client, string name, bool isShop)
 {
     if (playerManager.doesPlayerHasAdmin(client) <= 0)
     {
         client.SendChatMessage("!{#CEF0AC}You need to be an admin.");
         return;
     }
     business.model gasStation = new business.model();
     gasStation.enterPos          = client.Position;
     gasStation.owner             = "AdmBot";
     gasStation.external          = new external();
     gasStation.external.stations = new List <station>();
     gasStation.external.isShop   = isShop;
     gasStation.name = name;
     client.SetData("gasCreation", gasStation);
     client.SendChatMessage($"Gas statio {gasStation.bizId} created. Use /addstation {gasStation.bizId}.");
 }
Example #11
0
        public void addraft(Player player, string name)
        {
            if (playerManager.doesPlayerHasAdmin(player) <= 0)
            {
                player.SendChatMessage("!{#CEF0AC}You need to be an admin.");
                return;
            }
            if (!player.HasData("inShopCreation"))
            {
                player.SendChatMessage("Nu esti in creearea unui shop.");
                return;
            }

            business.model shop = player.GetData <business.model>("inShopCreation");
            shop.external.rafts.Add(new raft(player.Position, name));
            player.SendChatMessage("A fost creat raftul Foloseste comanda /viewrafts pentru a vedea rafturile.");
        }
Example #12
0
        public void setCheckout(Player player)
        {
            if (playerManager.doesPlayerHasAdmin(player) <= 0)
            {
                player.SendChatMessage("!{#CEF0AC}You need to be an admin.");
                return;
            }
            if (!player.HasData("inShopCreation"))
            {
                player.SendChatMessage("Nu esti in creearea unui shop.");
                return;
            }

            business.model shop = player.GetData <business.model>("inShopCreation");
            shop.external.checkout = player.Position;
            player.SendChatMessage("A fost setata pozitia de checkout(unde platesti).");
        }
Example #13
0
        public void AddShopCommand(Player player, string name)
        {
            if (playerManager.doesPlayerHasAdmin(player) <= 0)
            {
                player.SendChatMessage("!{#CEF0AC}You need to be an admin.");
                return;
            }
            business.model shop = new business.model();
            shop.name  = name;
            shop.owner = "AdmCmd"; shop.external = new external();

            shop.external.rafts = new List <raft>();

            shop.enterPos = player.Position;
            player.SetData("inShopCreation", shop);
            player.SendChatMessage($"Esti in creearea shopului. Te rog acum sa seetezi iesirea daca este nevoie. Scrie /setexit false/true (false => nu are iesire deci nu e in vW $$ true => are iesire si este in vw)");
        }
Example #14
0
            public static async Task loadAllGasStations()
            {
                await databaseManager.selectQuery($"SELECT * FROM business WHERE type = '{(int)type.gasStation}'", (DbDataReader reader) =>
                {
                    business.model gs = new business.model();;
                    gs.owner          = (string)reader["owner"];
                    gs.enterPos       = (Vector3)NAPI.Util.FromJson <Vector3>(reader["enterPos"]);
                    gs.sale           = (int)reader["sale"];
                    gs.external       = NAPI.Util.FromJson <external>((string)reader["external"]);
                    gs.name           = (string)reader["name"];
                    gs.bizId          = (int)reader["id"];
                    gs.type           = type.gasStation;
                    gs.balance        = ( int )reader["balance"];
                    gs.type           = type.gasStation;

                    business.businessList.Add(gs);
                }).Execute();
            }
Example #15
0
        public void onPlayerViewRaft(Player player)
        {
            if (playerManager.doesPlayerHasAdmin(player) <= 0)
            {
                player.SendChatMessage("!{#CEF0AC}You need to be an admin.");
                return;
            }
            if (!player.HasData("inShopCreation"))
            {
                player.SendChatMessage("Nu esti in creearea/editarea unui shop.");
                return;
            }

            business.model shop = player.GetData <business.model>("inShopCreation");
            player.SendChatMessage("rafturile sunt: ");
            for (int i = 0; i < shop.external.rafts.Count; i++)
            {
                raft raft = shop.external.rafts[i];
                player.SendChatMessage($"ID: {i} Nume: {raft.name}, Items: {raft.items.Count}, Position: {NAPI.Util.ToJson(raft.name)}");
            }
        }
Example #16
0
        public async void onStart( )
        {
            await databaseManager.selectQuery($"SELECT * FROM business WHERE type = '{(int)type.bank}'", ( DbDataReader reader ) =>
            {
                business.model bank = new business.model();;
                bank.owner          = ( string )reader["owner"];
                bank.enterPos       = ( Vector3 )NAPI.Util.FromJson <Vector3>(reader["enterPos"]);
                bank.sale           = ( int )reader["sale"];
                bank.external       = NAPI.Util.FromJson <external>(( string )reader["external"]);
                bank.name           = ( string )reader["name"];
                bank.bizId          = ( int )reader["id"];
                bank.balance        = ( int )reader["balance"];

                business.businessList.Add(bank);
            }).Execute( );

            NAPI.Task.Run(() =>
            {
                foreach (var bank in business.getBusinessList(type.bank))
                {
                    business.createBusiness(bank);

                    for (int i = 0; i < bank.external.counters.Count; i++)
                    {
                        var counter = bank.external.counters[i];
                        NAPI.Ped.CreatePed(NAPI.Util.GetHashKey("u_m_m_aldinapoli"), counter.pedPosition, counter.pedRotation, false, true, true, true);
                        TextLabel textLabel = NAPI.TextLabel.CreateTextLabel($"[Counter {i}]]", counter.textLabel, 30.0f, 0.75f, 4, new Color(255, 255, 255), false, 0);
                        ColShape bankShape  = NAPI.ColShape.CreateSphereColShape(bank.enterPos, 40);
                        bankShape.SetData("bank", true);
                        bankShape.SetData("bizid", bank.bizId);
                    }
                    foreach (var atm in bank.external.atms)
                    {
                        TextLabel textATM = NAPI.TextLabel.CreateTextLabel($"[ATM {bank.name}]  \n Owner: {bank.owner} \n ", atm.position, 30.0f, 0.75f, 4, new Color(255, 255, 255), false, 0);
                        textATM.SetSharedData("atmData", bank.bizId);
                        NAPI.Marker.CreateMarker(27, new Vector3(atm.position.X, atm.position.Y, atm.position.Z - 0.90f), new Vector3(0, 0, 0), new Vector3(0, 0, 0), 0.6f, 140, 4, 36, false, 0);
                    }
                }
            });
        }
Example #17
0
        public void addraft(Player player)
        {
            if (playerManager.doesPlayerHasAdmin(player) <= 0)
            {
                player.SendChatMessage("!{#CEF0AC}You need to be an admin.");
                return;
            }
            if (!player.HasData("inShopCreation"))
            {
                player.SendChatMessage("Nu esti in creearea unui shop.");
                return;
            }

            business.model shop = player.GetData <business.model>("inShopCreation");

            player.SendChatMessage("Rafturile sunt:");
            for (int i = 0; i < shop.external.rafts.Count; i++)
            {
                player.SendChatMessage($"id: {i} nume: {shop.external.rafts[i]} positia: {NAPI.Util.ToJson(shop.external.rafts[i].position)}");
            }
            player.SendChatMessage("Foloseste comanda /removeraft id pentru a sterge un raft.");
        }
Example #18
0
 public void onPlayerEditShop(Player player, int id)
 {
     if (playerManager.doesPlayerHasAdmin(player) <= 0)
     {
         player.SendChatMessage("!{#CEF0AC}You need to be an admin.");
         return;
     }
     if (player.HasData("inShopEditing"))
     {
         player.SendChatMessage("esti deja in editarea shopului.");
         return;
     }
     business.model shop = business.getBusinessList(type.shop).Find(a => a.bizId == id);
     if (shop == null)
     {
         player.SendChatMessage("nu exista shopul ");
         return;
     }
     player.SetData("inShopCreation", shop);
     player.SendChatMessage("Esti in editatrea shopului acum,");
     player.SetData("inShopEditing", true);
 }
Example #19
0
        public void deleteItem(Player player, int indexRaft, int index)
        {
            if (playerManager.doesPlayerHasAdmin(player) <= 0)
            {
                player.SendChatMessage("!{#CEF0AC}You need to be an admin.");
                return;
            }
            if (!player.HasData("inShopCreation"))
            {
                player.SendChatMessage("Nu esti in creearea unui shop.");
                return;
            }

            business.model shop = player.GetData <business.model>("inShopCreation");

            if (shop.external.rafts[indexRaft] == null)
            {
                player.SendChatMessage($"Raft invalid. Foloseste comanda /viewrafts {shop.bizId} pentru a vedea rafturile.");
                return;
            }
            shop.external.rafts[indexRaft].items.RemoveAt(index);
            player.SendChatMessage("a fost sters itemu");
        }
Example #20
0
        public async void finishShop(Player player)
        {
            if (playerManager.doesPlayerHasAdmin(player) <= 0)
            {
                player.SendChatMessage("!{#CEF0AC}You need to be an admin.");
                return;
            }
            if (!player.HasData("inShopCreation"))
            {
                player.SendChatMessage("Nu esti in creearea unui shop.");
                return;
            }
            business.model shop = player.GetData <business.model>("inShopCreation");
            if (player.HasData("inShopEditing"))
            {
                await databaseManager.updateQuery($"UPDATE business SET external = '{NAPI.Util.ToJson(shop.external)}' WHERE id = '{shop.bizId}'").Execute();
            }
            else
            {
                shop.bizId = await databaseManager.updateQuery($"INSERT INTO business (type, name, owner, enterPos, exitPos, external) VALUES ('{(int)type.shop}', '{shop.name}','{shop.owner}','{NAPI.Util.ToJson(shop.enterPos)}', '{NAPI.Util.ToJson(shop.exitPos)}', '{NAPI.Util.ToJson(shop.external)}')").Execute();

                player.SendChatMessage($"A fost creat shopul cu id-ul {shop.bizId}");
            }
        }
Example #21
0
        public void setExit(Player player, bool value)
        {
            if (playerManager.doesPlayerHasAdmin(player) <= 0)
            {
                player.SendChatMessage("!{#CEF0AC}You need to be an admin.");
                return;
            }
            if (!player.HasData("inShopCreation"))
            {
                player.SendChatMessage("Nu esti in creearea unui shop.");
                return;
            }

            business.model shop = player.GetData <business.model>("inShopCreation");
            if (value)
            {
                shop.exitPos = player.Position;
            }
            else
            {
                shop.exitPos = new Vector3();
            }
            player.SendChatMessage("A fost setata pozitia de iesire.");
        }
Example #22
0
 public static async Task <int> updateGunShop(business.model gs, int id)
 {
     return(await databaseManager.updateQuery($"UPDATE business SET external = '{NAPI.Util.ToJson(gs.external)}' WHERE id = '{id}'").Execute());
 }
Example #23
0
 public static async Task <int> createGasStation(business.model gs)
 {
     return(await databaseManager.updateQuery($"INSERT INTO business (owner, name, type, enterPos, external) VALUES ('{gs.owner}', '{gs.name}', '{(int)type.gasStation}', '{NAPI.Util.ToJson(gs.enterPos)}', '{NAPI.Util.ToJson(gs.external)}')").Execute());
 }