Пример #1
0
        public async void PlayerInit(Player player)
        {
            API.setPlayerNametag(player.Client, player.Username.Roleplay());
            API.setPlayerName(player.Client, player.Username.Roleplay());
            API.setPlayerHealth(player.Client, (int)player.Health);
            API.setPlayerArmor(player.Client, (int)player.Armour);
            API.setEntityDimension(player.Client, player.Dimension);

            player.IsInInterior = (player.Dimension > 0);
            if (player.IsInInterior)
            {
                player.PropertyIn = PropertyManager.Properties.FirstOrDefault(p => p.Dimension == player.Dimension);
            }

            Skin playerSkin = await SkinRepository.GetSkinById(player.Skin);

            API.setPlayerSkin(player.Client, (PedHash)playerSkin.Model);

            List <SkinVariations> skinVars = playerSkin.Variations();

            player.ChatIndicatorLabel       = API.createTextLabel("typing...", player.Client.position, 50, 0.35f, false, player.Dimension);
            player.ChatIndicatorLabel.color = new Color(0, 0, 0, 0);
            player.ChatIndicatorLabel.attachTo(player.Client, null, new Vector3(0, 0, 0.9f), new Vector3());

            for (int i = 0; i < 12; i++)
            {
                API.setPlayerClothes(player.Client, i, skinVars[i].Drawable, skinVars[i].Texture);
            }

            player.IsLogged = true;

            player.MasterAccount.ActiveConnectionLog.PlayerId = player.Id;
            ConnectionLogRepository.UpdateAsync(player.MasterAccount.ActiveConnectionLog);

            if (player.FactionId > 0)
            {
                player.Faction = Faction.FactionData.Single(f => f.Id == player.FactionId);
            }

            player.Weapons = await WeaponRepository.GetAllWeaponsByPlayerIdAsync(player.Id);

            foreach (Weapon w in player.Weapons)
            {
                API.givePlayerWeapon(player.Client, w.Model, w.Ammo, false, false);
            }

            player.Inventory = await InventoryRepository.GetInventoryByOwnerIdAsync(player.Id);

            player.PopulateWeaponSkills();

            await player.LoadPlayerVehicles();

            foreach (Inventory i in player.Inventory)
            {
                if (i.IsPhone())
                {
                    Phone p = PhoneRepository.GetPhoneByIMEI(long.Parse(i.Value));

                    if (p.IsPrimary)
                    {
                        player.PrimaryPhone = p;
                        if (p.PoweredOn)
                        {
                            if (p.BatteryLevel > 3)
                            {
                                p.TurnOn(player.Client);
                            }
                            else
                            {
                                p.TurnOff(player.Client);
                            }
                        }
                        else
                        {
                            p.TurnOff(player.Client);
                        }
                        break;
                    }
                }
            }

            player.InEvent = PlayerEvent.None;

            player.Client.freeze(false);
            player.Client.ToggleCursorLock(false);
            player.Client.transparency = 255;
            API.sendNativeToAllPlayers(Hash.SET_CURRENT_PED_WEAPON, player.Client, (int)WeaponHash.Unarmed, true);

            Player.PlayerData.Add(player.Client, player);

            if (player.LastPosition != new Vector3(0, 0, 0))
            {
                player.Client.position = player.LastPosition;
            }

            API.triggerClientEvent(player.Client, "hasLoggedIn",
                                   ((char)player.MasterAccount.KeyCursor).ToString(),
                                   ((char)player.MasterAccount.KeyInventory).ToString(),
                                   ((char)player.MasterAccount.KeyInteract).ToString());

            API.triggerClientEvent(player.Client, "executeSkillTimer");
            API.triggerClientEvent(player.Client, "loadScoreboard");
            API.triggerClientEvent(player.Client, "initInteractionMenu");

            API.sendNativeToPlayer(player.Client, Hash.SET_CAM_AFFECTS_AIMING, player.Client, true);

            //API.sendNativeToPlayer(player.Client, Hash.SET_PED_CAN_BE_SHOT_IN_VEHICLE, player.Client, true);
            player.Client.invincible = true;

            for (int i = 0; i < 12; i++)
            {
                API.exported.doormanager.refreshDoorState(i);
            }

            UpdateNatives(player);

            PrisonManager.LoadPrisonSentenceForPlayer(player);
            OnPlayerLoggedIn(player);
        }
Пример #2
0
        public async void EditProperty(Client sender, int id = -1, string field = "", string value = "", string val2 = "")
        {
            Player user = Player.PlayerData[sender];

            if (!(user.MasterAccount.AdminLevel >= 4))
            {
                Message.NotAuthorised(sender); return;
            }
            if (field == "" && value == "")
            {
                PropertyCommandUsage(sender);
                return;
            }

            Property        propertyToEdit = null;
            PropertyManager mng            = new PropertyManager();

            if (id == -1)
            {
                float minRange = 2.5f;
                propertyToEdit = mng.GetClosestPropertyToLocation(sender.position, minRange);
                if (propertyToEdit == null)
                {
                    API.SendErrorNotification(sender, "Error: Could not find property"); return;
                }
                id = propertyToEdit.Id;
            }
            else
            {
                if (id > PropertyManager.Properties.Count)
                {
                    API.SendErrorNotification(sender, "Error: Could not find property"); return;
                }
                propertyToEdit = PropertyManager.Properties[id - 1];
            }

            // --- Property is valid, found and ready to edit

            if (field == "Name")
            {
                value += (" " + val2);

                propertyToEdit.Name = value;
                API.setTextLabelText(propertyToEdit.labelHandle, value);
            }

            if (field == "Type")
            {
                PropertyType typeID = ((PropertyType)Int32.Parse(value));
                if (!mng.IsValidTypeID(typeID))
                {
                    PropertyCommandUsage(sender); return;
                }

                propertyToEdit.Type = typeID;

                Globals.Colour col = new Globals.Colour(255, 255, 255);
                switch (typeID)
                {
                case PropertyType.General:    { col = Property.generalColour; break; }

                case PropertyType.Residential: { col = Property.residentialColour; break; }

                case PropertyType.Commericial: { col = Property.commercialColour; break; }

                case PropertyType.Industrial: { col = Property.industrialColour; break; }
                }

                API.setMarkerColor(propertyToEdit.pickupHandle, col.a, col.r, col.g, col.b);
                API.SendWarningNotification(sender, ("You have edited " + propertyToEdit.Name + "'s type ID to: " + propertyToEdit.Type));
            }

            if (field == "Owner")
            {
                if (val2 == "")
                {
                    PropertyCommandUsage(sender); return;
                }

                int val = Int32.Parse(val2);
                int TYPE_PLAYER = 0; int TYPE_COMPANY = 1;
                if (val != TYPE_PLAYER && val != TYPE_COMPANY)
                {
                    PropertyCommandUsage(sender); return;
                }

                // -- Delete all property keys
                mng.DeleteAllPropertyKeys(id);

                // -- Create a new key and give it to X
                if (val == TYPE_PLAYER)
                {
                    Player    recipient = Player.GetPlayerData(value);
                    Inventory key       = null;

                    propertyToEdit.OwnerId = recipient.Id;

                    // --- If the player is online, we should handle it
                    if (API.isPlayerConnected(recipient.Client))   // -- Check may be redundant. Added as extra security
                    {
                        key = new Inventory()
                        {
                            Name     = propertyToEdit.Name + " key",
                            Type     = InventoryType.PropertyKey,
                            Value    = propertyToEdit.Id + "," + Globals.GetUniqueString(),
                            Quantity = 1,
                            OwnerId  = recipient.Id,
                        };
                        recipient.Inventory.Add(key);
                    }
                    else
                    {
                        API.SendErrorNotification(sender, "Player could not be found, use their full name with underscores");
                    }
                    InventoryRepository.AddNewInventoryItem(key);
                    key.Id = InventoryRepository.GetInventoryItemOfTypeByValue(InventoryType.PropertyKey, key.Value).Id;
                    API.SendWarningNotification(sender, "You have set the Owner of " + propertyToEdit.Name + " to " + recipient.Username);
                }
                else if (val == TYPE_COMPANY)
                {
                    // If Faction give to all high ranks? or just highest? or give to admin to give to faction member
                    API.SendErrorNotification(sender, "Not implemented yet");
                }
                return;
            }

            if (field == "EnterPos")
            {
                Vector3        pos = sender.position;
                Globals.Colour col = new Globals.Colour(255, 255, 255);

                switch (propertyToEdit.Type)
                {
                case PropertyType.General:     { col = Property.generalColour;     break; }

                case PropertyType.Residential: { col = Property.residentialColour; break; }

                case PropertyType.Commericial:  { col = Property.commercialColour;  break; }

                case PropertyType.Industrial:  { col = Property.industrialColour;  break; }
                }

                API.deleteEntity(propertyToEdit.pickupHandle);
                propertyToEdit.pickupHandle = API.createMarker(20, pos, new Vector3(0, 0, 0), new Vector3(0, 0, 0), new Vector3(0.5, 0.5, 0.5),
                                                               col.a, col.r, col.g, col.b);

                bool isEnterable = propertyToEdit.IsEnterable;
                col = new Globals.Colour(
                    isEnterable ? 100 : 223,
                    isEnterable ? 223 : 58,
                    isEnterable ? 0 : 0
                    );

                API.deleteEntity(propertyToEdit.labelHandle);
                Vector3 lablePos = pos.Copy(); lablePos.Z += 0.5f;
                propertyToEdit.labelHandle = API.createTextLabel(propertyToEdit.Name, lablePos, 25.0f, 0.75f);
                API.setTextLabelColor(propertyToEdit.labelHandle, col.r, col.g, col.b, col.a);

                propertyToEdit.EnterPosition = pos;
                API.SendWarningNotification(sender, ("You have edited " + propertyToEdit.Name + "'s EnterPos to: " + pos.ToString()));
            }

            if (field == "ExitPos")
            {
                if (value == "-1")
                {
                    propertyToEdit.IsEnterable  = false;
                    propertyToEdit.ExitPosition = new Vector3(0, 0, 0);
                    propertyToEdit.Dimension    = 0;

                    API.setTextLabelColor(propertyToEdit.labelHandle, 223, 58, 0, 255);
                    API.SendWarningNotification(sender, ("You have removed " + propertyToEdit.Name + "'s ExitPos"));
                }
                else
                {
                    propertyToEdit.IsEnterable  = true;
                    propertyToEdit.ExitPosition = sender.position;
                    propertyToEdit.Dimension    = propertyToEdit.Id;

                    API.setTextLabelColor(propertyToEdit.labelHandle, 100, 223, 0, 255);
                    API.SendWarningNotification(sender, ("You have edited " + propertyToEdit.Name + "'s ExitPos to: " + sender.position.ToString() + " (Dimension: " + propertyToEdit.Id + ")"));
                }
            }

            if (field == "Dimension")
            {
                int dimension = Int32.Parse(value);

                if ((int)dimension < 0)
                {
                    PropertyCommandUsage(sender); return;
                }

                propertyToEdit.Dimension = dimension;
                API.SendWarningNotification(sender, ("You have edited " + propertyToEdit.Name + "'s type Dimension: " + dimension));
            }

            await PropertyRepository.UpdateAsync(propertyToEdit);

            return;
        }
