public static void ShowBigMessage(string text, string description, HudColor color, HudColor background, int duration = 3000) { BigMessage message = new BigMessage { text = text, description = description, color = color, background = background, duration = duration }; BigMessages.Add(message); }
public override void OnClientConnect(NetworkConnection conn) { Debug.Log("OnClient Connect"); base.OnClientConnect(conn); var bigMsg = new BigMessage(); bigMsg.data = new byte[MsgSize]; var writer = new NetworkWriter(); writer.StartMessage(MsgIdBig); bigMsg.Serialize(writer); writer.FinishMessage(); var data = writer.ToArray(); client.SendBytes(data, data.Length, 0); }
public void Init() { _responseStub = new Response { Code = 1, Msg = "Fake message" }; var player = new PlayerResponse { PublicId = "publicId", AccessToken = "Token", Name = "PlayerName", Items = { "item1", "item2" }, Health = 2.10 }; var npc = new NPC { Name = "NPC_NAME", PublicId = "NPC_publicID", Health = 10.3 }; var bigResponse = new BigMessageResponse { Player = player, Npcs = { { "npc_key", npc } }, Chests = { "chest1", "chest2" } }; _bigMessageStub = new BigMessage { Code = "22", Response = bigResponse }; _respondeMessageEncodeJson = Encoding.UTF8.GetBytes("{\"code\": 1,\"msg\":\"Fake message\"}"); _bigMessageEncodedJson = Encoding.UTF8.GetBytes("{\"code\":\"22\",\"response\":{\"player\":{\"publicId\":\"publicId\",\"accessToken\":\"Token\",\"name\":\"PlayerName\",\"items\":[\"item1\",\"item2\"],\"health\":2.1},\"npcs\":{\"npc_key\":{\"name\":\"NPC_NAME\",\"health\":10.3,\"publicId\":\"NPC_publicID\"}},\"chests\":[\"chest1\",\"chest2\"]}}"); _bigMessageEncodedProtobuf = new byte[] { 0x0A, 0x02, 0x32, 0x32, 0x12, 0x74, 0x0A, 0x34, 0x0A, 0x08, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x49, 0x64, 0x12, 0x05, 0x54, 0x6F, 0x6B, 0x65, 0x6E, 0x1A, 0x0A, 0x50, 0x6C, 0x61, 0x79, 0x65, 0x72, 0x4E, 0x61, 0x6D, 0x65, 0x22, 0x05, 0x69, 0x74, 0x65, 0x6D, 0x31, 0x22, 0x05, 0x69, 0x74, 0x65, 0x6D, 0x32, 0x29, 0xCD, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x00, 0x40, 0x12, 0x2C, 0x0A, 0x07, 0x6E, 0x70, 0x63, 0x5F, 0x6B, 0x65, 0x79, 0x12, 0x21, 0x0A, 0x08, 0x4E, 0x50, 0x43, 0x5F, 0x4E, 0x41, 0x4D, 0x45, 0x11, 0x9A, 0x99, 0x99, 0x99, 0x99, 0x99, 0x24, 0x40, 0x1A, 0x0C, 0x4E, 0x50, 0x43, 0x5F, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x49, 0x44, 0x1A, 0x06, 0x63, 0x68, 0x65, 0x73, 0x74, 0x31, 0x1A, 0x06, 0x63, 0x68, 0x65, 0x73, 0x74, 0x32 }; _responseEncoded = new ProtobufSerializer(ProtobufSerializer.SerializationFormat.Protobuf).Encode(_responseStub); }
void OnKeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.D2) { if (!_tmpWorkaround) { _criminalGroup = World.AddRelationShipGroup("CRIMINALS_MOD"); //Wont work _tmpWorkaround = true; } if (!_onMission && IsInPoliceCar()) { _seconds = 180; StartMissions(); BigMessage.ShowMessage("Vigilante", 300, Color.Goldenrod); } else if (_onMission) { StopMissions(); } } }
void OnTick(object sender, EventArgs e) { //this._debug.Text = ; //this._debug.Draw(); BigMessage.OnTick(); Ped player = Game.Player.Character; if (_onMission) { Game.Player.WantedLevel = 0; if (_tick >= 60) { if (!_spotted) { _seconds--; _tick = 0; } } else { _tick++; } //FUTURE _headsup.Caption = "Level: ~b~" + _level; if (!_spotted) { _headsup.Caption += "~w~\nStart Chase: ~b~" + ParseTime(_seconds); } _headsup.Caption += "~w~\nKills: ~b~" + _kills; _headsup.Draw(); _headsupRectangle.Draw(); if (_seconds < 0) { UI.Notify("You ran out of time!\nThe ~r~criminals~w~ have escaped."); StopMissions(); } else { for (int i = 0; i < _criminals.Count; i++) { if (_criminals[i].IsDead) { _kills++; SpookCriminal(); AddCash(20 * _level); _criminals[i].MarkAsNoLongerNeeded(); _criminals.RemoveAt(i); _criminalBlips[i].Remove(); _criminalBlips.RemoveAt(i); if (_criminals.Count == 0) { _level++; SpookCriminal(); //int secsadded = _rndGet.Next(60, 200); //BigMessage.ShowMessage("~b~" + secsadded + " ~w~seconds added", 200, Color.White, 1.0f); _seconds = 180; UI.Notify("Good job officer! You've completed this level."); StartMissions(); } } else { if (_criminals[i].IsInVehicle()) { if (player.IsInVehicle()) { if ((player.Position - _criminals[i].Position).Length() < 40.0f && (player.CurrentVehicle.SirenActive || _criminals[i].IsInCombat) && !_spotted) { SpookCriminal(i); } } if ((player.Position - _criminals[i].Position).Length() < 50.0f && _criminals[i].CurrentVehicle.Speed < 1.0f && _spotted) { if (!_fighting) { _fighting = true; TaskSequence tasks = new TaskSequence(); tasks.AddTask.LeaveVehicle(); tasks.AddTask.FightAgainst(player, 100000); tasks.Close(); _criminals[i].Task.PerformSequence(tasks); } } else if (_fighting) { //this.Criminals[i].Task.ClearAll(); if (_criminals[i].IsInVehicle()) { _criminals[i].Task.CruiseWithVehicle(_criminals[i].CurrentVehicle, 60.0f, 6); } _fighting = false; } } else { if ((player.Position - _criminals[i].Position).Length() < 60.0f) { if (!_fighting) { _fighting = true; _criminals[i].Task.FightAgainst(player, 100000); } } else { if (_fighting) { TaskSequence tasks = new TaskSequence(); tasks.AddTask.EnterVehicle(); //tasks.AddTask.CruiseWithVehicle(this.Criminals[i].CurrentVehicle, 60.0f, 6); tasks.Close(); _criminals[i].Task.PerformSequence(tasks); //this.Fighting = false; } } } } } if (player.IsDead) { StopMissions(); } } } }
private void OnTick(object sender, EventArgs e) { //System.Diagnostics.Stopwatch Stopwatch = System.Diagnostics.Stopwatch.StartNew(); //Stopwatch.Start(); if (Function.Call <bool>(Hash.IS_HUD_HIDDEN) || Function.Call <bool>(Hash.IS_PLAYER_SWITCH_IN_PROGRESS)) { return; } Ped Character = Game.Player.Character; int WantedLevel = Game.Player.WantedLevel; // Option Offsets if ((Config.Options.BetterChases.IconOffsetX != 0 && Config.Options.BetterChases.IconOffsetX != BetterChasesIconOffsetX) || (Config.Options.BetterChases.IconOffsetY != 0 && Config.Options.BetterChases.IconOffsetY != BetterChasesIconOffsetY)) { CopsRamSprite.Position = new PointF(GTA.UI.Screen.Width - 265 + Config.Options.BetterChases.IconOffsetX, 5 + Config.Options.BetterChases.IconOffsetY); CopsShootSprite.Position = new PointF(GTA.UI.Screen.Width - 280 + Config.Options.BetterChases.IconOffsetX, 5 + Config.Options.BetterChases.IconOffsetY); ShowBetterChasesHUDUntil = Game.GameTime; BetterChasesIconOffsetX = Config.Options.BetterChases.IconOffsetX; BetterChasesIconOffsetY = Config.Options.BetterChases.IconOffsetY; } else if ((Config.Options.ArrestWarrants.IconOffsetX != 0 && Config.Options.ArrestWarrants.IconOffsetX != ArrestWarrantsIconOffsetX) || (Config.Options.ArrestWarrants.IconOffsetY != 0 && Config.Options.ArrestWarrants.IconOffsetY != ArrestWarrantsIconOffsetY)) { PedWantedSprite.Position = new PointF(GTA.UI.Screen.Width - 130 + Config.Options.ArrestWarrants.IconOffsetX, GTA.UI.Screen.Height - 19 + Config.Options.ArrestWarrants.IconOffsetY); CarWantedSprite.Position = new PointF(GTA.UI.Screen.Width - 144 + Config.Options.ArrestWarrants.IconOffsetX, GTA.UI.Screen.Height - 19 + Config.Options.ArrestWarrants.IconOffsetY); PlaneWantedSprite.Position = new PointF(GTA.UI.Screen.Width - 144 + Config.Options.ArrestWarrants.IconOffsetX, GTA.UI.Screen.Height - 19 + Config.Options.ArrestWarrants.IconOffsetY); HeliWantedSprite.Position = new PointF(GTA.UI.Screen.Width - 144 + Config.Options.ArrestWarrants.IconOffsetX, GTA.UI.Screen.Height - 19 + Config.Options.ArrestWarrants.IconOffsetY); BoatWantedSprite.Position = new PointF(GTA.UI.Screen.Width - 144 + Config.Options.ArrestWarrants.IconOffsetX, GTA.UI.Screen.Height - 19 + Config.Options.ArrestWarrants.IconOffsetY); BikeWantedSprite.Position = new PointF(GTA.UI.Screen.Width - 144 + Config.Options.ArrestWarrants.IconOffsetX, GTA.UI.Screen.Height - 19 + Config.Options.ArrestWarrants.IconOffsetY); ShowArrestWarrantsHUDUntil = Game.GameTime; ArrestWarrantsIconOffsetX = Config.Options.ArrestWarrants.IconOffsetX; ArrestWarrantsIconOffsetY = Config.Options.ArrestWarrants.IconOffsetY; } else if ((Config.Options.ArrestWarrants.TextOffsetX != 0 && Config.Options.ArrestWarrants.TextOffsetX != ArrestWarrantsTextOffsetX) || (Config.Options.ArrestWarrants.TextOffsetY != 0 && Config.Options.ArrestWarrants.TextOffsetY != ArrestWarrantsTextOffsetY)) { SuspectWanted = new GTA.UI.TextElement("~w~SUSPECT WANTED", new PointF(GTA.UI.Screen.Width - 150 + Config.Options.ArrestWarrants.TextOffsetX, GTA.UI.Screen.Height - 20 + Config.Options.ArrestWarrants.TextOffsetY), 0.4f, Color.White, GTA.UI.Font.ChaletLondon); WarrantActive = new GTA.UI.TextElement("~w~WARRANT ACTIVE", new PointF(GTA.UI.Screen.Width - 150 + Config.Options.ArrestWarrants.TextOffsetX, GTA.UI.Screen.Height - 20 + Config.Options.ArrestWarrants.TextOffsetY), 0.4f, Color.White, GTA.UI.Font.ChaletLondon); ShowArrestWarrantsHUDUntil = Game.GameTime; ArrestWarrantsTextOffsetX = Config.Options.ArrestWarrants.TextOffsetX; ArrestWarrantsTextOffsetY = Config.Options.ArrestWarrants.TextOffsetY; } else if ((Config.Options.ArrestWarrants.GradientOffsetX != 0 && Config.Options.ArrestWarrants.GradientOffsetX != ArrestWarrantsGradientOffsetX) || (Config.Options.ArrestWarrants.GradientOffsetY != 0 && Config.Options.ArrestWarrants.GradientOffsetY != ArrestWarrantsGradientOffsetY)) { WantedGradient.Position = new PointF(GTA.UI.Screen.Width - 490 + Config.Options.ArrestWarrants.GradientOffsetX, GTA.UI.Screen.Height - 22 + Config.Options.ArrestWarrants.GradientOffsetY); MichaelGradient.Position = new PointF(GTA.UI.Screen.Width - 490 + Config.Options.ArrestWarrants.GradientOffsetX, GTA.UI.Screen.Height - 22 + Config.Options.ArrestWarrants.GradientOffsetY); FranklinGradient.Position = new PointF(GTA.UI.Screen.Width - 490 + Config.Options.ArrestWarrants.GradientOffsetX, GTA.UI.Screen.Height - 22 + Config.Options.ArrestWarrants.GradientOffsetY); TrevorGradient.Position = new PointF(GTA.UI.Screen.Width - 490 + Config.Options.ArrestWarrants.GradientOffsetX, GTA.UI.Screen.Height - 22 + Config.Options.ArrestWarrants.GradientOffsetY); DimGradient.Position = new PointF(GTA.UI.Screen.Width - 490 + Config.Options.ArrestWarrants.GradientOffsetX, GTA.UI.Screen.Height - 22 + Config.Options.ArrestWarrants.GradientOffsetY); ShowArrestWarrantsHUDUntil = Game.GameTime; ArrestWarrantsGradientOffsetX = Config.Options.ArrestWarrants.GradientOffsetX; ArrestWarrantsGradientOffsetY = Config.Options.ArrestWarrants.GradientOffsetY; } if (Config.IsMenuOpen && ShowBetterChasesHUDUntil != 0 && ShowBetterChasesHUDUntil + OffsetChangeDisplayLength > Game.GameTime) { CopsRamSprite.Draw(); CopsShootSprite.Draw(); } else if (Config.IsMenuOpen && ShowArrestWarrantsHUDUntil != 0 && ShowArrestWarrantsHUDUntil + OffsetChangeDisplayLength > Game.GameTime) { WantedGradient.Draw(); PedWantedSprite.Draw(); CarWantedSprite.Draw(); SuspectWanted.Draw(); } else { if (Config.Options.BetterChases.ShowHUD && BetterChases.ActiveChase.PITAuthorized && WantedLevel > 0) { CopsRamSprite.Draw(); } if (Config.Options.BetterChases.ShowHUD && BetterChases.ActiveChase.DeadlyForce && WantedLevel > 0) { CopsShootSprite.Draw(); } if (Config.Options.ArrestWarrants.ShowHUD && (ArrestWarrants.PedWarrant.pedHash != 0 || (ArrestWarrants.VehicleWarrant.vehicleHash != 0 && Helpers.IsValid(Character.CurrentVehicle) && Character.CurrentVehicle.Model.Hash == ArrestWarrants.VehicleWarrant.vehicleHash))) { if (WantedLevel > 0 || Function.Call <bool>(Hash.ARE_PLAYER_STARS_GREYED_OUT, Game.Player)) { SuspectWanted.Draw(); WantedGradient.Draw(); } else { WarrantActive.Draw(); if (Character.Model == PedHash.Michael) { MichaelGradient.Draw(); } else if (Character.Model == PedHash.Franklin) { FranklinGradient.Draw(); } else if (Character.Model == PedHash.Trevor) { TrevorGradient.Draw(); } else { DimGradient.Draw(); } } if (ArrestWarrants.PedWarrant.pedHash != 0) { PedWantedSprite.Draw(); } if (ArrestWarrants.VehicleWarrant.vehicleHash != 0 && Helpers.IsValid(Character.CurrentVehicle) && Character.CurrentVehicle.Model.Hash == ArrestWarrants.VehicleWarrant.vehicleHash) { if (Helpers.GetModel(ArrestWarrants.VehicleWarrant.vehicleHash).IsCar) { CarWantedSprite.Draw(); } else if (Helpers.GetModel(ArrestWarrants.VehicleWarrant.vehicleHash).IsBicycle || Helpers.GetModel(ArrestWarrants.VehicleWarrant.vehicleHash).IsBike) { BikeWantedSprite.Draw(); } else if (Helpers.GetModel(ArrestWarrants.VehicleWarrant.vehicleHash).IsBoat) { BoatWantedSprite.Draw(); } else if (Helpers.GetModel(ArrestWarrants.VehicleWarrant.vehicleHash).IsPlane) { PlaneWantedSprite.Draw(); } else if (Helpers.GetModel(ArrestWarrants.VehicleWarrant.vehicleHash).IsHelicopter) { HeliWantedSprite.Draw(); } } } } // Recognition Markers if (Config.Options.ArrestWarrants.ShowSpottedIndicators && Markers.Count > 0) { foreach (UIMarker marker in Markers) { World.DrawMarker(marker.Type, marker.Entity.Position + new Vector3(0f, 0f, 1.5f), new Vector3(0, 0, 0), new Vector3(0f, 180f, 0f), new Vector3(0.5f, 0.5f, 0.5f), marker.Color, true, false, true, "", "", false); } } // Recognition meter if (Config.Options.ArrestWarrants.ShowSpottedMeter && Markers.Count > 0 && ArrestWarrants.ShowSpottedMeter) { SpottedMeterBG.Draw(); SpottedMeterText.Caption = "A cop is watching you.~n~~y~Recognition process: ~r~" + Math.Round(ArrestWarrants.SpottedMeter, 0) + "%"; SpottedMeterText.Draw(); } // Display Help Messages if (HelpMessages.Count > 0 && Game.GameTime > HelpMessageTime + HelpMessageInterval) { Function.Call(Hash.BEGIN_TEXT_COMMAND_DISPLAY_HELP, "STRING"); Function.Call(Hash.ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME, HelpMessages[0]); Function.Call(Hash.END_TEXT_COMMAND_DISPLAY_HELP, 0, 0, 0, HelpMessageInterval); HelpMessageTime = Game.GameTime; HelpMessages.RemoveAt(0); } // Display Big Messages if (BigMessages.Count > 0 && BigMessageTime == 0 && Game.GameTime > BigMessageTime + BigMessageInterval) { BigMessage message = BigMessages[0]; Scaleform.CallFunction("SHOW_SHARD_CENTERED_MP_MESSAGE", message.text, message.description, (int)message.color, (int)message.background); Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "CHECKPOINT_NORMAL", "HUD_MINI_GAME_SOUNDSET"); BigMessageTime = Game.GameTime; BigMessageInterval = message.duration; } else if (BigMessageTime > 0 && Game.GameTime < BigMessageTime + BigMessageInterval) { Scaleform.Render2D(); } else if (BigMessageTime > 0 && Game.GameTime > BigMessageTime + BigMessageInterval) { Scaleform.CallFunction("TRANSITION_OUT"); BigMessageTime = 0; BigMessages.RemoveAt(0); } //Stopwatch.Stop(); //UI.ShowSubtitle("Debug: " + "" + " CPU: " + Stopwatch.Elapsed); }