wanted abtauchen blinken

This commit is contained in:
hydrant
2021-04-11 21:53:08 +02:00
parent f258896e56
commit 523e193317
3 changed files with 101 additions and 54 deletions

View File

@@ -4,4 +4,8 @@
mp.events.add("SERVER:SetWanteds", (count: number) => { mp.events.add("SERVER:SetWanteds", (count: number) => {
browser.execute(`setWanteds(${count});`); browser.execute(`setWanteds(${count});`);
}); });
mp.events.add("SERVER:SetWantedFlash", (flash) => {
browser.execute(`setFlashing(${flash});`);
});
} }

View File

@@ -6,8 +6,15 @@
<title>Wanteds</title> <title>Wanteds</title>
<style> <style>
@font-face { font-family: 'Pricedown'; src: url('package://assets/font/Pricedown.ttf'); } @font-face {
html, body { margin: 0; padding: 0; } font-family: 'Pricedown';
src: url('package://assets/font/Pricedown.ttf');
}
html, body {
margin: 0;
padding: 0;
}
#wanteds { #wanteds {
position: absolute; position: absolute;
@@ -23,7 +30,6 @@
width: 25px; width: 25px;
height: 25px; height: 25px;
margin-right: 5px; margin-right: 5px;
filter: drop-shadow(0px 0px 1px #000000); filter: drop-shadow(0px 0px 1px #000000);
-webkit-filter: drop-shadow(0px 0px 1px #000000); -webkit-filter: drop-shadow(0px 0px 1px #000000);
-moz-filter: drop-shadow(0px 0px 1px #000000); -moz-filter: drop-shadow(0px 0px 1px #000000);
@@ -42,7 +48,7 @@
<body> <body>
<div id="wanteds" style="display: none;"> <div id="wanteds" style="display: none;">
<img src="package://assets/img/wanteds/star.svg"> <span id="wanted-count">10</span> <img src="package://assets/img/wanteds/star.svg" id="wanted-star"> <span id="wanted-count">10</span>
</div> </div>
<script src="package://assets/js/jquery-3.3.1.min.js"></script> <script src="package://assets/js/jquery-3.3.1.min.js"></script>
@@ -55,6 +61,39 @@
$("#wanted-count").text(count.toString()); $("#wanted-count").text(count.toString());
} }
} }
var flashInterval = null;
var previousFlashToggle = false;
var firstToggle = true;
function setFlashing(flash) {
if (previousFlashToggle == flash && !firstToggle) {
return;
}
firstToggle = false;
previousFlashToggle = flash;
if (flash) {
if (flashInterval) {
clearInterval(flashInterval);
}
flashInterval = setInterval(flashWantedImage, 750);
} else {
clearInterval(flashInterval);
$("#wanted-star").css('visibility', 'visible');
}
}
var flashStatus = false;
function flashWantedImage() {
flashStatus = !flashStatus;
if (flashStatus) {
$("#wanted-star").css('visibility', 'visible');
} else {
$("#wanted-star").css('visibility', 'hidden');
}
}
</script> </script>
</body> </body>
</html> </html>

View File

@@ -27,12 +27,8 @@ namespace ReallifeGamemode.Server.Wanted
} }
*/ */
public static void ResetWantedTimeToElapse(Player client) public static void ResetWantedTimeToElapse(User user)
{ {
User user = client.GetUser();
if (user.FactionId == 1 || user.FactionId == 3)
return;
waTimer[user.Id] = WantedEscapeTime; waTimer[user.Id] = WantedEscapeTime;
} }
@@ -45,7 +41,7 @@ namespace ReallifeGamemode.Server.Wanted
if (user != null && user.Wanteds > 0) if (user != null && user.Wanteds > 0)
{ {
if (!waTimer.ContainsKey(user.Id)) if (!waTimer.ContainsKey(user.Id))
ResetWantedTimeToElapse(player); ResetWantedTimeToElapse(user);
bool isNearCop = false; bool isNearCop = false;
foreach (var playerCop in NAPI.Pools.GetAllPlayers()) foreach (var playerCop in NAPI.Pools.GetAllPlayers())
@@ -70,7 +66,7 @@ namespace ReallifeGamemode.Server.Wanted
if (waTimer[user.Id] <= 0) if (waTimer[user.Id] <= 0)
{ {
ResetWantedTimeToElapse(player); ResetWantedTimeToElapse(user);
player.SendChatMessage("~y~Du hast erfolgreich einen Wanted abgetaucht."); player.SendChatMessage("~y~Du hast erfolgreich einen Wanted abgetaucht.");
user.Wanteds -= 1; user.Wanteds -= 1;
if (user.Wanteds == 0) if (user.Wanteds == 0)
@@ -82,8 +78,16 @@ namespace ReallifeGamemode.Server.Wanted
waTimer[user.Id] = WantedEscapeTime; waTimer[user.Id] = WantedEscapeTime;
} }
else if (!isNearCop) else if (!isNearCop)
{
player.TriggerEvent("SERVER:SetWantedFlash", true);
waTimer[user.Id] -= 2500; waTimer[user.Id] -= 2500;
} }
else if (isNearCop)
{
player.TriggerEvent("SERVER:SetWantedFlash", false);
ResetWantedTimeToElapse(user);
}
}
} }
} }
} }