public static void OnEntityStreamOutEvent(Entity entity) { if (entity.Type == Type.Player) { // Get the player's identifier int playerId = entity.RemoteId; if (playerAttachments.ContainsKey(playerId)) { // Get the attached object var attachment = playerAttachments[playerId].attach; // Destroy the attachment attachment.Destroy(); playerAttachments.Remove(playerId); } } }
private void PlayerConnectionStateChanged(Entity entity, object arg) { if (entity == Player.LocalPlayer) { var serverTime = Player.LocalPlayer.GetSharedData("SERVER_TIME").ToString().Split(":"); var hours = int.Parse(serverTime[0]); var minutes = int.Parse(serverTime[1]); var seconds = int.Parse(serverTime[2]); // Set the hour from the server Clock.SetClockTime(hours, minutes, seconds); // Get the current timestamp lastTimeChecked = DateTime.UtcNow; // Show the login window Login.AccountLoginFormEvent(null); } }
public static void OnEntityStreamInEvent(Entity entity) { if (entity.Type == Type.Player) { // Get the identifier of the player int playerId = entity.RemoteId; var attachedPlayer = Entities.Players.GetAtRemote((ushort)playerId); // Get the attachment on the right hand var attachmentJson = attachedPlayer.GetSharedData(Constants.ITEM_ENTITY_RIGHT_HAND); if (attachmentJson == null) { attachmentJson = attachedPlayer.GetSharedData(Constants.ITEM_ENTITY_WEAPON_CRATE); } if (attachmentJson != null) { var attachment = JsonConvert.DeserializeObject <AttachmentModel>(attachmentJson.ToString()); // If the attached item is a weapon, we don't stream it if (Weapon.IsWeaponValid(Convert.ToUInt32(attachment.hash))) { return; } var boneIndex = attachedPlayer.GetBoneIndexByName(attachment.bodyPart); attachment.attach = new MapObject(Convert.ToUInt32(attachment.hash), attachedPlayer.Position, new Vector3(), 255, attachedPlayer.Dimension); RAGE.Game.Entity.AttachEntityToEntity(attachment.attach.Handle, attachedPlayer.Handle, boneIndex, attachment.offset.X, attachment.offset.Y, attachment.offset.Z, attachment.rotation.X, attachment.rotation.Y, attachment.rotation.Z, false, false, false, true, 0, true); // Add the attachment to the dictionary playerAttachments.Add(playerId, attachment); } } }
private void EntityStreamInEvent(Entity entity) { if (entity.Type == Type.Vehicle) { // Get the vehicle from the entity var vehicle = (Vehicle)entity; // Get the state for each one of the doors var doorsJson = entity.GetSharedData(Constants.VEHICLE_DOORS_STATE).ToString(); var doorStateList = JsonConvert.DeserializeObject <List <bool> >(doorsJson); for (var i = 0; i < doorStateList.Count; i++) { if (doorStateList[i]) { vehicle.SetDoorOpen(i, false, false); } else { vehicle.SetDoorShut(i, true); } } } }