public static void startSafeDoorCracking(Client player) { if (!player.HasData("HEIST_DRILL")) { Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, $"У Вас нет дрели для взлома", 3000); return; } if (isCracking) { Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, $"Взлом уже начат", 3000); return; } if (isOpen) { Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, $"Дверь в хранилище уже открыта", 3000); return; } nInventory.Remove(player, ItemType.BagWithDrill, 1); player.SetClothes(5, 0, 0); player.ResetData("HEIST_DRILL"); isCracking = true; safeDrill = NAPI.Object.CreateObject(-443429795, new Vector3(253.9534, 225.2, 102.22), new Vector3(0, 0, -18), 255, 0); label = NAPI.TextLabel.CreateTextLabel("~r~8:00", new Vector3(253.9534, 225.2, 102.22), 4F, 0.3F, 0, new Color(255, 255, 255)); secondsLeft = 480; //timer = Main.StartT(1000, 1000, (o) => updateDoorCracking()); timer = Timers.StartTask("DoorCracking", 1000, () => updateDoorCracking()); canBeClosed = false; Manager.sendFractionMessage(6, "Кто-то пытается взломать дверь в хранилище мэрии."); Manager.sendFractionMessage(7, "Кто-то пытается взломать дверь в хранилище мэрии."); Manager.sendFractionMessage(9, "Кто-то пытается взломать дверь в хранилище мэрии."); Manager.sendFractionMessage(14, "Кто-то пытается взломать дверь в хранилище мэрии."); }
private void OnGarbageCollectedTimer(object playerObject) { Client player = (Client)playerObject; Client driver = player.GetData(EntityData.PLAYER_JOB_PARTNER); // Get garbage bag GTANetworkAPI.Object garbageBag = player.GetData(EntityData.PLAYER_GARBAGE_BAG); player.StopAnimation(); garbageBag.Delete(); // Get the remaining checkpoints int route = driver.GetData(EntityData.PLAYER_JOB_ROUTE); int checkPoint = driver.GetData(EntityData.PLAYER_JOB_CHECKPOINT) + 1; int totalCheckPoints = Constants.GARBAGE_LIST.Where(x => x.route == route).Count(); // Get the current checkpoint Checkpoint garbageCheckpoint = player.GetData(EntityData.PLAYER_JOB_COLSHAPE); garbageCheckpoint.Delete(); NAPI.Task.Run(() => { if (checkPoint < totalCheckPoints) { Vector3 currentGarbagePosition = GetGarbageCheckPointPosition(route, checkPoint); Vector3 nextGarbagePosition = GetGarbageCheckPointPosition(route, checkPoint + 1); // Show the next checkpoint garbageCheckpoint = NAPI.Checkpoint.CreateCheckpoint(CheckpointType.CylinderSingleArrow, currentGarbagePosition, nextGarbagePosition, 2.5f, new Color(198, 40, 40, 200)); driver.SetData(EntityData.PLAYER_JOB_CHECKPOINT, checkPoint); player.SetData(EntityData.PLAYER_JOB_CHECKPOINT, checkPoint); driver.TriggerEvent("showGarbageCheckPoint", currentGarbagePosition); player.TriggerEvent("showGarbageCheckPoint", currentGarbagePosition); // Add the garbage bag garbageBag = NAPI.Object.CreateObject(628215202, currentGarbagePosition, new Vector3(0.0f, 0.0f, 0.0f)); player.SetData(EntityData.PLAYER_GARBAGE_BAG, garbageBag); } else { garbageCheckpoint = NAPI.Checkpoint.CreateCheckpoint(CheckpointType.CylinderCheckerboard, new Vector3(-339.0206f, -1560.117f, 25.23038f), new Vector3(), 2.5f, new Color(198, 40, 40, 200)); driver.SendChatMessage(Constants.COLOR_INFO + InfoRes.route_finished); driver.TriggerEvent("showGarbageCheckPoint", garbageCheckpoint.Position); player.TriggerEvent("deleteGarbageCheckPoint"); } player.SendChatMessage(Constants.COLOR_INFO + InfoRes.garbage_collected); }); if (garbageTimerList.TryGetValue(player.Value, out Timer garbageTimer) == true) { garbageTimer.Dispose(); garbageTimerList.Remove(player.Value); } }
public WeaponCrateModel(string contentItem, int contentAmount, Vector3 position, string carriedEntity, int carriedIdentifier, GTANetworkAPI.Object crateObject) { this.ContentItem = contentItem; this.ContentAmount = contentAmount; this.Position = position; this.CarriedEntity = carriedEntity; this.CarriedIdentifier = carriedIdentifier; this.CrateObject = crateObject; }
private void OnGarbageCollectedTimer(object playerObject) { Client player = (Client)playerObject; Client driver = player.GetData(EntityData.PLAYER_JOB_PARTNER); // Get garbage bag GTANetworkAPI.Object garbageBag = player.GetData(EntityData.PLAYER_GARBAGE_BAG); player.StopAnimation(); garbageBag.Delete(); // Get the remaining checkpoints int route = driver.GetData(EntityData.PLAYER_JOB_ROUTE); int checkPoint = driver.GetData(EntityData.PLAYER_JOB_CHECKPOINT) + 1; int totalCheckPoints = Constants.GARBAGE_LIST.Where(x => x.route == route).Count(); // Get the current checkpoint Checkpoint garbageCheckpoint = player.GetData(EntityData.PLAYER_JOB_COLSHAPE); if (checkPoint < totalCheckPoints) { Vector3 currentGarbagePosition = GetGarbageCheckPointPosition(route, checkPoint); Vector3 nextGarbagePosition = GetGarbageCheckPointPosition(route, checkPoint + 1); // Show the next checkpoint garbageCheckpoint.Position = currentGarbagePosition; garbageCheckpoint.Direction = nextGarbagePosition; driver.SetData(EntityData.PLAYER_JOB_CHECKPOINT, checkPoint); player.SetData(EntityData.PLAYER_JOB_CHECKPOINT, checkPoint); driver.TriggerEvent("showGarbageCheckPoint", currentGarbagePosition); player.TriggerEvent("showGarbageCheckPoint", currentGarbagePosition); // Add the garbage bag garbageBag = NAPI.Object.CreateObject(628215202, currentGarbagePosition, new Vector3(0.0f, 0.0f, 0.0f)); player.SetData(EntityData.PLAYER_GARBAGE_BAG, garbageBag); } else { NAPI.Entity.SetEntityModel(garbageCheckpoint, 4); garbageCheckpoint.Position = new Vector3(-339.0206f, -1560.117f, 25.23038f); driver.SendChatMessage(Constants.COLOR_INFO + Messages.INF_ROUTE_FINISHED); driver.TriggerEvent("showGarbageCheckPoint", garbageCheckpoint.Position); player.TriggerEvent("deleteGarbageCheckPoint"); } if (garbageTimerList.TryGetValue(player.Value, out Timer garbageTimer) == true) { garbageTimer.Dispose(); garbageTimerList.Remove(player.Value); } player.SendChatMessage(Constants.COLOR_INFO + Messages.INF_GARBAGE_COLLECTED); }
public static void OnPlayerDisconnected(Client player, DisconnectionType type, string reason) { if (player.HasData(EntityData.PLAYER_HANDCUFFED) == true) { // Remove player's cuffs GTANetworkAPI.Object cuff = player.GetData(EntityData.PLAYER_HANDCUFFED); cuff.Detach(); cuff.Delete(); } }
public static void CreateWeaponProp(Client player, WeaponHash weapon) { if (!WeaponData.ContainsKey(weapon)) { return; } RemoveWeaponProp(player, WeaponData[weapon].Type); // make sure player has the weapon if (Array.IndexOf(player.Weapons, weapon) == -1) { return; } string bone = ""; Vector3 offset = new Vector3(0.0, 0.0, 0.0); Vector3 rotation = new Vector3(0.0, 0.0, 0.0); switch (WeaponData[weapon].Type) { case WeaponAttachmentType.RightLeg: bone = "SKEL_R_Thigh"; offset = new Vector3(0.02, 0.06, 0.1); rotation = new Vector3(-100.0, 0.0, 0.0); break; case WeaponAttachmentType.LeftLeg: bone = "SKEL_L_Thigh"; offset = new Vector3(0.08, 0.03, -0.1); rotation = new Vector3(-80.77, 0.0, 0.0); break; case WeaponAttachmentType.RightBack: bone = "SKEL_Spine3"; offset = new Vector3(-0.1, -0.15, -0.13); rotation = new Vector3(0.0, 0.0, 3.5); break; case WeaponAttachmentType.LeftBack: bone = "SKEL_Spine3"; offset = new Vector3(-0.1, -0.15, 0.11); rotation = new Vector3(-180.0, 0.0, 0.0); break; } GTANetworkAPI.Object temp_handle = NAPI.Object.CreateObject(NAPI.Util.GetHashKey(WeaponData[weapon].Model), player.Position, player.Rotation, 255, 0); temp_handle.AttachTo(player.Handle, bone, offset, rotation); NAPI.Data.SetEntityData(player.Handle, WeaponKeys[(int)WeaponData[weapon].Type], temp_handle); }
private void OnGarbageCollectedTimer(object playerObject) { NAPI.Task.Run(() => { Client player = (Client)playerObject; Client driver = player.GetData(EntityData.PLAYER_JOB_PARTNER); if (garbageTimerList.TryGetValue(player.Value, out Timer garbageTimer) == true) { garbageTimer.Dispose(); garbageTimerList.Remove(player.Value); } // Get garbage bag GTANetworkAPI.Object garbageBag = player.GetData(EntityData.PLAYER_GARBAGE_BAG); player.StopAnimation(); garbageBag.Delete(); // Get the remaining checkpoints int route = driver.GetData(EntityData.PLAYER_JOB_ROUTE); int checkPoint = driver.GetData(EntityData.PLAYER_JOB_CHECKPOINT) + 1; int totalCheckPoints = Constants.GARBAGE_LIST.Where(x => x.route == route).Count(); if (checkPoint < totalCheckPoints) { Vector3 currentGarbagePosition = GetGarbageCheckPointPosition(route, checkPoint); Vector3 nextGarbagePosition = GetGarbageCheckPointPosition(route, checkPoint + 1); driver.SetData(EntityData.PLAYER_JOB_CHECKPOINT, checkPoint); player.SetData(EntityData.PLAYER_JOB_CHECKPOINT, checkPoint); // Add the garbage bag garbageBag = NAPI.Object.CreateObject(628215202, currentGarbagePosition, new Vector3(0.0f, 0.0f, 0.0f)); player.SetData(EntityData.PLAYER_GARBAGE_BAG, garbageBag); // Create the checkpoints driver.TriggerEvent("showGarbageCheckPoint", currentGarbagePosition, nextGarbagePosition, CheckpointType.CylinderSingleArrow); player.TriggerEvent("showGarbageCheckPoint", currentGarbagePosition, nextGarbagePosition, CheckpointType.CylinderSingleArrow); } else { driver.SendChatMessage(Constants.COLOR_INFO + InfoRes.route_finished); driver.TriggerEvent("showGarbageCheckPoint", new Vector3(49.44239f, 6558.004f, 32.18963f), new Vector3(), CheckpointType.CylinderCheckerboard); player.TriggerEvent("deleteGarbageCheckPoint"); } player.SendChatMessage(Constants.COLOR_INFO + InfoRes.garbage_collected); }); }
public static void RemoveWeaponProp(Client player, WeaponAttachmentType type) { int type_int = (int)type; if (!NAPI.Data.HasEntityData(player.Handle, WeaponKeys[type_int])) { return; } GTANetworkAPI.Object obj = NAPI.Data.GetEntityData(player.Handle, WeaponKeys[type_int]); obj.Delete(); NAPI.Data.ResetEntityData(player.Handle, WeaponKeys[type_int]); }
public static void RemoveWeaponProps(Client player) { foreach (string key in WeaponKeys) { if (!NAPI.Data.HasEntityData(player.Handle, key)) { continue; } GTANetworkAPI.Object obj = NAPI.Data.GetEntityData(player.Handle, key); obj.Delete(); NAPI.Data.ResetEntityData(player.Handle, key); } }
void CancelScuba(Client player) { var character = player.GetCharacter(); //Cancel timer. Timer timer = NAPI.Data.GetEntityData(player, "SCUBA_TIMER"); if (timer != null) { timer.Dispose(); NAPI.Data.ResetEntityData(player, "SCUBA_TIMER"); } //Remove clothes GTANetworkAPI.Object head = NAPI.Data.GetEntityData(player, "SCUBA_HEAD"); GTANetworkAPI.Object tank = NAPI.Data.GetEntityData(player, "SCUBA_TANK"); if (head != null && API.DoesEntityExist(head)) { head.Detach(); head.Delete(); NAPI.Data.ResetEntityData(player, "SCUBA_HEAD"); } if (tank != null && API.DoesEntityExist(tank)) { tank.Detach(); tank.Delete(); NAPI.Data.ResetEntityData(player, "SCUBA_TANK"); } //Set scuba state API.SendNativeToPlayer(player, Hash.SET_ENABLE_SCUBA, player.Handle, false); //Remove exygen NAPI.ClientEvent.TriggerClientEvent(player, "UPDATE_SCUBA_PERCENTAGE", "none"); //Set the variable. character.IsScubaDiving = false; //Set normal clothes character.update_ped(); //Set normal underwater time. API.SendNativeToPlayer(player, Hash.SET_PED_MAX_TIME_UNDERWATER, player.Handle, 60.0f); }
public void RemovePlayerWeapon(Client player, WeaponHash weapon) { if (WeaponData.ContainsKey(weapon)) { string key = WeaponKeys[(int)WeaponData[weapon].Type]; if (NAPI.Data.HasEntityData(player.Handle, key)) { GTANetworkAPI.Object obj = NAPI.Data.GetEntityData(player.Handle, key); if (obj.Model == NAPI.Util.GetHashKey(WeaponData[weapon].Model)) { obj.Delete(); NAPI.Data.ResetEntityData(player.Handle, key); } } } NAPI.Player.RemovePlayerWeapon(player, weapon); }
public void Create() { Object = NAPI.Object.CreateObject(NAPI.Util.GetHashKey("v_ilev_gangsafe"), Position, new Vector3(0.0, 0.0, Rotation), 255, 0); DoorObject = NAPI.Object.CreateObject(NAPI.Util.GetHashKey("v_ilev_gangsafedoor"), Position, new Vector3(0.0, 0.0, Rotation), 255, 0); colShape = NAPI.ColShape.CreateCylinderColShape(Position, 1.25f, 1.0f, 0); Label = NAPI.TextLabel.CreateTextLabel(Main.StringToU16("~g~Safe"), Position + new Vector3(0, 0, 1.05), 5f, 0.65f, 0, new Color(255, 255, 255), false); for (int i = 0; i < 3; i++) { LockAngles.Add(SafeMain.SafeRNG.Next(0, 361)); } colShape.OnEntityEnterColShape += (shape, player) => { try { player.SetData("temp_SafeID", ID); player.SetData("INTERACTIONCHECK", 43); } catch (Exception e) { Console.WriteLine("colShape.OnEntityEnterColShape: " + e.ToString()); } }; colShape.OnEntityExitColShape += (shape, player) => { try { if (player == Occupier) { Occupier = null; } player.SetData("INTERACTIONCHECK", 0); Trigger.ClientEvent(player, "dial", "close"); player.ResetData("temp_SafeID"); } catch (Exception e) { Console.WriteLine("colShape.OnEntityExitColShape: " + e.ToString()); } }; }
private void OnGarbageCollectedTimer(object playerObject) { try { Client player = (Client)playerObject; Client driver = NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB_PARTNER); // Recogemos la bolsa de basura GTANetworkAPI.Object trashBag = NAPI.Data.GetEntityData(player, EntityData.PLAYER_GARBAGE_BAG); NAPI.Player.StopPlayerAnimation(player); NAPI.Entity.DeleteEntity(trashBag); // Obtenemos el total de checkpoints int route = NAPI.Data.GetEntityData(driver, EntityData.PLAYER_JOB_ROUTE); int checkPoint = NAPI.Data.GetEntityData(driver, EntityData.PLAYER_JOB_CHECKPOINT) + 1; int totalCheckPoints = Constants.GARBAGE_LIST.Where(x => x.route == route).Count(); // Obtenemos el checkpoint actual Checkpoint garbageCheckpoint = NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB_COLSHAPE); if (checkPoint < totalCheckPoints) { Vector3 currentGarbagePosition = GetGarbageCheckPointPosition(route, checkPoint); Vector3 nextGarbagePosition = GetGarbageCheckPointPosition(route, checkPoint + 1); // Avanzamos al siguiente checkpoint NAPI.Entity.SetEntityPosition(garbageCheckpoint, currentGarbagePosition); NAPI.Checkpoint.SetCheckpointDirection(garbageCheckpoint, nextGarbagePosition); NAPI.Data.SetEntityData(driver, EntityData.PLAYER_JOB_CHECKPOINT, checkPoint); NAPI.Data.SetEntityData(player, EntityData.PLAYER_JOB_CHECKPOINT, checkPoint); NAPI.ClientEvent.TriggerClientEvent(driver, "showGarbageCheckPoint", currentGarbagePosition); NAPI.ClientEvent.TriggerClientEvent(player, "showGarbageCheckPoint", currentGarbagePosition); // Añadimos el objeto basura trashBag = NAPI.Object.CreateObject(628215202, currentGarbagePosition, new Vector3(0.0f, 0.0f, 0.0f)); NAPI.Data.SetEntityData(player, EntityData.PLAYER_GARBAGE_BAG, trashBag); } else { Vector3 garbagePosition = new Vector3(-339.0206f, -1560.117f, 25.23038f); NAPI.Entity.SetEntityModel(garbageCheckpoint, 4); NAPI.Entity.SetEntityPosition(garbageCheckpoint, garbagePosition); NAPI.Chat.SendChatMessageToPlayer(driver, Constants.COLOR_INFO + Messages.INF_ROUTE_FINISHED); NAPI.ClientEvent.TriggerClientEvent(driver, "showGarbageCheckPoint", garbagePosition); NAPI.ClientEvent.TriggerClientEvent(player, "deleteGarbageCheckPoint"); } if (garbageTimerList.TryGetValue(player.Value, out Timer garbageTimer) == true) { // Eliminamos el timer garbageTimer.Dispose(); garbageTimerList.Remove(player.Value); } // Mandamos el mensaje de que se ha recogido la bolsa de basura NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + Messages.INF_GARBAGE_COLLECTED); } catch (Exception ex) { NAPI.Util.ConsoleOutput("[EXCEPTION OnGarbageCollectedTimer] " + ex.Message); NAPI.Util.ConsoleOutput("[EXCEPTION OnGarbageCollectedTimer] " + ex.StackTrace); } }
public GTANetworkAPI.Object Create(uint Dimension) { obj = NAPI.Object.CreateObject(NAPI.Util.GetHashKey(Model), Position, Rotation, 255, Dimension); obj.SetData("ID", ID); return(obj); }
public void GarbageCommand(Client player, string action) { if (player.GetData(EntityData.PLAYER_JOB) != Constants.JOB_GARBAGE) { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_not_garbage); } else if (player.GetData(EntityData.PLAYER_ON_DUTY) == 0) { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_not_on_duty); } else { switch (action.ToLower()) { case Commands.ARG_ROUTE: if (player.HasData(EntityData.PLAYER_JOB_ROUTE) == true) { player.SendChatMessage(ErrRes.already_in_route); } else { Random random = new Random(); int garbageRoute = random.Next(Constants.MAX_GARBAGE_ROUTES); player.SetData(EntityData.PLAYER_JOB_ROUTE, garbageRoute); switch (garbageRoute) { case 0: player.SendChatMessage(Constants.COLOR_INFO + GenRes.route_north); break; case 1: player.SendChatMessage(Constants.COLOR_INFO + GenRes.route_south); break; case 2: player.SendChatMessage(Constants.COLOR_INFO + GenRes.route_east); break; case 3: player.SendChatMessage(Constants.COLOR_INFO + GenRes.route_west); break; } } break; case Commands.ARG_PICKUP: if (player.IsInVehicle) { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.garbage_in_vehicle); } else if (player.HasData(EntityData.PLAYER_JOB_COLSHAPE) == false) { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.not_garbage_near); } else { Checkpoint garbageCheckpoint = player.GetData(EntityData.PLAYER_JOB_COLSHAPE); if (player.Position.DistanceTo(garbageCheckpoint.Position) < 3.5f) { if (garbageTimerList.TryGetValue(player.Value, out Timer garbageTimer) == false) { player.PlayAnimation("anim@move_m@trash", "pickup", (int)(Constants.AnimationFlags.Loop | Constants.AnimationFlags.AllowPlayerControl)); player.SetData(EntityData.PLAYER_ANIMATION, true); // Make the timer for garbage collection garbageTimer = new Timer(OnGarbageCollectedTimer, player, 15000, Timeout.Infinite); garbageTimerList.Add(player.Value, garbageTimer); } else { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.already_garbage); } } else { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.not_garbage_near); } } break; case Commands.ARG_CANCEL: if (player.HasData(EntityData.PLAYER_JOB_PARTNER) == true) { Client partner = player.GetData(EntityData.PLAYER_JOB_PARTNER); if (partner != player) { GTANetworkAPI.Object trashBag = null; Checkpoint garbageCheckpoint = null; if (player.VehicleSeat == (int)VehicleSeat.Driver) { // Driver canceled trashBag = player.GetData(EntityData.PLAYER_GARBAGE_BAG); garbageCheckpoint = player.GetData(EntityData.PLAYER_JOB_COLSHAPE); player.SendChatMessage(Constants.COLOR_INFO + InfoRes.route_finished); partner.TriggerEvent("deleteGarbageCheckPoint"); } else { // Passenger canceled trashBag = partner.GetData(EntityData.PLAYER_GARBAGE_BAG); garbageCheckpoint = partner.GetData(EntityData.PLAYER_JOB_COLSHAPE); trashBag = partner.GetData(EntityData.PLAYER_GARBAGE_BAG); player.TriggerEvent("deleteGarbageCheckPoint"); } trashBag.Delete(); // Create finish checkpoint NAPI.Entity.SetEntityModel(garbageCheckpoint, 4); garbageCheckpoint.Position = new Vector3(-339.0206f, -1560.117f, 25.23038f); } else { // Player doesn't have any partner player.SendChatMessage(Constants.COLOR_INFO + InfoRes.route_canceled); } // Remove player from partner search player.ResetData(EntityData.PLAYER_JOB_PARTNER); } else if (player.HasData(EntityData.PLAYER_JOB_ROUTE) == true) { // Cancel the route player.ResetData(EntityData.PLAYER_JOB_PARTNER); player.SendChatMessage(Constants.COLOR_INFO + InfoRes.garbage_route_canceled); } else { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.not_in_route); } break; default: player.SendChatMessage(Constants.COLOR_HELP + Commands.HLP_GARBAGE_JOB_COMMAND); break; } } }
public void OnPlayerEnterVehicle(Client player, Vehicle vehicle, sbyte seat) { if (vehicle.GetData(EntityData.VEHICLE_FACTION) == Constants.JOB_GARBAGE + Constants.MAX_FACTION_VEHICLES) { if (player.VehicleSeat == (int)VehicleSeat.Driver) { if (player.HasData(EntityData.PLAYER_JOB_ROUTE) == false && player.HasData(EntityData.PLAYER_JOB_VEHICLE) == false) { // Stop the vehicle's speedometer player.TriggerEvent("removeSpeedometer"); player.WarpOutOfVehicle(); player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.not_in_route); } else if (player.HasData(EntityData.PLAYER_JOB_VEHICLE) && player.GetData(EntityData.PLAYER_JOB_VEHICLE) != vehicle) { // Stop the vehicle's speedometer player.TriggerEvent("removeSpeedometer"); player.WarpOutOfVehicle(); player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.not_your_job_vehicle); } else { if (garbageTimerList.TryGetValue(player.Value, out Timer garbageTimer) == true) { garbageTimer.Dispose(); garbageTimerList.Remove(player.Value); } // Check whether route starts or he's returning to the truck if (player.HasData(EntityData.PLAYER_JOB_VEHICLE) == false) { player.SetData(EntityData.PLAYER_JOB_PARTNER, player); player.SetData(EntityData.PLAYER_JOB_VEHICLE, vehicle); player.SendChatMessage(Constants.COLOR_INFO + InfoRes.player_waiting_partner); } else { // We continue with the previous route Client partner = player.GetData(EntityData.PLAYER_JOB_PARTNER); int garbageRoute = player.GetData(EntityData.PLAYER_JOB_ROUTE); int checkPoint = player.GetData(EntityData.PLAYER_JOB_CHECKPOINT); Vector3 garbagePosition = GetGarbageCheckPointPosition(garbageRoute, checkPoint); player.TriggerEvent("showGarbageCheckPoint", garbagePosition); partner.TriggerEvent("showGarbageCheckPoint", garbagePosition); } } } else { foreach (Client driver in vehicle.Occupants) { if (driver.HasData(EntityData.PLAYER_JOB_PARTNER) && driver.VehicleSeat == (int)VehicleSeat.Driver) { Client partner = driver.GetData(EntityData.PLAYER_JOB_PARTNER); if (partner == driver) { if (player.GetData(EntityData.PLAYER_ON_DUTY) == 1) { // Link both players as partners player.SetData(EntityData.PLAYER_JOB_PARTNER, driver); driver.SetData(EntityData.PLAYER_JOB_PARTNER, player); // Set the route to the passenger int garbageRoute = driver.GetData(EntityData.PLAYER_JOB_ROUTE); player.SetData(EntityData.PLAYER_JOB_ROUTE, garbageRoute); driver.SetData(EntityData.PLAYER_JOB_CHECKPOINT, 0); player.SetData(EntityData.PLAYER_JOB_CHECKPOINT, 0); // Create the first checkpoint Vector3 currentGarbagePosition = GetGarbageCheckPointPosition(garbageRoute, 0); Vector3 nextGarbagePosition = GetGarbageCheckPointPosition(garbageRoute, 1); Checkpoint garbageCheckpoint = NAPI.Checkpoint.CreateCheckpoint(0, currentGarbagePosition, nextGarbagePosition, 2.5f, new Color(198, 40, 40, 200)); player.SetData(EntityData.PLAYER_JOB_COLSHAPE, garbageCheckpoint); // Add garbage bag GTANetworkAPI.Object trashBag = NAPI.Object.CreateObject(628215202, currentGarbagePosition, new Vector3(0.0f, 0.0f, 0.0f)); player.SetData(EntityData.PLAYER_GARBAGE_BAG, trashBag); driver.TriggerEvent("showGarbageCheckPoint", currentGarbagePosition); player.TriggerEvent("showGarbageCheckPoint", currentGarbagePosition); } else { player.WarpOutOfVehicle(); player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_not_on_duty); } } return; } } // There's no player driving, kick the passenger player.WarpOutOfVehicle(); player.SendChatMessage(Constants.COLOR_INFO + InfoRes.wait_garbage_driver); } } }
public void HandcuffCommand(Client player, string targetString) { if (player.GetData(EntityData.PLAYER_KILLED) != 0) { player.SendChatMessage(Constants.COLOR_ERROR + Messages.ERR_PLAYER_IS_DEAD); } else if (player.GetData(EntityData.PLAYER_ON_DUTY) == 0) { player.SendChatMessage(Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_ON_DUTY); } else if (player.GetData(EntityData.PLAYER_FACTION) != Constants.FACTION_POLICE) { player.SendChatMessage(Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_POLICE_FACTION); } else { Client target = int.TryParse(targetString, out int targetId) ? Globals.GetPlayerById(targetId) : NAPI.Player.GetPlayerFromName(targetString); if (target != null) { if (player.Position.DistanceTo(target.Position) > 1.5f) { player.SendChatMessage(Constants.COLOR_ERROR + Messages.ERR_PLAYER_TOO_FAR); } else if (target == player) { player.SendChatMessage(Constants.COLOR_ERROR + Messages.ERR_PLAYER_HANDCUFFED_HIMSELF); } else if (target.HasData(EntityData.PLAYER_HANDCUFFED) == false) { string playerMessage = string.Format(Messages.INF_CUFFED, target.Name); string targetMessage = string.Format(Messages.INF_CUFFED_BY, player.Name); GTANetworkAPI.Object cuff = NAPI.Object.CreateObject(-1281059971, new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f)); cuff.AttachTo(target, "IK_R_Hand", new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f)); target.PlayAnimation("mp_arresting", "idle", (int)(Constants.AnimationFlags.Loop | Constants.AnimationFlags.OnlyAnimateUpperBody | Constants.AnimationFlags.AllowPlayerControl)); player.SetData(EntityData.PLAYER_ANIMATION, true); target.SetData(EntityData.PLAYER_HANDCUFFED, cuff); player.SendChatMessage(Constants.COLOR_INFO + playerMessage); target.SendChatMessage(Constants.COLOR_INFO + targetMessage); // Disable some player movements player.TriggerEvent("toggleHandcuffed", true); } else { GTANetworkAPI.Object cuff = target.GetData(EntityData.PLAYER_HANDCUFFED); cuff.Detach(); cuff.Delete(); target.StopAnimation(); player.ResetData(EntityData.PLAYER_ANIMATION); target.ResetData(EntityData.PLAYER_HANDCUFFED); string playerMessage = string.Format(Messages.INF_UNCUFFED, target.Name); string targetMessage = string.Format(Messages.INF_UNCUFFED_BY, player.Name); player.SendChatMessage(Constants.COLOR_INFO + playerMessage); target.SendChatMessage(Constants.COLOR_INFO + targetMessage); // Enable previously disabled player movements player.TriggerEvent("toggleHandcuffed", false); } } else { player.SendChatMessage(Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_FOUND); } } }
private void OnPlayerEnterVehicle(Client player, Vehicle vehicle, sbyte seat) { if (NAPI.Data.GetEntityData(vehicle, EntityData.VEHICLE_FACTION) == Constants.JOB_GARBAGE + Constants.MAX_FACTION_VEHICLES) { if (NAPI.Player.GetPlayerVehicleSeat(player) == Constants.VEHICLE_SEAT_DRIVER) { if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_JOB_ROUTE) == false && NAPI.Data.HasEntityData(player, EntityData.PLAYER_JOB_VEHICLE) == false) { NAPI.Player.WarpPlayerOutOfVehicle(player); NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_NOT_IN_ROUTE); } else if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_JOB_VEHICLE) && NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB_VEHICLE) != vehicle) { NAPI.Player.WarpPlayerOutOfVehicle(player); NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_NOT_YOUR_JOB_VEHICLE); } else { if (garbageTimerList.TryGetValue(player.Value, out Timer garbageTimer) == true) { garbageTimer.Dispose(); garbageTimerList.Remove(player.Value); } // Miramos si empieza una ruta o vuelve al camión if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_JOB_VEHICLE) == false) { NAPI.Data.SetEntityData(player, EntityData.PLAYER_JOB_PARTNER, player); NAPI.Data.SetEntityData(player, EntityData.PLAYER_JOB_VEHICLE, vehicle); NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + Messages.INF_PLAYER_WAITING_PARTNER); } else { // Continuamos la ruta Client partner = NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB_PARTNER); int garbageRoute = NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB_ROUTE); int checkPoint = NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB_CHECKPOINT); Vector3 garbagePosition = GetGarbageCheckPointPosition(garbageRoute, checkPoint); NAPI.ClientEvent.TriggerClientEvent(player, "showGarbageCheckPoint", garbagePosition); NAPI.ClientEvent.TriggerClientEvent(partner, "showGarbageCheckPoint", garbagePosition); } } } else { foreach (Client driver in NAPI.Vehicle.GetVehicleOccupants(vehicle)) { if (NAPI.Data.HasEntityData(driver, EntityData.PLAYER_JOB_PARTNER) && NAPI.Player.GetPlayerVehicleSeat(driver) == Constants.VEHICLE_SEAT_DRIVER) { Client partner = NAPI.Data.GetEntityData(driver, EntityData.PLAYER_JOB_PARTNER); if (partner == driver) { if (NAPI.Data.GetEntityData(player, EntityData.PLAYER_ON_DUTY) == 1) { // Unimos los dos jugadores como compañeros NAPI.Data.SetEntityData(player, EntityData.PLAYER_JOB_PARTNER, driver); NAPI.Data.SetEntityData(driver, EntityData.PLAYER_JOB_PARTNER, player); // Asignamos la ruta al copiloto int garbageRoute = NAPI.Data.GetEntityData(driver, EntityData.PLAYER_JOB_ROUTE); NAPI.Data.SetEntityData(player, EntityData.PLAYER_JOB_ROUTE, garbageRoute); NAPI.Data.SetEntityData(driver, EntityData.PLAYER_JOB_CHECKPOINT, 0); NAPI.Data.SetEntityData(player, EntityData.PLAYER_JOB_CHECKPOINT, 0); // Creamos el primer punto Vector3 currentGarbagePosition = GetGarbageCheckPointPosition(garbageRoute, 0); Vector3 nextGarbagePosition = GetGarbageCheckPointPosition(garbageRoute, 1); Checkpoint garbageCheckpoint = NAPI.Checkpoint.CreateCheckpoint(0, currentGarbagePosition, nextGarbagePosition, 2.5f, new Color(198, 40, 40, 200)); NAPI.Data.SetEntityData(player, EntityData.PLAYER_JOB_COLSHAPE, garbageCheckpoint); NAPI.ClientEvent.TriggerClientEvent(driver, "showGarbageCheckPoint", currentGarbagePosition); NAPI.ClientEvent.TriggerClientEvent(player, "showGarbageCheckPoint", currentGarbagePosition); // Añadimos el objeto basura GTANetworkAPI.Object trashBag = NAPI.Object.CreateObject(628215202, currentGarbagePosition, new Vector3(0.0f, 0.0f, 0.0f)); NAPI.Data.SetEntityData(player, EntityData.PLAYER_GARBAGE_BAG, trashBag); } else { NAPI.Player.WarpPlayerOutOfVehicle(player); NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_ON_DUTY); } } return; } } // Si no hay nadie conduciendo, echamos al jugador NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + Messages.INF_WAIT_GARBAGE_DRIVER); NAPI.Player.WarpPlayerOutOfVehicle(player); } } }
public void BasuraCommand(Client player, String action) { if (NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB) != Constants.JOB_GARBAGE) { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_GARBAGE); } else if (NAPI.Data.GetEntityData(player, EntityData.PLAYER_ON_DUTY) == 0) { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_ON_DUTY); } else { switch (action.ToLower()) { case "ruta": if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_JOB_ROUTE) == true) { NAPI.Chat.SendChatMessageToPlayer(player, Messages.ERR_ALREADY_IN_ROUTE); } else { Random random = new Random(); int garbageRoute = random.Next(Constants.MAX_GARBAGE_ROUTES); NAPI.Data.SetEntityData(player, EntityData.PLAYER_JOB_ROUTE, garbageRoute); switch (garbageRoute) { case 0: NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + "Se te ha asignado la ruta norte."); break; case 1: NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + "Se te ha asignado la ruta sur."); break; case 2: NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + "Se te ha asignado la ruta este."); break; case 3: NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + "Se te ha asignado la ruta oeste."); break; } } break; case "recoger": if (NAPI.Player.GetPlayerVehicleSeat(player) == Constants.VEHICLE_SEAT_ANY) { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_GARBAGE_IN_VEHICLE); } else if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_JOB_COLSHAPE) == false) { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_NOT_GARBAGE_NEAR); } else { Checkpoint garbageCheckpoint = NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB_COLSHAPE); if (player.Position.DistanceTo(garbageCheckpoint.Position) < 3.5f) { if (garbageTimerList.TryGetValue(player.Value, out Timer garbageTimer) == false) { NAPI.Player.PlayPlayerAnimation(player, (int)(Constants.AnimationFlags.Loop | Constants.AnimationFlags.AllowPlayerControl), "anim@move_m@trash", "pickup"); NAPI.Data.SetEntityData(player, EntityData.PLAYER_ANIMATION, true); // Creamos el timer para recoger la basura garbageTimer = new Timer(OnGarbageCollectedTimer, player, 15000, Timeout.Infinite); garbageTimerList.Add(player.Value, garbageTimer); } else { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_ALREADY_GARBAGE); } } else { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_NOT_GARBAGE_NEAR); } } break; case "cancelar": if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_JOB_PARTNER) == true) { Client partner = NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB_PARTNER); if (partner != player) { // Tiene un compañero asignado GTANetworkAPI.Object trashBag = null; Checkpoint garbageCheckpoint = null; if (NAPI.Player.GetPlayerVehicleSeat(player) == Constants.VEHICLE_SEAT_DRIVER) { // Ha cancelado el conductor trashBag = NAPI.Data.GetEntityData(player, EntityData.PLAYER_GARBAGE_BAG); garbageCheckpoint = NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB_COLSHAPE); } else { // Ha cancelado el acompañante trashBag = NAPI.Data.GetEntityData(partner, EntityData.PLAYER_GARBAGE_BAG); garbageCheckpoint = NAPI.Data.GetEntityData(partner, EntityData.PLAYER_JOB_COLSHAPE); } // Borramos la bolsa de basura NAPI.Entity.DeleteEntity(trashBag); // Destruímos el check anterior NAPI.Entity.SetEntityModel(garbageCheckpoint, 4); NAPI.Entity.SetEntityPosition(garbageCheckpoint, new Vector3(-339.0206f, -1560.117f, 25.23038f)); if (NAPI.Player.GetPlayerVehicleSeat(player) == Constants.VEHICLE_SEAT_DRIVER) { // Ha cancelado el conductor NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + Messages.INF_ROUTE_FINISHED); NAPI.ClientEvent.TriggerClientEvent(partner, "deleteGarbageCheckPoint"); } else { // Ha cancelado el acompañante trashBag = NAPI.Data.GetEntityData(partner, EntityData.PLAYER_GARBAGE_BAG); NAPI.ClientEvent.TriggerClientEvent(player, "deleteGarbageCheckPoint"); } } else { // No tiene compañero, enviamos el mensaje NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + Messages.INF_ROUTE_CANCELED); } // Eliminamos la búsqueda de compañero NAPI.Data.ResetEntityData(player, EntityData.PLAYER_JOB_PARTNER); } else if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_JOB_ROUTE) == true) { // Cancelamos la ruta NAPI.Data.ResetEntityData(player, EntityData.PLAYER_JOB_PARTNER); NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + Messages.INF_GARBAGE_ROUTE_CANCELED); } else { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_NOT_IN_ROUTE); } break; default: NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_HELP + Messages.GEN_GARBAGE_JOB_COMMAND); break; } } }
public void GarbageCommand(Client player, string action) { player.SendChatMessage(Constants.COLOR_ERROR + "Trabajo deshabilitado temporalmente."); return; if (player.GetData(EntityData.PLAYER_JOB) != Constants.JOB_GARBAGE) { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_not_garbage); } else if (player.GetData(EntityData.PLAYER_ON_DUTY) == 0) { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_not_on_duty); } else { switch (action.ToLower()) { case Commands.ARG_ROUTE: if (player.GetData(EntityData.PLAYER_JOB_ROUTE) != null) { player.SendChatMessage(ErrRes.already_in_route); } else { Random random = new Random(); int garbageRoute = random.Next(Constants.MAX_GARBAGE_ROUTES); player.SetData(EntityData.PLAYER_JOB_ROUTE, garbageRoute); switch (garbageRoute) { case 0: player.SendChatMessage(Constants.COLOR_INFO + GenRes.route_north); break; case 1: player.SendChatMessage(Constants.COLOR_INFO + GenRes.route_south); break; case 2: player.SendChatMessage(Constants.COLOR_INFO + GenRes.route_east); break; case 3: player.SendChatMessage(Constants.COLOR_INFO + GenRes.route_west); break; } } break; case Commands.ARG_PICKUP: if (player.IsInVehicle) { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.garbage_in_vehicle); } else if (player.GetData(EntityData.PLAYER_GARBAGE_BAG) == null) { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.not_garbage_near); } else { // Get the closest garbage bag GTANetworkAPI.Object trashBag = player.GetData(EntityData.PLAYER_GARBAGE_BAG); if (player.Position.DistanceTo(trashBag.Position) < 3.5f) { if (garbageTimerList.TryGetValue(player.Value, out Timer garbageTimer) == false) { player.PlayAnimation("anim@move_m@trash", "pickup", (int)(Constants.AnimationFlags.Loop | Constants.AnimationFlags.AllowPlayerControl)); player.SetData(EntityData.PLAYER_ANIMATION, true); // Make the timer for garbage collection garbageTimer = new Timer(OnGarbageCollectedTimer, player, 15000, Timeout.Infinite); garbageTimerList.Add(player.Value, garbageTimer); } else { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.already_garbage); } } else { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.not_garbage_near); } } break; case Commands.ARG_CANCEL: if (player.GetData(EntityData.PLAYER_JOB_PARTNER) != null) { Client partner = player.GetData(EntityData.PLAYER_JOB_PARTNER); if (partner != player) { GTANetworkAPI.Object trashBag = null; if (player.VehicleSeat == (int)VehicleSeat.Driver) { // Driver canceled trashBag = player.GetData(EntityData.PLAYER_GARBAGE_BAG); player.SendChatMessage(Constants.COLOR_INFO + InfoRes.route_finished); partner.TriggerEvent("deleteGarbageCheckPoint"); // Create finish checkpoint player.TriggerEvent("showGarbageCheckPoint", new Vector3(49.44239f, 6558.004f, 32.18963f), new Vector3(), CheckpointType.CylinderCheckerboard); } else { // Passenger canceled trashBag = partner.GetData(EntityData.PLAYER_GARBAGE_BAG); player.TriggerEvent("deleteGarbageCheckPoint"); // Create finish checkpoint partner.TriggerEvent("showGarbageCheckPoint", new Vector3(49.44239f, 6558.004f, 32.18963f), new Vector3(), CheckpointType.CylinderCheckerboard); } // Delete the garbage bag trashBag.Delete(); } else { // Player doesn't have any partner player.SendChatMessage(Constants.COLOR_INFO + InfoRes.route_canceled); } // Remove player from partner search player.ResetData(EntityData.PLAYER_JOB_PARTNER); } else if (player.GetData(EntityData.PLAYER_JOB_ROUTE) != null) { // Cancel the route player.ResetData(EntityData.PLAYER_JOB_ROUTE); player.ResetData(EntityData.PLAYER_JOB_PARTNER); player.SendChatMessage(Constants.COLOR_INFO + InfoRes.garbage_route_canceled); } else { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.not_in_route); } break; default: player.SendChatMessage(Constants.COLOR_HELP + Commands.HLP_GARBAGE_JOB_COMMAND); break; } } }
public void GarbageCommand(Client player, String action) { if (NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB) != Constants.JOB_GARBAGE) { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_GARBAGE); } else if (NAPI.Data.GetEntityData(player, EntityData.PLAYER_ON_DUTY) == 0) { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_ON_DUTY); } else { switch (action.ToLower()) { case Messages.ARG_ROUTE: if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_JOB_ROUTE) == true) { NAPI.Chat.SendChatMessageToPlayer(player, Messages.ERR_ALREADY_IN_ROUTE); } else { Random random = new Random(); int garbageRoute = random.Next(Constants.MAX_GARBAGE_ROUTES); NAPI.Data.SetEntityData(player, EntityData.PLAYER_JOB_ROUTE, garbageRoute); switch (garbageRoute) { case 0: NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + Messages.GEN_ROUTE_NORTH); break; case 1: NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + Messages.GEN_ROUTE_SOUTH); break; case 2: NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + Messages.GEN_ROUTE_EAST); break; case 3: NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + Messages.GEN_ROUTE_WEST); break; } } break; case Messages.ARG_PICKUP: if (NAPI.Player.IsPlayerInAnyVehicle(player) == true) { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_GARBAGE_IN_VEHICLE); } else if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_JOB_COLSHAPE) == false) { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_NOT_GARBAGE_NEAR); } else { Checkpoint garbageCheckpoint = NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB_COLSHAPE); if (player.Position.DistanceTo(garbageCheckpoint.Position) < 3.5f) { if (garbageTimerList.TryGetValue(player.Value, out Timer garbageTimer) == false) { NAPI.Player.PlayPlayerAnimation(player, (int)(Constants.AnimationFlags.Loop | Constants.AnimationFlags.AllowPlayerControl), "anim@move_m@trash", "pickup"); NAPI.Data.SetEntityData(player, EntityData.PLAYER_ANIMATION, true); // Make the timer for garbage collection garbageTimer = new Timer(OnGarbageCollectedTimer, player, 15000, Timeout.Infinite); garbageTimerList.Add(player.Value, garbageTimer); } else { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_ALREADY_GARBAGE); } } else { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_NOT_GARBAGE_NEAR); } } break; case Messages.ARG_CANCEL: if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_JOB_PARTNER) == true) { Client partner = NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB_PARTNER); if (partner != player) { GTANetworkAPI.Object trashBag = null; Checkpoint garbageCheckpoint = null; if (NAPI.Player.GetPlayerVehicleSeat(player) == (int)VehicleSeat.Driver) { // Driver canceled trashBag = NAPI.Data.GetEntityData(player, EntityData.PLAYER_GARBAGE_BAG); garbageCheckpoint = NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB_COLSHAPE); NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + Messages.INF_ROUTE_FINISHED); NAPI.ClientEvent.TriggerClientEvent(partner, "deleteGarbageCheckPoint"); } else { // Passenger canceled trashBag = NAPI.Data.GetEntityData(partner, EntityData.PLAYER_GARBAGE_BAG); garbageCheckpoint = NAPI.Data.GetEntityData(partner, EntityData.PLAYER_JOB_COLSHAPE); trashBag = NAPI.Data.GetEntityData(partner, EntityData.PLAYER_GARBAGE_BAG); NAPI.ClientEvent.TriggerClientEvent(player, "deleteGarbageCheckPoint"); } NAPI.Entity.DeleteEntity(trashBag); // Create finish checkpoint NAPI.Entity.SetEntityModel(garbageCheckpoint, 4); NAPI.Entity.SetEntityPosition(garbageCheckpoint, new Vector3(-339.0206f, -1560.117f, 25.23038f)); } else { // Player doesn't have any partner NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + Messages.INF_ROUTE_CANCELED); } // Remove player from partner search NAPI.Data.ResetEntityData(player, EntityData.PLAYER_JOB_PARTNER); } else if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_JOB_ROUTE) == true) { // Cancel the route NAPI.Data.ResetEntityData(player, EntityData.PLAYER_JOB_PARTNER); NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + Messages.INF_GARBAGE_ROUTE_CANCELED); } else { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_NOT_IN_ROUTE); } break; default: NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_HELP + Messages.GEN_GARBAGE_JOB_COMMAND); break; } } }
public void OnPlayerEnterVehicle(Client player, Vehicle vehicle, sbyte seat) { if (NAPI.Data.GetEntityData(vehicle, EntityData.VEHICLE_FACTION) == Constants.JOB_GARBAGE + Constants.MAX_FACTION_VEHICLES) { if (NAPI.Player.GetPlayerVehicleSeat(player) == (int)VehicleSeat.Driver) { if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_JOB_ROUTE) == false && NAPI.Data.HasEntityData(player, EntityData.PLAYER_JOB_VEHICLE) == false) { NAPI.Player.WarpPlayerOutOfVehicle(player); NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_NOT_IN_ROUTE); } else if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_JOB_VEHICLE) && NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB_VEHICLE) != vehicle) { NAPI.Player.WarpPlayerOutOfVehicle(player); NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_NOT_YOUR_JOB_VEHICLE); } else { if (garbageTimerList.TryGetValue(player.Value, out Timer garbageTimer) == true) { garbageTimer.Dispose(); garbageTimerList.Remove(player.Value); } // Check whether route starts or he's returning to the truck if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_JOB_VEHICLE) == false) { NAPI.Data.SetEntityData(player, EntityData.PLAYER_JOB_PARTNER, player); NAPI.Data.SetEntityData(player, EntityData.PLAYER_JOB_VEHICLE, vehicle); NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + Messages.INF_PLAYER_WAITING_PARTNER); } else { // We continue with the previous route Client partner = NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB_PARTNER); int garbageRoute = NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB_ROUTE); int checkPoint = NAPI.Data.GetEntityData(player, EntityData.PLAYER_JOB_CHECKPOINT); Vector3 garbagePosition = GetGarbageCheckPointPosition(garbageRoute, checkPoint); NAPI.ClientEvent.TriggerClientEvent(player, "showGarbageCheckPoint", garbagePosition); NAPI.ClientEvent.TriggerClientEvent(partner, "showGarbageCheckPoint", garbagePosition); } } } else { foreach (Client driver in NAPI.Vehicle.GetVehicleOccupants(vehicle)) { if (NAPI.Data.HasEntityData(driver, EntityData.PLAYER_JOB_PARTNER) && NAPI.Player.GetPlayerVehicleSeat(driver) == (int)VehicleSeat.Driver) { Client partner = NAPI.Data.GetEntityData(driver, EntityData.PLAYER_JOB_PARTNER); if (partner == driver) { if (NAPI.Data.GetEntityData(player, EntityData.PLAYER_ON_DUTY) == 1) { // Link both players as partners NAPI.Data.SetEntityData(player, EntityData.PLAYER_JOB_PARTNER, driver); NAPI.Data.SetEntityData(driver, EntityData.PLAYER_JOB_PARTNER, player); // Set the route to the passenger int garbageRoute = NAPI.Data.GetEntityData(driver, EntityData.PLAYER_JOB_ROUTE); NAPI.Data.SetEntityData(player, EntityData.PLAYER_JOB_ROUTE, garbageRoute); NAPI.Data.SetEntityData(driver, EntityData.PLAYER_JOB_CHECKPOINT, 0); NAPI.Data.SetEntityData(player, EntityData.PLAYER_JOB_CHECKPOINT, 0); // Create the first checkpoint Vector3 currentGarbagePosition = GetGarbageCheckPointPosition(garbageRoute, 0); Vector3 nextGarbagePosition = GetGarbageCheckPointPosition(garbageRoute, 1); Checkpoint garbageCheckpoint = NAPI.Checkpoint.CreateCheckpoint(0, currentGarbagePosition, nextGarbagePosition, 2.5f, new Color(198, 40, 40, 200)); NAPI.Data.SetEntityData(player, EntityData.PLAYER_JOB_COLSHAPE, garbageCheckpoint); // Add garbage bag GTANetworkAPI.Object trashBag = NAPI.Object.CreateObject(628215202, currentGarbagePosition, new Vector3(0.0f, 0.0f, 0.0f)); NAPI.Data.SetEntityData(player, EntityData.PLAYER_GARBAGE_BAG, trashBag); NAPI.ClientEvent.TriggerClientEvent(driver, "showGarbageCheckPoint", currentGarbagePosition); NAPI.ClientEvent.TriggerClientEvent(player, "showGarbageCheckPoint", currentGarbagePosition); } else { NAPI.Player.WarpPlayerOutOfVehicle(player); NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_ON_DUTY); } } return; } } // There's no player driving, kick the passenger NAPI.Player.WarpPlayerOutOfVehicle(player); NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + Messages.INF_WAIT_GARBAGE_DRIVER); } } }