Пример #3
0
        private async void DropInventoryItem(Client sender, int id)
        {
            if (!sender.isInVehicle)
            {
                if (!sender.inFreefall && !sender.isParachuting && !sender.isOnLadder)
                {
                    Player    player = Player.PlayerData[sender];
                    Inventory item   = InventoryRepository.GetInventoryItemById(id);

                    API.playPlayerAnimation(player.Client, 0, "pickup_object", "putdown_low");

                    await Task.Run(() =>
                    {
                        Thread.Sleep(350);

                        item.DroppedPos       = Player.GetPositionInFrontOfPlayer(sender, 0.4f, -0.74);
                        item.DroppedRot       = Inventory.GetRotationForItem[item.Type];
                        item.OwnerId          = -1;
                        item.OwnerType        = InventoryOwnerType.Dropped;
                        item.DroppedDimension = sender.dimension;

                        item.DroppedObj = API.createObject(Inventory.GetObjectForItem[item.Type], item.DroppedPos, item.DroppedRot, item.DroppedDimension);
                        item.ApplyPhysics();

                        if (item.IsPhone())
                        {
                            Phone p = PhoneRepository.GetPhoneByIMEI(long.Parse(item.Value));
                            if (p.IsPrimary)
                            {
                                API.triggerClientEvent(sender, "hidePhoneUI");
                            }

                            p.IsPrimary = false;
                            PhoneRepository.UpdateAsync(p);
                        }
                        List <Inventory> inv = null;
                        if (player.InEvent == PlayerEvent.AccessingInventory)
                        {
                            if (player.VehicleInteractingWith != null)
                            {
                                inv = player.VehicleInteractingWith.TrunkItems;
                            }
                            else
                            {
                                inv = player.Inventory;
                            }
                        }
                        inv?.Remove(inv.FirstOrDefault(il => il.Id == item.Id));
                        InventoryRepository.UpdateAsync(item);
                        Inventory.DroppedItems.Add(item);

                        RefreshAfterDropChange(item);
                    });
                }
                else
                {
                    API.SendErrorNotification(sender, "You have to be on the ground to drop items.");
                }
            }
            else
            {
                API.SendErrorNotification(sender, "You drop items in a vehicle");
            }
        }
