Beispiel #1
0
        public static void CreateServerShop(IPlayer client, int shopid, string name, Position pos)
        {
            if (client == null || !client.Exists)
            {
                return;
            }
            var ServerShopData = new Server_Shops
            {
                shopId        = shopid,
                name          = name,
                posX          = pos.X,
                posY          = pos.Y,
                posZ          = pos.Z,
                pedX          = 0f,
                pedY          = 0f,
                pedZ          = 0f,
                pedRot        = 0f,
                pedModel      = "",
                neededLicense = "None",
                isOnlySelling = false
            };

            try
            {
                ServerShops_.Add(ServerShopData);

                using (gtaContext db = new gtaContext())
                {
                    db.Server_Shops.Add(ServerShopData);
                    db.SaveChanges();
                }

                ServerShopsItems.CreateServerShopItem(client, shopid, "Bagel", 20, 5);
                ServerShopsItems.CreateServerShopItem(client, shopid, "BonBon", 20, 2);
                ServerShopsItems.CreateServerShopItem(client, shopid, "Chips", 20, 4);
                ServerShopsItems.CreateServerShopItem(client, shopid, "Donut", 20, 2);
                ServerShopsItems.CreateServerShopItem(client, shopid, "Eis", 20, 1);
                ServerShopsItems.CreateServerShopItem(client, shopid, "HotDog", 20, 5);
                ServerShopsItems.CreateServerShopItem(client, shopid, "Müsli-Riegel", 20, 2);
                ServerShopsItems.CreateServerShopItem(client, shopid, "Sandwich", 20, 4);
                ServerShopsItems.CreateServerShopItem(client, shopid, "Schokolade", 20, 3);
                ServerShopsItems.CreateServerShopItem(client, shopid, "Wrap", 20, 4);


                HUDHandler.SendNotification(client, 2, 5000, $"Shop mit dem Namen ({ServerShopData.name}) an deiner Position erstellt.");
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Beispiel #2
0
        internal static void openShop(IPlayer player, Server_Shops shopPos)
        {
            try
            {
                if (player == null || !player.Exists)
                {
                    return;
                }
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                int charId = User.GetPlayerOnline(player);
                if (charId <= 0)
                {
                    return;
                }

                if (shopPos.faction > 0 && shopPos.faction != 0)
                {
                    if (!ServerFactions.IsCharacterInAnyFaction(charId))
                    {
                        HUDHandler.SendNotification(player, 3, 2500, "Kein Zugriff [1]"); return;
                    }
                    if (ServerFactions.GetCharacterFactionId(charId) != shopPos.faction)
                    {
                        HUDHandler.SendNotification(player, 3, 2500, $"Kein Zugriff [{shopPos.faction} - {ServerFactions.GetCharacterFactionId(charId)}]"); return;
                    }
                }

                if (shopPos.neededLicense != "None" && !Characters.HasCharacterPermission(charId, shopPos.neededLicense))
                {
                    HUDHandler.SendNotification(player, 3, 5000, $"Du hast hier keinen Zugriff drauf.");
                    stopwatch.Stop();
                    if (stopwatch.Elapsed.Milliseconds > 30)
                    {
                        Alt.Log($"{charId} - openShop benötigte {stopwatch.Elapsed.Milliseconds}ms");
                    }
                    return;
                }

                if (shopPos.isOnlySelling == false)
                {
                    Global.mGlobal.VirtualAPI.TriggerClientEventSafe(player, "Client:Shop:shopCEFCreateCEF", ServerShopsItems.GetShopShopItems(shopPos.shopId), shopPos.shopId, shopPos.isOnlySelling);
                    stopwatch.Stop();
                    if (stopwatch.Elapsed.Milliseconds > 30)
                    {
                        Alt.Log($"{charId} - openShop benötigte {stopwatch.Elapsed.Milliseconds}ms");
                    }
                    return;
                }
                else if (shopPos.isOnlySelling == true)
                {
                    Global.mGlobal.VirtualAPI.TriggerClientEventSafe(player, "Client:Shop:shopCEFCreateCEF", ServerShopsItems.GetShopSellItems(charId, shopPos.shopId), shopPos.shopId, shopPos.isOnlySelling);
                    stopwatch.Stop();
                    if (stopwatch.Elapsed.Milliseconds > 30)
                    {
                        Alt.Log($"{charId} - openShop benötigte {stopwatch.Elapsed.Milliseconds}ms");
                    }
                    return;
                }
                stopwatch.Stop();
                if (stopwatch.Elapsed.Milliseconds > 30)
                {
                    Alt.Log($"{charId} - openShop benötigte {stopwatch.Elapsed.Milliseconds}ms");
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }