Example #1
0
File: MDC.cs Project: Yarpii/MTGRP
        public void CreateBolo(Client player, params object[] arguments)
        {
            Character character = player.GetCharacter();
            var       newBolo   = new Bolo(character.CharacterName, Convert.ToInt32(arguments[1]),
                                           Convert.ToString(arguments[0]));

            ActiveBolos.Add(newBolo);
            newBolo.Id = ActiveBolos.IndexOf(newBolo);

            foreach (var c in PlayerManager.Players)
            {
                if (c.IsViewingMdc)
                {
                    SendBoloToClient(c.Client, newBolo);
                }
            }

            NAPI.Chat.SendChatMessageToPlayer(player, "Successfully submitted Bolo #" + newBolo.Id);
        }
Example #2
0
File: MDC.cs Project: Yarpii/MTGRP
 public void SendBoloToClient(Client player, Bolo bolo)
 {
     //boloId, officer, time, priority, info
     NAPI.ClientEvent.TriggerClientEvent(player, "addBolo", bolo.Id, bolo.ReportingOfficer, bolo.Time.ToString(),
                                         bolo.Priority, bolo.Info);
 }
Example #3
0
        private void MDC_onClientEventTrigger(Client player, string eventName, params object[] arguments)
        {
            switch (eventName)
            {
            case "server_updateMdcAnnouncement":
            {
                break;
            }

            case "server_removeBolo":
            {
                ActiveBolos.RemoveAt((int)arguments[0]);
                API.SendChatMessageToPlayer(player, "You removed Bolo # " + (int)arguments[0]);
                break;
            }

            case "server_createBolo":
            {
                Character character = player.GetCharacter();
                var       newBolo   = new Bolo(character.CharacterName, Convert.ToInt32(arguments[1]),
                                               Convert.ToString(arguments[0]));

                ActiveBolos.Add(newBolo);
                newBolo.Id = ActiveBolos.IndexOf(newBolo);

                foreach (var c in PlayerManager.Players)
                {
                    if (c.IsViewingMdc)
                    {
                        SendBoloToClient(c.Client, newBolo);
                    }
                }

                API.SendChatMessageToPlayer(player, "Successfully submitted Bolo #" + newBolo.Id);
                break;
            }

            case "requestMdcInformation":
            {
                SendAll911ToClient(player);
                SendAllBoloToClient(player);
                break;
            }

            case "server_mdc_close":
            {
                var character = player.GetCharacter();
                ChatManager.RoleplayMessage(character, "logs off of the MDC.", ChatManager.RoleplayMe);
                character.IsViewingMdc = false;
                break;
            }

            case "MDC_SearchForCitizen":
            {
                var name  = (string)arguments[0];
                var phone = (string)arguments[1];

                //First if online.


                Character foundPlayer = null;

                foreach (var playerfound in PlayerManager.Players)
                {
                    if (playerfound == null)
                    {
                        continue;
                    }
                    if (playerfound.CharacterName == name)
                    {
                        foundPlayer = playerfound;
                        break;
                    }
                }

                if (foundPlayer == null)
                {
                    foundPlayer = PhoneManager.GetPlayerWithNumber(phone);
                }

                if (foundPlayer == null)
                {
                    var filter = Builders <Character> .Filter.Eq(x => x.CharacterName, name) |
                                 (Builders <Character> .Filter.Eq("Inventory.PhoneNumber", phone));

                    //Not online.. check DB.
                    var found = DatabaseManager.CharacterTable.Find(filter);
                    if (found.Any())
                    {
                        foundPlayer = found.First();
                    }
                }

                //If still NULL
                if (foundPlayer == null)
                {
                    API.TriggerClientEvent(player, "MDC_SHOW_CITIZEN_INFO", "", "", "", "", "");
                    return;
                }

                //GET VEHICLES.
                var vehicles     = DatabaseManager.VehicleTable.Find(x => x.OwnerId == foundPlayer.Id).ToList();
                var vehiclesList = vehicles.Where(x => x.IsRegistered).Select(x => new[]
                                                                              { VehicleOwnership.returnCorrDisplayName(x.VehModel), x.LicensePlate }).ToArray();

                //Get amount of crimes.
                var amountOfPages = Math.Floor((foundPlayer.GetCrimesNumber() + 9d) / 10d);
                var crimes        = GetCrimeArray(foundPlayer);

                //Store character.
                player.setData("MDC_LAST_CHECKED", foundPlayer);

                //Send Event
                API.TriggerClientEvent(player, "MDC_SHOW_CITIZEN_INFO", foundPlayer.rp_name(), foundPlayer.Birthday,
                                       API.ToJson(vehiclesList), API.ToJson(crimes), amountOfPages);
                break;
            }

            case "MDC_SearchForVehicle":
            {
                var lic = (string)arguments[0];
                vehicle_manager.Vehicle veh = VehicleManager.Vehicles.FirstOrDefault(x => x.LicensePlate == lic) ??
                                              DatabaseManager.VehicleTable.Find(x => x.LicensePlate == lic)
                                              .FirstOrDefault();

                if (veh == null)
                {
                    API.TriggerClientEvent(player, "MDC_SHOW_VEHICLE_INFO", "", "");
                    return;
                }

                API.TriggerClientEvent(player, "MDC_SHOW_VEHICLE_INFO", VehicleOwnership.returnCorrDisplayName(veh.VehModel),
                                       veh.OwnerName, API.GetVehicleClassName(API.GetVehicleClass(veh.VehModel)));
                break;
            }

            case "MDC_RequestNextCrimesPage":
            {
                Character p = player.getData("MDC_LAST_CHECKED");
                if (p == null)
                {
                    return;
                }

                var next   = Convert.ToInt32(arguments[0]);
                var crimes = GetCrimeArray(p, next);

                API.TriggerClientEvent(player, "MDC_UPDATE_CRIMES", API.ToJson(crimes));
                break;
            }
            }
        }