Пример #4
0
        private async void OnClientEventTrigger(Client sender, string eventName, params object[] arguments)
        {
            switch (eventName)
            {
            case "getInventoryTypeActions":
            {
                Inventory inv = InventoryRepository.GetInventoryItemById((int)arguments[0]);
                if (inv.IsPhone())
                {
                    Phone p = PhoneRepository.GetPhoneByIMEI(long.Parse(inv.Value));
                    API.triggerClientEvent(sender, "displayActionsForItem", inv.Id,
                                           p.IsPrimary
                                    ? JsonConvert.SerializeObject("GIVE,DROP,UNSET PRIMARY".Split(','))
                                    : JsonConvert.SerializeObject("GIVE,DROP,SET PRIMARY".Split(',')));
                    return;
                }

                API.triggerClientEvent(sender, "displayActionsForItem", inv.Id, JsonConvert.SerializeObject(Inventory.GetActionsByType[inv.Type]));
            }
            break;

            case "performActionOnItem":
            {
                Inventory inv = InventoryRepository.GetInventoryItemById((int)arguments[0]);
                switch (arguments[1].ToString())
                {
                case "USE":
                    UsePlayerInventoryItem(sender, (int)arguments[0]);
                    break;

                case "GIVE":
                    GetPlayerToGiveItem(sender, (int)arguments[0]);
                    break;

                case "DROP":
                    DropInventoryItem(sender, (int)arguments[0]);
                    break;

                case "SET PRIMARY":
                    SetPhonePrimary(sender, inv, true);
                    break;

                case "UNSET PRIMARY":
                    SetPhonePrimary(sender, inv, false);
                    break;

                case "RELEASE":
                    DestroyInventoryItem(sender, (int)arguments[0]);
                    break;
                }
            }
            break;

            case "giveItemToPlayer":
                if ((int)arguments[0] == 1)
                {
                    GiveInventoryItem(sender, arguments[1].ToString());
                }
                break;

            case "DisplayPlayerInventory":
            {
                Player p = Player.PlayerData[sender];
                UpdatePlayerInventory(p);
            }
            break;

            case "OnInventoryItemMoved":
            {
                Player    p = Player.PlayerData[sender];
                Inventory item;
                try
                {
                    item = p.Inventory.Single(i => i.Id == (int)arguments[0]);
                }
                catch
                {
                    item = Inventory.DroppedItems.Single(i => i.Id == (int)arguments[0]);
                    Inventory.DroppedItems.Remove(item);
                    API.deleteEntity(item.DroppedObj);

                    if (!Inventory.IsStackable(item))
                    {
                        item.OwnerId   = p.Id;
                        item.OwnerType = InventoryOwnerType.Player;
                        p.Inventory.Add(item);

                        API.SendInfoNotification(p.Client, String.Format("You have picked up a {0}", item.Name));
                        API.playPlayerAnimation(p.Client, 0, "pickup_object", "pickup_low");
                        RefreshAfterDropChange(item);
                    }
                }
                item.SlotPosition = int.Parse(arguments[1].ToString() + arguments[2].ToString());

                InventoryRepository.UpdateAsync(item);
            }
            break;

            case "OnFriskInventoryItemTaken":
            {
                Player    p    = Player.PlayerData[sender];
                Inventory item = null;
                try
                {
                    item = p.Inventory.Single(i => i.Id == (int)arguments[0]);
                }
                catch
                {
                    item = p.PlayerInteractingWith.Inventory.Single(i => i.Id == (int)arguments[0]);
                }

                if (item != null)
                {
                    int    newOwnerId = (int)arguments[1];
                    Player oldOwner   = Player.PlayerData.Values.FirstOrDefault(pl => pl.Id == item.OwnerId);
                    Player newOwner   = Player.PlayerData.Values.FirstOrDefault(pl => p.Id == newOwnerId);

                    API.SendCloseMessage(sender, 10.0f, "~#C2A2DA~",
                                         p != oldOwner
                                    ? string.Format("{0} {1} takes a {2} from {3}.", p.Faction.Ranks[p.FactionRank].Title,
                                                    API.getPlayerName(sender), item.Name, oldOwner.Username.Roleplay())
                                    : string.Format("{0} {1} places a {2} on {3}.", p.Faction.Ranks[p.FactionRank].Title,
                                                    API.getPlayerName(sender), item.Name, newOwner.Username.Roleplay()));

                    item.OwnerId      = newOwner.Id;
                    item.OwnerType    = InventoryOwnerType.Player;
                    item.SlotPosition = int.Parse(arguments[2].ToString() + arguments[3].ToString());

                    InventoryRepository.UpdateAsync(item);

                    RefreshPlayerInventory(p.PlayerInteractingWith);
                    ShowFriskInventory(p, p.PlayerInteractingWith);
                }
            }
            break;

            case "OnTrunkInventoryItemTaken":
            {
                int    oldOwnerId;
                Player p    = Player.PlayerData[sender];
                string type = arguments[2].ToString();

                Vehicle   vTo   = null;
                Player    from  = null;
                Vehicle   vFrom = null;
                Player    to    = null;
                Inventory item  = null;

                item = InventoryRepository.GetInventoryItemById((int)arguments[0]);
                Console.WriteLine(arguments[1].ToString());

                if (type == "trunk")
                {
                    vTo = Vehicle.VehicleData.Values.FirstOrDefault(
                        ve => ve.Id == int.Parse(arguments[1].ToString()));
                    from = p;
                }
                else
                {
                    to = Player.PlayerData.Values.FirstOrDefault(
                        pl => pl.Id == int.Parse(arguments[1].ToString()));
                    if (item.OwnerType == InventoryOwnerType.Vehicle)
                    {
                        vFrom = Vehicle.VehicleData.Values.FirstOrDefault(ve => ve.Id == item.OwnerId);
                    }
                }

                oldOwnerId = item.OwnerId;

                item.OwnerType = vTo != null
                            ? InventoryOwnerType.Vehicle
                            : to != null
                                ? InventoryOwnerType.Player
                                : InventoryOwnerType.Dropped;
                item.OwnerId      = vTo != null ? vTo.Id : to != null ? p.Id : -1;
                item.SlotPosition = int.Parse(arguments[3].ToString() + arguments[4].ToString());

                InventoryRepository.UpdateAsync(item);

                if (oldOwnerId == -1)
                {
                    Inventory.DroppedItems.Remove(Inventory.DroppedItems.Single(i => i.Id == (int)arguments[0]));
                    API.deleteEntity(item.DroppedObj);

                    API.SendInfoNotification(p.Client, String.Format("You have picked up a {0}", item.Name));
                    API.playPlayerAnimation(p.Client, 0, "pickup_object", "pickup_low");
                    RefreshAfterDropChange(item);
                }

                p.Inventory = await InventoryRepository.GetInventoryByOwnerIdAsync(p.Id);

                if (vFrom != null)
                {
                    vFrom.TrunkItems.Remove(vFrom.TrunkItems.FirstOrDefault(vl => vl.Id == item.Id));
                }
                if (item.OwnerType == InventoryOwnerType.Vehicle)
                {
                    if (oldOwnerId != item.OwnerId)
                    {
                        vTo.TrunkItems.Add(item);
                    }
                    else
                    {
                        vTo.TrunkItems.FirstOrDefault(vl => vl.Id == item.Id).SlotPosition = item.SlotPosition;
                    }
                }

                ShowTrunkInventory(p, p.VehicleInteractingWith);

                if (p == to)
                {
                    return;
                }

                string fromString = vTo != null ? $"{vTo.DisplayName}" : $"{vFrom.DisplayName}";
                API.SendCloseMessage(sender, 10.0f, "~#C2A2DA~",
                                     vTo == null
                                ? string.Format("{0} takes a {1} from the {2}.",
                                                API.getPlayerName(sender), item.Name, fromString)
                                : string.Format("{0} places a {1} on the {2}.",
                                                API.getPlayerName(sender), item.Name, fromString));
                break;
            }

            case "OnHeaderSlotItemSelected":
            {
                Player    p    = Player.PlayerData[sender];
                Inventory item = null;
                try
                {
                    item = p.Inventory.FirstOrDefault(i => i.Id == (int)arguments[0]);
                }
                catch
                {
                    Console.WriteLine("{0}: Error occurred when trying to open Header Slot with ID: {1}", Server.Date.ToString(), (int)arguments[0]);
                    return;
                }

                if (item != null)
                {
                    if (item.IsBag())
                    {
                    }
                }
            }
            break;

            case "OnInventoryClose":
            {
                Player p = Player.PlayerData[sender];
                if (p.AccessingBank != -1)
                {
                }
                p.InEvent = PlayerEvent.None;
            }
            break;
            }
        }
