public static void dropSign(string selectedSign, bool swapHeading, Vector3 Location, float HeadingModifier) { GameFiber.StartNew(delegate { try { //string selectedCone = barriersToChooseFrom[EntryPoint.rnd.Next(barriersToChooseFrom.Length)]; //string selectedCone = "PROP_MP_ARROW_BARRIER_01"; if (TrafficPolicerHandler.IsLSPDFRPlusRunning) { API.LSPDFRPlusFunctions.AddCountToStatistic(Main.PluginName, "Road signs placed"); } Rage.Object trafficCone = new Rage.Object(selectedSign, Location); trafficCone.IsPersistent = true; trafficCone.IsInvincible = true; trafficCone.Rotation = RotationToPlaceAt; if (swapHeading) { trafficCone.Heading = Game.LocalPlayer.Character.Heading + 180f; } trafficCone.Heading += HeadingModifier; trafficCone.IsPositionFrozen = false; if (TrafficSignPreview.Exists()) { TrafficSignPreview.SetPositionZ(TrafficSignPreview.Position.Z + 3f); } int waitCount = 0; while (trafficCone.HeightAboveGround > 0.01f) { trafficCone.SetPositionZ(trafficCone.Position.Z - (trafficCone.HeightAboveGround * 0.75f)); waitCount++; if (waitCount >= 1000) { break; } } if (trafficCone.Exists()) { trafficCone.IsPositionFrozen = true; roadSignsDropped.Add(trafficCone); UInt32 handle = World.AddSpeedZone(trafficCone.Position, 5f, 5f); speedZones.Add(handle); Rage.Object invWall = new Rage.Object("p_ice_box_01_s", trafficCone.Position); invWall.IsPersistent = true; Ped invPed = new Ped(trafficCone.Position); invPed.MakeMissionPed(); invPed.IsVisible = false; invPed.IsPositionFrozen = true; invWall.Heading = Game.LocalPlayer.Character.Heading; invWall.IsVisible = false; RoadSignsWithInvisWallsAndPeds.Add(trafficCone, invWall, invPed); } } catch (Exception e) { Game.LogTrivial(e.ToString()); } }); }
public static void RoadSignsMainLogic() { GameFiber.StartNew(delegate { createRoadSignsMenu(); try { while (true) { GameFiber.Yield(); if (PlaceSignMenu.Visible && EnablePreviewItem.Checked) { if (TrafficSignPreview.Exists()) { if (TrafficSignPreview.DistanceTo2D(DetermineSignSpawn(SpawnDirectionListItem.Collection[SpawnDirectionListItem.Index].Value.ToString(), float.Parse(SpawnMultiplierListItem.Collection[SpawnMultiplierListItem.Index].Value.ToString()))) > 0.4f) { TrafficSignPreview.Position = DetermineSignSpawn(SpawnDirectionListItem.Collection[SpawnDirectionListItem.Index].Value.ToString(), float.Parse(SpawnMultiplierListItem.Collection[SpawnMultiplierListItem.Index].Value.ToString())); TrafficSignPreview.SetPositionZ(TrafficSignPreview.Position.Z + 3f); } TrafficSignPreview.Rotation = RotationToPlaceAt; if (barriersList.Collection[barriersList.Index].Value.ToString() == "Stripes Left") { //TrafficSignPreview.Heading = Game.LocalPlayer.Character.Heading + 180f; TrafficSignPreview.Heading += 180f; } TrafficSignPreview.Heading += float.Parse(HeadingItem.Collection[HeadingItem.Index].Value.ToString()); int waitCount = 0; while (TrafficSignPreview.HeightAboveGround > 0.01f) { GameFiber.Yield(); TrafficSignPreview.SetPositionZ(TrafficSignPreview.Position.Z - (TrafficSignPreview.HeightAboveGround * 0.75f)); //Game.LogTrivial("Heighaboveground: " + TrafficSignPreview.HeightAboveGround); waitCount++; if (waitCount >= 1000) { break; } } TrafficSignPreview.IsPositionFrozen = true; TrafficSignPreview.Opacity = 0.7f; TrafficSignPreview.NeedsCollision = false; NativeFunction.Natives.SET_ENTITY_COLLISION(TrafficSignPreview, false, false); } if (SignTypeToPlace == SignTypes.Barrier && !TrafficSignPreview.Exists()) { if (TrafficSignPreview.Exists()) { TrafficSignPreview.Delete(); } TrafficSignPreview = new Rage.Object(barriersToChooseFrom[barriersList.Index], DetermineSignSpawn(SpawnDirectionListItem.Collection[SpawnDirectionListItem.Index].Value.ToString(), float.Parse(SpawnMultiplierListItem.Collection[SpawnMultiplierListItem.Index].Value.ToString()))); TrafficSignPreview.Rotation = RotationToPlaceAt; TrafficSignPreview.NeedsCollision = false; } else if (SignTypeToPlace == SignTypes.Cone && !TrafficSignPreview.Exists()) { if (TrafficSignPreview.Exists()) { TrafficSignPreview.Delete(); } TrafficSignPreview = new Rage.Object(conesToChooseFrom[conesList.Index], DetermineSignSpawn(SpawnDirectionListItem.Collection[SpawnDirectionListItem.Index].Value.ToString(), float.Parse(SpawnMultiplierListItem.Collection[SpawnMultiplierListItem.Index].Value.ToString()))); TrafficSignPreview.Rotation = RotationToPlaceAt; TrafficSignPreview.NeedsCollision = false; } } else { if (TrafficSignPreview.Exists()) { TrafficSignPreview.Delete(); } } if (!PlaceSignMenu.Visible) { if (!Game.LocalPlayer.Character.IsInAnyVehicle(false)) { if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyCombinationDownComputerCheck(placeSignShortcutKey, placeSignShortcutModifierKey)) { RotationToPlaceAt = Game.LocalPlayer.Character.Rotation; dropSign(SignTypeToPlace == SignTypes.Barrier ? barriersToChooseFrom[barriersList.Index] : conesToChooseFrom[conesList.Index], false, Game.LocalPlayer.Character.GetOffsetPositionFront(2), 0); Game.LogTrivial("Shortcut Sign dropped"); Rage.Native.NativeFunction.Natives.SET_PED_STEALTH_MOVEMENT(Game.LocalPlayer.Character, 0, 0); } else if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyCombinationDownComputerCheck(removeAllSignsKey, removeAllSignsModifierKey)) { removeAllSigns(); } } } } } catch { removeAllSigns(); if (TrafficSignPreview.Exists()) { TrafficSignPreview.Delete(); } } }); }