예제 #1
0
파일: garbageman.cs 프로젝트: MTG-RP/V-RP
 public void RespawnGarbageTruck(Client player, vehicle_manager.Vehicle vehicle)
 {
     vehicle.CustomRespawnTimer.Stop();
     vehicle.GarbageBags = 0;
     VehicleManager.respawn_vehicle(vehicle);
     vehicle.UpdateMarkers();
     player.GetCharacter().GarbageTimeLeft = 0;
     player.GetCharacter().GarbageTimeLeftTimer.Stop();
     player.GetCharacter().IsOnGarbageRun = false;
     player.GetCharacter().update_ped();
     player.SendChatMessage("~r~The garbage run has ended. Your garbage truck was removed.");
     API.TriggerClientEvent(player, "garbage_removewaypoint");
 }
예제 #2
0
파일: garbageman.cs 프로젝트: MTG-RP/V-RP
        public void unloadtrash_cmd(Client player)
        {
            Character character = player.GetCharacter();

            if (character.JobOne.Type != JobManager.JobTypes.Garbageman)
            {
                player.SendChatMessage("You must be a garbageman to use this command!");
                return;
            }

            if (!character.IsOnGarbageRun)
            {
                player.SendChatMessage("You must be on a garbage run to unload trash.");
                return;
            }

            if (player.position.DistanceTo(character.JobOne.MiscOne.Location) > 10)
            {
                player.SendChatMessage("You must be at the trash depot to unload the trash.");
                return;
            }

            vehicle_manager.Vehicle closestVeh = VehicleManager.GetClosestVehicle(player, 10f).GetVehicle();

            if (closestVeh == null || closestVeh.Job.Type != JobManager.JobTypes.Garbageman)
            {
                player.SendChatMessage("~r~You must be at the back of your garbage truck to unload the trash.");
                return;
            }

            if (player.rotation.Z > API.GetEntityRotation(closestVeh.NetHandle).Z + 20 || player.rotation.Z < API.GetEntityRotation(closestVeh.NetHandle).Z - 20)
            {
                player.SendChatMessage("~r~You must be at the back of your garbage truck to unload the trash.");
                return;
            }

            if (closestVeh.GarbageBags == 0)
            {
                player.SendChatMessage("~r~Your garbage truck has no trash to unload!");
                return;
            }

            LogManager.Log(LogManager.LogTypes.Stats, $"[Job] {character.CharacterName}[{player.GetAccount().AccountName}] has earned ${closestVeh.GarbageBags * 100} from a garbage run.");
            InventoryManager.GiveInventoryItem(character, new Money(), closestVeh.GarbageBags * 100);
            ChatManager.RoleplayMessage(character, "uses the garbage truck's control panel to unload the trash.", ChatManager.RoleplayMe);
            player.SendChatMessage($"You were paid ${closestVeh.GarbageBags * 100} for unloading {closestVeh.GarbageBags} trash bags.");
            closestVeh.GarbageBags = 0;
            closestVeh.UpdateMarkers();
            API.Shared.SendPictureNotificationToPlayer(player, $"Thanks for keeping Los Santos clean!", "CHAR_PROPERTY_CAR_SCRAP_YARD", 0, 1, "Los Santos Sanitations", "Garbage Notification");
        }
예제 #3
0
파일: garbageman.cs 프로젝트: MTG-RP/V-RP
        private void API_onClientEventTrigger(Client player, string eventName, params object[] arguments)
        {
            switch (eventName)
            {
            case "garbage_throwbag":
            {
                Character character = player.GetCharacter();
                API.DeleteEntity(character.GarbageBag);
                character.GarbageBag = null;

                vehicle_manager.Vehicle closestVeh = VehicleManager.GetClosestVehicle(player, 10f).GetVehicle();

                if (API.IsPlayerInAnyVehicle(player))
                {
                    player.SendChatMessage("You cannot be in a vehicle while doing this.");
                    return;
                }
                if (closestVeh == null || closestVeh.Job.Type != JobManager.JobTypes.Garbageman)
                {
                    ChatManager.RoleplayMessage(character, "throws the garbage bag into the air.", ChatManager.RoleplayMe);
                    player.SendChatMessage("~r~You must throw the garbage bag into the back of the garbage truck!");
                    return;
                }
                if (player.rotation.Z > API.GetEntityRotation(closestVeh.NetHandle).Z + 30 || player.rotation.Z < API.GetEntityRotation(closestVeh.NetHandle).Z - 30)
                {
                    ChatManager.RoleplayMessage(character, "throws the garbage bag at the garbage truck and misses.", ChatManager.RoleplayMe);
                    player.SendChatMessage("~r~You failed to throw the garbage bag into the back of the garbage truck!");
                    return;
                }
                if (closestVeh.GarbageBags >= 10)
                {
                    ChatManager.RoleplayMessage(character, "throws the garbage bag at the garbage truck and the garbage goes everywhere!", ChatManager.RoleplayMe);
                    player.SendChatMessage("~r~Garbage trucks can only hold 10 bags!");
                    return;
                }

                ChatManager.RoleplayMessage(character, "successfully throws the garbage bag into the garbage truck.", ChatManager.RoleplayMe);
                player.SendChatMessage("~b~Pick up another garbage bag if you have time or deliver the garbage bags to the depot!");
                closestVeh.GarbageBags += 1;
                closestVeh.UpdateMarkers();
                break;
            }

            case "garbage_pickupbag":
            {
                Character character = player.GetCharacter();

                if (character == null)
                {
                    return;
                }

                if (character.JobOne?.Type != JobManager.JobTypes.Garbageman)
                {
                    return;
                }

                pickuptrash_e(character.Client);
                break;
            }
            }
        }