Пример #5
0
        private async void OnResourceStart()
        {
            API.setGamemodeName("pbrp");

            Server serverData = ServerRepository.LoadServerData();

            Server.Date = serverData.DateTime;

            Globals.MAX_PLAYERS = API.getMaxPlayers();

            LoadWeatherData();

            Player.IDs = new Client[Globals.MAX_PLAYERS];
            Player.IDs.Initialize();

            Vehicle.IDs = new GrandTheftMultiplayer.Server.Elements.Vehicle[2000];
            Vehicle.IDs.Initialize();

            // -- Dropped Weapons
            Weapon.DroppedWeapons = WeaponRepository.GetAllDroppedWeapons();
            foreach (Weapon w in Weapon.DroppedWeapons)
            {
                string weaponName = NameToHash.Weapons.Keys.Where(k => NameToHash.Weapons[k] == (WeaponHash)w.Model).First();
                w.DroppedObj = API.createObject(NameToHash.WeaponObjects[weaponName], w.DroppedPos, w.DroppedRot, w.DroppedDimension);
            }

            // --- Dropped Items
            Inventory.DroppedItems = await InventoryRepository.GetAllDroppedInventoryItems();

            foreach (Inventory i in Inventory.DroppedItems)
            {
                i.DroppedObj = API.createObject(Inventory.GetObjectForItem[i.Type], i.DroppedPos, i.DroppedRot, i.DroppedDimension);
            }

            SkinImagePed = API.createPed(PedHash.Barry, new Vector3(-697.0174, 5803.262, 17.33096), 90, 0);

            System.Globalization.CultureInfo.DefaultThreadCurrentCulture = new System.Globalization.CultureInfo("en-US");

            API.removeIpl("bnkheist_apt_dest");
            API.removeIpl("bnkheist_apt_dest_vfx");
            API.removeIpl("bnkheist_apt_dest_lod");
            API.requestIpl("bnkheist_apt_norm");
            API.requestIpl("bnkheist_apt_norm_lod");
            API.removeIpl("CS1_02_cf_offmission");
            API.requestIpl("CS1_02_cf_onmission1");
            API.requestIpl("CS1_02_cf_onmission2");
            API.requestIpl("CS1_02_cf_onmission3");
            API.requestIpl("CS1_02_cf_onmission4");

            API.removeIpl("fakeint");
            API.requestIpl("shr_int");

            API.createObject(1539730305, new Vector3(-810.866821, -210.795883, 340.32489), new Vector3(0, 0, 14.6697245));
            API.createObject(1539730305, new Vector3(-809.520752, -210.520264, 341.861816), new Vector3(89.0096512, -2.6680425e-08, -163.269455));
            API.createObject(1539730305, new Vector3(-810.520752, -208.520264, 341.861816), new Vector3(89.0096512, 4.00206375e-08, -78.2687149));
            API.createObject(1539730305, new Vector3(-810.520752, -212.520264, 341.861816), new Vector3(89.0096512, -2.134434e-07, 101.731239));

            //API.requestIpl("shr_int_lod");

            var doorManager = API.exported.doormanager;

            // -- Base Doors
            doorManager.setDoorState(doorManager.registerDoor(-1666470363, new Vector3(-109.65, 6462.11, 31.98499)), false, 0);   // PB Bank Right Door 1(1)
            doorManager.setDoorState(doorManager.registerDoor(-353187150, new Vector3(-111.48, 6463.94, 31.98499)), false, 0);    // PB Bank Left Door 2 (2)

            doorManager.setDoorState(doorManager.registerDoor(-1501157055, new Vector3(-442.66, 6015.222, 31.86633)), true, 0);   // PB PD Left Door (3)
            doorManager.setDoorState(doorManager.registerDoor(-1501157055, new Vector3(-444.66, 6017.060, 31.86633)), true, 0);   // PB PD Right Door (3)

            doorManager.setDoorState(doorManager.registerDoor(1417577297, new Vector3(-37.33113, -1108.873, 26.7198)), true, 0);  // Simeon Garage Door 1 (5)
            doorManager.setDoorState(doorManager.registerDoor(2059227086, new Vector3(-39.13366, -1108.218, 26.7198)), true, 0);  // Simeon Garage Door 2 (6)
            doorManager.setDoorState(doorManager.registerDoor(2059227086, new Vector3(-59.89302, -1092.952, 26.88362)), true, 0); // Simeon Garage Door 3 (7)
            doorManager.setDoorState(doorManager.registerDoor(1417577297, new Vector3(-60.54582, -1094.749, 26.88872)), true, 0); // Simeone Garage Door 4 (8)

            doorManager.setDoorState(doorManager.registerDoor(-116041313, new Vector3(127.9552, -1298.503, 29.41962)), true, 0);  // LS Strip Club Door 1 (9)
            doorManager.setDoorState(doorManager.registerDoor(668467214, new Vector3(96.09197, -1284.854, 29.43878)), true, 0);   // LS Strip Club Door 2 (10)

            // --- PD INTERIOR DOORS

            doorManager.setDoorState(doorManager.registerDoor(-1033001619, new Vector3(463.4782, -1003.538, 25.00599)), true, 0); // LS PD Door 1 (11)
            doorManager.setDoorState(doorManager.registerDoor(749848321, new Vector3(461.2865, -985.3206, 30.83926)), true, 0);   // LS PD Door 2 (12)
            doorManager.setDoorState(doorManager.registerDoor(749848321, new Vector3(453.0793, -983.1895, 30.83926)), true, 0);   // LS PD Door 3 (Armoury) (13)

            PDManager.AddCell(631614199, new Vector3(464.5601, -992.6381, 25.0649), true);                                        // LS PD Cell 1
            PDManager.AddCell(631614199, new Vector3(461.8293, -994.4047, 25.0649), true);                                        // LS PD Cell 2
            PDManager.AddCell(631614199, new Vector3(461.8293, -998.6381, 25.0649), true);                                        // LS PD Cell 3
            PDManager.AddCell(631614199, new Vector3(461.8293, -1002.6381, 25.0649), true);                                       // LS PD Cell 4

            // -- Property Doors are handled in Property Manager

            ServerDay   = Server.Date.Day;
            ServerMonth = Server.Date.Month;
            ServerYear  = Server.Date.Year;

            ServerHour   = Server.Date.Hour;
            ServerMinute = Server.Date.Minute;

            API.delay(1200, true, OnServerTick);
        }
