diff --git a/ReallifeGamemode.Client/Gui/blips.ts b/ReallifeGamemode.Client/Gui/blips.ts index ba6b8446..d02df572 100644 --- a/ReallifeGamemode.Client/Gui/blips.ts +++ b/ReallifeGamemode.Client/Gui/blips.ts @@ -16,7 +16,7 @@ export default function playerBlips() { mp.players.forEachInStreamRange( (player) => { if (mp.players.local == player) - return; + return; if (!playerBlipMap.has(player)) { let pBlip = mp.blips.new(1, player.position, { @@ -59,21 +59,21 @@ export default function playerBlips() { } return; } - - if (!escapeTimer && !afkStatus && getWantedCount() > 0) { - mp.events.call("SERVER:SetWantedFlash", true); - escapeTimer = setInterval(() => { - if (getWantedCount() == 0) { - clearInterval(escapeTimer); - escapeTimer = null; - return; - } - - mp.events.callRemote("CLIENT:EscapeWanted"); - }, 300000); //120000 -> 2 min , 300000 -> 5min - } } }); + + if (!escapeTimer && !afkStatus && getWantedCount() > 0) { + mp.events.call("SERVER:SetWantedFlash", true); + escapeTimer = setInterval(() => { + if (getWantedCount() == 0) { + clearInterval(escapeTimer); + escapeTimer = null; + return; + } + + mp.events.callRemote("CLIENT:EscapeWanted"); + }, 5000); //120000 -> 2 min , 300000 -> 5min + } }, 50); mp.events.add("playerReady", () => { diff --git a/ReallifeGamemode.Client/Gui/notification.ts b/ReallifeGamemode.Client/Gui/notification.ts new file mode 100644 index 00000000..486c603c --- /dev/null +++ b/ReallifeGamemode.Client/Gui/notification.ts @@ -0,0 +1,31 @@ +export default function notification() { + const _SET_NOTIFICATION_COLOR_NEXT = "0x39BBF623FC803EAC"; + const _SET_NOTIFICATION_BACKGROUND_COLOR = "0x92F0DA1E27DB96DC"; + + mp.events.add("BN_Show", (message, flashing = false, textColor = -1, bgColor = -1, flashColor = [77, 77, 77, 200]) => { + if (textColor > -1) mp.game.invoke(_SET_NOTIFICATION_COLOR_NEXT, textColor); + if (bgColor > -1) mp.game.invoke(_SET_NOTIFICATION_BACKGROUND_COLOR, bgColor); + if (flashing) mp.game.ui.setNotificationFlashColor(flashColor[0], flashColor[1], flashColor[2], flashColor[3]); + + mp.game.gxt.set("BNOTIF_LONG_TEXT_ENTRY", `~a~${message}`); + mp.game.ui.setNotificationTextEntry("BNOTIF_LONG_TEXT_ENTRY"); + mp.game.ui.addTextComponentSubstringPlayerName(""); // needed for text color to work + mp.game.ui.drawNotification(flashing, true); + }); + + mp.events.add("BN_ShowWithPicture", (title, sender, message, notifPic, icon = 0, flashing = false, textColor = -1, bgColor = -1, flashColor = [77, 77, 77, 200]) => { + if (textColor > -1) mp.game.invoke(_SET_NOTIFICATION_COLOR_NEXT, textColor); + if (bgColor > -1) mp.game.invoke(_SET_NOTIFICATION_BACKGROUND_COLOR, bgColor); + if (flashing) mp.game.ui.setNotificationFlashColor(flashColor[0], flashColor[1], flashColor[2], flashColor[3]); + + mp.game.gxt.set("BNOTIF_LONG_TEXT_ENTRY_IMG", `~a~${message}`); + mp.game.ui.setNotificationTextEntry("BNOTIF_LONG_TEXT_ENTRY_IMG"); + mp.game.ui.addTextComponentSubstringPlayerName(""); // needed for text color to work + mp.game.ui.setNotificationMessage(notifPic, notifPic, flashing, icon, title, sender); + }); + + const notifications = { + show: (message, flashing = false, textColor = -1, bgColor = -1, flashColor = [77, 77, 77, 200]) => mp.events.call("BN_Show", message, flashing, textColor, bgColor, flashColor), + showWithPicture: (title, sender, message, notifPic, icon = 0, flashing = false, textColor = -1, bgColor = -1, flashColor = [77, 77, 77, 200]) => mp.events.call("BN_ShowWithPicture", title, sender, message, notifPic, icon, flashing, textColor, bgColor, flashColor) + }; +} \ No newline at end of file diff --git a/ReallifeGamemode.Client/index.ts b/ReallifeGamemode.Client/index.ts index 72f41def..1d47c140 100644 --- a/ReallifeGamemode.Client/index.ts +++ b/ReallifeGamemode.Client/index.ts @@ -277,6 +277,9 @@ spawnschutz(); import bigmap from './Gui/bigmap'; bigmap(); +import notification from './Gui/notification'; +notification(); + require('./Gui/policedepartment'); require('./Gui/helptext'); require('./admin/spectate'); diff --git a/ReallifeGamemode.Server/Extensions/ClientExtension.cs b/ReallifeGamemode.Server/Extensions/ClientExtension.cs index 56f0d4f7..3d66bfc3 100644 --- a/ReallifeGamemode.Server/Extensions/ClientExtension.cs +++ b/ReallifeGamemode.Server/Extensions/ClientExtension.cs @@ -103,7 +103,7 @@ namespace ReallifeGamemode.Server.Extensions int factionMoney = user.Wanteds * 6; var executiveFactions = dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 1 || f.Id == 3); - foreach(var faction in executiveFactions) + foreach (var faction in executiveFactions) { faction.BankAccount.Balance += factionMoney; } @@ -224,8 +224,7 @@ namespace ReallifeGamemode.Server.Extensions dbUser.SetBlipAndNametagColor(); dbContext.SaveChanges(); } - ChatService.SendMessage(user.Player, "!{#FF614A}Du hast ein Verbrechen begangen: " + reason + "" + (cop != null ? " | Gemeldet von: " + cop.Name + "." : "")); - ChatService.SendMessage(user.Player, " !{#FFFF00}Fahndungslevel:~s~ " + newWanteds); + user.Player.TriggerEvent("BN_ShowWithPicture", "Straftat", cop != null ? "Officer " + cop.Name + "" : "LSPD", "Du hast ein Verbrechen begangen: " + reason + ".'\n' Fahndungslevel: " + newWanteds, "DIA_POLICE", 1, true, 15); foreach (var copPlayer in NAPI.Pools.GetAllPlayers()) { diff --git a/ReallifeGamemode.Server/Wanted/WantedEscapeTimer.cs b/ReallifeGamemode.Server/Wanted/WantedEscapeTimer.cs index ffbac518..32985165 100644 --- a/ReallifeGamemode.Server/Wanted/WantedEscapeTimer.cs +++ b/ReallifeGamemode.Server/Wanted/WantedEscapeTimer.cs @@ -21,10 +21,10 @@ namespace ReallifeGamemode.Server.Wanted using var dbContext = new DatabaseContext(); User user = player.GetUser(dbContext); - if (user.Wanteds <= 0) + if (user.Wanteds <= 0) return; - player.SendChatMessage("~y~Du hast erfolgreich einen Wanted abgetaucht."); + player.TriggerEvent("BN_ShowWithPicture", "Abgetaucht", "Lester", "Du hast erfolgreich ein Wanted ~y~abgetaucht", "CHAR_LESTER", 1, true); user.Wanteds -= 1; if (user.Wanteds == 0) {