예제 #4
0
        private void API_onClientEventTrigger(Client sender, string eventName, params object[] arguments)
        {
            Character character = sender.GetCharacter();

            switch (eventName)
            {
            case "myvehicles_locatecar":
                vehicle_manager.Vehicle lcVeh =
                    VehicleManager.Vehicles.Single(
                        x => x.NetHandle.Value == Convert.ToInt32(arguments[0]) && x.OwnerId == character.Id);
                Vector3 loc = API.GetEntityPosition(lcVeh.NetHandle);
                API.TriggerClientEvent(sender, "myvehicles_setCheckpointToCar", loc.X, loc.Y, loc.Z);
                API.SendChatMessageToPlayer(sender, "A checkpoint has been set to the vehicle.");
                break;

            case "myvehicles_abandoncar":
                vehicle_manager.Vehicle acVeh =
                    VehicleManager.Vehicles.Single(
                        x => x.Id == Convert.ToInt32(arguments[0]) && x.OwnerId == character.Id);
                VehicleManager.despawn_vehicle(acVeh);
                VehicleManager.delete_vehicle(acVeh);
                acVeh.Delete();
                API.SendChatMessageToPlayer(sender,
                                            $"You have sucessfully abandoned your ~r~{VehicleOwnership.returnCorrDisplayName(acVeh.VehModel)}~w~");
                break;

            case "myvehicles_sellcar":
                vehicle_manager.Vehicle scVeh =
                    VehicleManager.Vehicles.Single(
                        x => x.Id == Convert.ToInt32(arguments[0]) && x.OwnerId == character.Id);
                var tid    = (string)arguments[1];
                var target = PlayerManager.ParseClient(tid);
                if (target == null)
                {
                    API.SendChatMessageToPlayer(sender, "That player isn't online or doesn't exist.");
                    return;
                }
                var targetChar    = target.GetCharacter();
                var targetAccount = target.GetAccount();

                var price = 0;
                if (!int.TryParse((string)arguments[2], out price))
                {
                    API.SendChatMessageToPlayer(sender, "Invalid price entered.");
                    return;
                }
                if (price < 0)
                {
                    API.SendChatMessageToPlayer(sender, "Price cannot be negative.");
                    return;
                }

                if (targetChar.OwnedVehicles.Count >= VehicleManager.GetMaxOwnedVehicles(targetChar.Client))
                {
                    API.SendChatMessageToPlayer(sender, "This player cannot own any more vehicles.");
                    return;
                }

                API.SendChatMessageToPlayer(sender,
                                            $"Are you sure you would like to sell the ~r~{VehicleOwnership.returnCorrDisplayName(scVeh.VehModel)}~w~ for ~r~${price}~w~ to the player ~r~{targetChar.rp_name()}~w~?");
                API.SendChatMessageToPlayer(sender, "Use /confirmsellvehicle to sell.");
                API.SetEntityData(sender, "sellcar_selling", new dynamic[] { scVeh, targetChar, price });
                break;

            case "groupvehicles_locatecar":
                vehicle_manager.Vehicle gVeh =
                    VehicleManager.Vehicles.Single(
                        x => x.NetHandle.Value == Convert.ToInt32(arguments[0]) && x.GroupId == character.GroupId);
                Vector3 location = API.GetEntityPosition(gVeh.NetHandle);
                API.TriggerClientEvent(sender, "myvehicles_setCheckpointToCar", location.X, location.Y, location.Z);
                API.SendChatMessageToPlayer(sender, "A checkpoint has been set to the vehicle.");
                break;
            }
        }
예제 #5
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;
            }
            }
        }