Пример #6
0
        public void DisconnectPlayer(Client player)
        {
            Player user = null;

            try
            {
                user = Player.PlayerData[player];
            }
            catch
            {
                user = Player.PlayerData.Values.FirstOrDefault(i => i.Username.Roleplay() == player.name);
            }

            if (user != null)
            {
                if (user.IsLogged)
                {
                    user.IsLogged     = false;
                    user.LastPosition = player.position;
                    user.LastRotation = player.rotation;
                    user.Health       = player.health;
                    user.Armour       = player.armor;
                    user.Dimension    = player.dimension;

                    user.ChatIndicatorLabel.text = "";
                    API.deleteEntity(user.ChatIndicatorLabel);

                    user.WeaponSkillData = string.Join(",", user.WeaponSkill.Values);

                    user.SavePlayerVehicles();

                    if (user.InEvent == PlayerEvent.VehicleDealership)
                    {
                        user.LastPosition = new Vector3(-257.5197 + (new Random().Next(-50, 50) / 20), 6211.149 + (new Random().Next(-50, 50) / 20), z: 31.48923);
                        user.LastRotZ     = 121.6988;
                    }
                    Vehicle ve = Vehicle.VehicleData.Values.FirstOrDefault(v => v.IsDealerVehicle && v.OwnerId == user.Id);

                    if (ve != null)
                    {
                        API.deleteEntity(ve.DealershipEmployee);
                        ve.Entity.Delete();
                    }

                    if (user.SelectedCash != null)
                    {
                        InventoryRepository.UpdateAsync(user.SelectedCash);
                    }
                    if (user.SelectedCardAccount != null)
                    {
                        BankRepository.UpdateAsync(user.SelectedCardAccount);
                    }

                    user.MasterAccount.ActiveConnectionLog.DisconnectTime = Server.Date;
                    ConnectionLogRepository.UpdateAsync(user.MasterAccount.ActiveConnectionLog);
                    WeaponRepository.UpdateAllAsync(user.Weapons);
                    PlayerRepository.UpdateAsync(user);
                    Player.PlayerData.Remove(user.Client);
                }
                else
                {
                    Player.PlayerData.Remove(user.Client);
                }
                Master.MasterData.Remove(user.MasterAccount);
            }
            player.FadeIn(0);
            API.triggerClientEvent(player, "onPlayerDisconnect");
        }
