public void OnClientEvent(Client client, string eventName, params object[] arguments) { switch (eventName) { case "KeyboardKey_E_Pressed": if (!client.hasData("player")) { return; } Player player = client.getData("player"); if (player.Character.Faction == FactionType.Police) { CheckDoors(client, player); // Check for Doors if (client.position.DistanceTo(new Vector3(452.3879, -980.1114, 30.6896)) <= 1.3f) { PoliceService.OpenWeaponMenu(client); } } break; case "Police_WeaponMenuItemSelected": PoliceService.ProcessWeaponMenu(client, (string)arguments[0]); break; } }
public void OnClientEvent(Client client, string eventName, params object[] arguments) { List <SpawnPosition> spawnList; switch (eventName) { case "SpawnMove": if (!client.hasData("spawnlist")) { return; } spawnList = client.getData("spawnlist"); API.moveEntityPosition(client, spawnList[(int)arguments[0]].Position, 1000); API.triggerClientEvent(client, "SpawnMovePed"); client.rotation = new Vector3(0, 0, 0); break; case "SpawnSelected": if (!client.hasData("spawnlist")) { return; } spawnList = client.getData("spawnlist"); API.triggerClientEvent(client, "SpawnMenu_Close"); client.rotation = spawnList[(int)arguments[0]].Rotation; spawnList.Clear(); client.resetData("spawnlist"); CharacterService.ShowPlayerHUD(client, true); client.dimension = 0; if (!client.hasData("player")) { return; } Player player = client.getData("player"); if (player.Character.OnDuty) { if (player.Character.Faction != FactionType.Citizen) { switch (player.Character.Faction) { case FactionType.Police: PoliceService.SetOnDuty(client, true); break; case FactionType.EMS: EMSService.SetOnDuty(client, true); break; } } else { player.Character.OnDuty = false; } } CharacterService.GivePlayerWeapons(client); break; } }
public static void ProcessInteractionMenu(Client client, string itemvalue) { if (!client.hasData("player")) { return; } Player player = client.getData("player"); if (player.Character.Faction != FactionType.Citizen) { switch (player.Character.Faction) { case FactionType.Police: PoliceService.ProcessInteractionMenu(client, itemvalue); break; case FactionType.EMS: EMSService.ProcessInteractionMenu(client, itemvalue); break; } } API.shared.triggerClientEvent(client, "PlayerMenu_Close"); switch (itemvalue) { #region Seatbelt Menu Item case "toggleseatbelt": if (!client.isInVehicle) { return; } if (client.seatbelt) { client.seatbelt = false; API.shared.sendNotificationToPlayer(client, "Put ~r~off ~w~Seatbelt"); } else { client.seatbelt = true; API.shared.sendNotificationToPlayer(client, "Put ~g~on ~w~Seatbelt"); } break; #endregion Seatbelt Menu Item case "togglehandsup": PoliceService.TogglePlayerHandsup(player); break; case "openinventory": API.shared.triggerClientEvent(client, "Inventory_Open", JsonConvert.SerializeObject(CharacterService.GetInventoryMenuItems(client))); break; } }
public static List <MenuItem> BuildInteractionMenu(Player player) { List <MenuItem> menuItemList = new List <MenuItem>(); #region Seatbelt Menu Item if (player.Character.Player.isInVehicle) { if (player.Character.Player.seatbelt) { menuItemList.Add(new MenuItem { Title = "Put off seatbeld", Value1 = "toggleseatbelt" }); } else { menuItemList.Add(new MenuItem { Title = "Put seatbelt on", Value1 = "toggleseatbelt" }); } } #endregion Seatbelt Menu Item #region Faction Menu Item if (player.Character.OnDuty && player.Character.Faction != FactionType.Citizen) { switch (player.Character.Faction) { case FactionType.Police: menuItemList.AddRange(PoliceService.BuildInteractionMenu(player)); // Add Police Menu Items break; case FactionType.EMS: menuItemList.AddRange(EMSService.BuildInteractionMenu(player)); // Add EMS Menu Items break; } } #endregion Faction Menu Item #region Inventory Menu Item menuItemList.Add(new MenuItem { Title = "Inventory", Value1 = "openinventory" }); #endregion Inventory Menu Item #region Handsup if (!player.Character.Player.isInVehicle) { if (player.Character.HasHandsup) { menuItemList.Add(new MenuItem { Title = "Hands down", Value1 = "togglehandsup" }); } else { menuItemList.Add(new MenuItem { Title = "Put hands up", Value1 = "togglehandsup" }); } } #endregion Handsup return(menuItemList); }
private void CheckDoors(Client client, Player player) { if (client.position.DistanceTo(new Vector3(460.1322, -990.9448, 30.6896)) <= 2) { if (client.hasSyncedData("onduty")) { PoliceService.SetOnDuty(client, false); } else { PoliceService.SetOnDuty(client, true); } return; } if (client.position.DistanceTo(new Vector3(434.6926, -981.8649, 30.71322)) <= 1) // Mission Row Main Doors { DoorService.ToggleDoorState(19); if (DoorService.ToggleDoorState(18)) { API.sendNotificationToPlayer(client, "~r~Locked ~w~Door"); } else { API.sendNotificationToPlayer(client, "~g~Unlocked ~w~Door"); } return; } if (client.position.DistanceTo(new Vector3(464.3711, -983.8344, 43.69287)) <= 1) // Mission Row Top Door { if (DoorService.ToggleDoorState(27)) { API.sendNotificationToPlayer(client, "~r~Locked ~w~Door"); } else { API.sendNotificationToPlayer(client, "~g~Unlocked ~w~Door"); } return; } if (client.position.DistanceTo(new Vector3(463.7195, -992.5253, 24.91487)) <= 1) // Mission Row Main Cell Door { if (DoorService.ToggleDoorState(26)) { API.sendNotificationToPlayer(client, "~r~Locked ~w~Door"); } else { API.sendNotificationToPlayer(client, "~g~Unlocked ~w~Door"); } return; } if (client.position.DistanceTo(new Vector3(464.1983, -1003.415, 24.91487)) <= 1) // Mission Row Back Cell Door (Not Working) { if (DoorService.ToggleDoorState(20)) { API.sendNotificationToPlayer(client, "~r~Locked ~w~Door"); } else { API.sendNotificationToPlayer(client, "~g~Unlocked ~w~Door"); } return; } if (client.position.DistanceTo(new Vector3(462.0896, -993.7011, 24.91486)) <= 1) // Mission Row Cell Door Right { if (!player.Character.OnDuty) { return; } if (DoorService.ToggleDoorState(23)) { API.sendNotificationToPlayer(client, "~r~Locked ~w~Door"); } else { API.sendNotificationToPlayer(client, "~g~Unlocked ~w~Door"); } return; } if (client.position.DistanceTo(new Vector3(462.0993, -998.6472, 24.91486)) <= 1) // Mission Row Cell Door Middle { if (!player.Character.OnDuty) { return; } if (DoorService.ToggleDoorState(24)) { API.sendNotificationToPlayer(client, "~r~Locked ~w~Door"); } else { API.sendNotificationToPlayer(client, "~g~Unlocked ~w~Door"); } return; } if (client.position.DistanceTo(new Vector3(462.2214, -1002.128, 24.91486)) <= 1) // Mission Row Cell Door Left { if (!player.Character.OnDuty) { return; } if (DoorService.ToggleDoorState(25)) { API.sendNotificationToPlayer(client, "~r~Locked ~w~Door"); } else { API.sendNotificationToPlayer(client, "~g~Unlocked ~w~Door"); } return; } if (client.position.DistanceTo(new Vector3(468.6248, -1014.067, 26.38638)) <= 1) // Mission Row Back Doors { if (DoorService.ToggleDoorState(20)) { API.sendNotificationToPlayer(client, "~r~Locked ~w~Door"); } else { API.sendNotificationToPlayer(client, "~g~Unlocked ~w~Door"); } DoorService.ToggleDoorState(21); return; } return; }