Пример #7
0
        private async void OnClientEventTrigger(Client sender, string eventName, params object[] arguments)
        {
            if (eventName == "ActivateBank")
            {
                Player p = Player.PlayerData[sender];
                sender.position = new Vector3(-113.4233, 6469.712, 31.62671);
                sender.rotation = new Vector3(0, 0, -20);

                API.sendNativeToPlayer(sender, Hash.TASK_PAUSE, sender, 240000000);

                API.triggerClientEvent(sender, "onExecuteBank");
                p.InEvent = PlayerEvent.UsingBank;

                API.triggerClientEvent(sender, "showBankOptions");
            }
            if (eventName == "accessAccount")
            {
                Player p = Player.PlayerData[sender];
                p.AccessingBank   = -1;
                p.TransactionType = -1;

                p.AwaitingInventorySelection = InventoryType.BankCard;

                InventoryManager.UpdatePlayerInventory(p);
            }
            else if (eventName == "newBankAccountChoice")
            {
                Player p = Player.PlayerData[sender];
                p.AccessingBank   = -1;
                p.TransactionType = -1;

                if ((BankAccountType)arguments[0] == BankAccountType.Savings)
                {
                    API.ShowPopupMessage(sender, "Opening Savings Account", "In order to open a new savings account, you will need to make an intial minimum cash deposit of $5,000.", true);

                    p.AwaitingInventorySelection = InventoryType.Money;

                    InventoryManager.UpdatePlayerInventory(p);
                    return;
                }
                else
                {
                    await CreateNewAccountByType(p, BankAccountType.Current, 0, "");
                }
            }
            else if (eventName == "createAccountPinConfirmed")
            {
                Player p = Player.PlayerData[sender];
                p.CreatingAccount.Pin = arguments[0].ToString();

                if (p.CreatingAccount != null)
                {
                    BankRepository.AddNewBankAccount(p.CreatingAccount);
                }
                if (p.CreatingAccountCard != null)
                {
                    p.CreatingAccountCard.AddToPlayer(p, true);
                    InventoryRepository.AddNewInventoryItem(p.CreatingAccountCard);
                }

                p.Inventory.Add(p.CreatingAccountCard);

                API.SendInfoNotification(sender, String.Format("You have successfully created a new {0}", p.CreatingAccount.Type == BankAccountType.Current ? "Current Account" : "Savings Account"), 6);

                p.CreatingAccount     = null;
                p.CreatingAccountCard = null;
            }
            else if (eventName == "validatePin")
            {
                Player      p           = Player.PlayerData[sender];
                BankAccount bankAccount = BankRepository.GetAccountById(p.AccessingBank);

                if ((string)arguments[0] == bankAccount.Pin)
                {
                    API.triggerClientEvent(sender, "correctPinEntered");
                }
                else
                {
                    API.SendErrorNotification(sender, "You have entered the incorrect PIN. Attempts remaining: " + (3 - ++bankAccount.FailedPinAttempts).ToString());
                    if (bankAccount.FailedPinAttempts == 3)
                    {
                        bankAccount.Locked     = true;
                        bankAccount.LockedType = BankAccountLockedType.FailedPin;
                    }
                    BankRepository.UpdateAsync(bankAccount);
                }
            }
            else if (eventName == "bankInputAction")
            {
                string      title       = "";
                string      message     = "";
                Player      p           = Player.PlayerData[sender];
                BankAccount bankAccount = BankRepository.GetAccountById(p.AccessingBank);
                p.TransactionType = (int)arguments[0];

                string last4Digits = bankAccount.CardNumber.ToString();
                last4Digits = last4Digits.Substring(last4Digits.Length - 4);

                switch (p.TransactionType)
                {
                case 0:
                    API.ShowPopupMessage(sender, "Bank Balance", String.Format("Your balance is: {0}", bankAccount.Balance.ToString("C0")), true);
                    return;

                case 1:
                    p.SelectedCardAccount        = null;
                    p.SelectedCash               = null;
                    p.AwaitingInventorySelection = InventoryType.Money;
                    API.SendInfoNotification(sender, "Select the cash you wish to deposit into the account ending in " + last4Digits, 10);

                    InventoryManager.UpdatePlayerInventory(p);
                    return;

                case 2:
                    title   = "Withdraw funds";
                    message = String.Format("Please enter the amount you wish to withdraw from account ending in {0}:", last4Digits);
                    break;

                case 3:
                    title   = "Transfer funds";
                    message = "Please enter the account number you wish to transfer funds to:";
                    break;

                case 4:
                    title   = "Change PIN number";
                    message = "Please enter the 4 digit pin you wish to change to below:";
                    break;

                case 5:
                    API.ShowPopupPrompt(sender, "confirmReplacementCard", "Replacement Bank Card", "Are you sure you want to receive a replacement bank card?", "", "", true);
                    return;
                }

                API.ShowInputPrompt(sender, "transactionInputReceived", title, message, "", "", true);
            }
            else if (eventName == "transactionInputReceived")
            {
                Player      p           = Player.PlayerData[sender];
                BankAccount bankAccount = BankRepository.GetAccountById(p.AccessingBank);
                if ((int)arguments[0] == 1)
                {
                    long value = 0;
                    try
                    {
                        value = long.Parse(arguments[1].ToString());
                    }
                    catch
                    {
                        var message = $"<span style='color:#f00'>Error: Value is invalid.</span><br />{arguments[3]}";
                        API.ShowInputPrompt(sender, "transactionInputReceived", arguments[2].ToString(), message, "", "", true);
                        return;
                    }


                    switch (p.TransactionType)
                    {
                    case 2:
                        if (bankAccount.Balance >= value && value > 0 && value <= 150001)
                        {
                            Inventory cashItem = Inventory.CreateCashInventoryItem(value);
                            cashItem.OwnerType = InventoryOwnerType.Player;
                            cashItem.OwnerId   = p.Id;
                            if (!cashItem.AddToPlayer(p, true))
                            {
                                API.SendErrorNotification(sender, "You don't have enough space to withdraw this amount of cash.", 7);
                                return;
                            }

                            InventoryRepository.AddNewInventoryItem(cashItem);
                            p.Inventory.Add(cashItem);
                            CashLogRepository.AddNew(new CashLog(bankAccount.Id, p.Id, value, MoneyTransferMethod.BankWithdraw));
                            bankAccount.Balance -= value;

                            API.SendInfoNotification(p.Client, $"Your new bank balance is {bankAccount.Balance}", 10);
                        }
                        else
                        {
                            API.ShowInputPrompt(sender, "transactionInputReceived", arguments[2].ToString(), "<span style='color:#f00'>Error: Insufficient funds.</span><br />Please enter the amount you wish to withdraw from this account:", "", "", true);
                        }
                        break;

                    case 3:
                        if ((int)arguments[0] == 1)
                        {
                            try
                            {
                                BankAccount targetAccount = BankRepository.GetAccountByCardNumber(long.Parse(arguments[1].ToString()));
                                string      last4Digits   = arguments[1].ToString();
                                last4Digits = last4Digits.Substring(last4Digits.Length - 4);

                                p.TransactionType = targetAccount.Id;
                                API.ShowInputPrompt(sender, "transferAmountToAccount", "Transfer funds to account",
                                                    $"Please enter the amount you wish to transfer to the account ending in {last4Digits}", "", "", true);
                            }
                            catch
                            {
                                API.ShowInputPrompt(sender, "transactionInputReceived", arguments[2].ToString(), "<span style='color:#f00'>Error: Invalid card number</span><br/>Please enter the account number you wish to transfer funds to:", "", "", true);
                            }
                        }
                        break;

                    case 4:
                        if (value > 999 && value < 10000)
                        {
                            string encPin = value.ToString();
                            bankAccount.Pin = encPin;

                            API.SendInfoNotification(sender, "Your new PIN is " + value, 8);
                        }
                        break;
                    }
                    API.triggerClientEvent(sender, "reenableCursor");
                    BankRepository.UpdateAsync(bankAccount);
                    PlayerRepository.UpdateAsync(p);
                }
                else
                {
                    API.triggerClientEvent(sender, "reenableCursor");
                }
            }
            else if (eventName == "confirmReplacementCard")
            {
                if ((int)arguments[0] == 1)
                {
                    bool        uniqueNumber = false;
                    Player      p            = Player.PlayerData[sender];
                    BankAccount bankAccount  = BankRepository.GetAccountById(p.AccessingBank);

                    while (!uniqueNumber)
                    {
                        string newCardNumber = await CreateCardNumber(16);

                        Inventory inv = InventoryRepository.GetInventoryItemOfTypeByValue(InventoryType.BankCard, newCardNumber);
                        if (inv == null)
                        {
                            Inventory newCard = new Inventory()
                            {
                                OwnerId  = p.Id,
                                Value    = newCardNumber,
                                Type     = InventoryType.BankCard,
                                Name     = "PaletoCard",
                                Quantity = 1
                            };
                            InventoryRepository.AddNewInventoryItem(newCard);
                            p.Inventory.Add(newCard);
                            uniqueNumber = true;
                        }
                    }

                    API.SendInfoNotification(sender, "You have been given a new bank card.");
                    API.triggerClientEvent(sender, "reenableCursor");
                    // Ask if they want the old card destroyed?
                }
            }
            else if (eventName == "transferAmountToAccount")
            {
                Player p = Player.PlayerData[sender];

                BankAccount bankAccount   = BankRepository.GetAccountById(p.AccessingBank);
                BankAccount targetAccount = BankRepository.GetAccountById(p.TransactionType);
                long        value         = 0;

                try { value = long.Parse(arguments[1].ToString()); } catch {
                    var message = $"<span style='color:#f00'>Error: Value is invalid.</span><br />{arguments[3]}";
                    API.triggerClientEvent(sender, "confirmInput", "transactionInputReceived", arguments[2], message);
                    return;
                }

                if (bankAccount.Balance <= value)
                {
                    return;
                }
                bankAccount.Balance   -= value;
                targetAccount.Balance += value;

                API.sendChatMessageToPlayer(sender, "Your new balance is " + bankAccount.Balance);

                API.triggerClientEvent(sender, "reenableCursor");

                BankRepository.UpdateAsync(bankAccount);
                BankRepository.UpdateAsync(targetAccount);
            }
            else if (eventName == "validateIDGiven")
            {
                if ((int)arguments[0] == 1)
                {
                }
            }
            else if (eventName == "onBankLeave")
            {
                Player p = Player.PlayerData[sender];
                p.InEvent = PlayerEvent.None;

                if (p.AwaitingInventorySelection == InventoryType.BankCard)
                {
                    p.AwaitingInventorySelection = null;
                }

                API.sendNativeToPlayer(sender, Hash.TASK_PAUSE, sender, -1);
                API.triggerClientEvent(sender, "onEnterBankCol", ((char)p.MasterAccount.KeyInteract).ToString(), p.MasterAccount.KeyInteract);
            }
        }