set blip color in one function

This commit is contained in:
hydrant
2021-04-05 16:26:12 +02:00
parent 072be07e98
commit f8237c84bb
7 changed files with 134 additions and 315 deletions

View File

@@ -131,8 +131,7 @@ namespace ReallifeGamemode.Server.Extensions
dbUser.Wanteds = newWanteds;
dbContext.SaveChanges();
}
user.Player.SetSharedData("nameTagColor", -1);
user.Player.SetSharedData("blipColor", 64);
user.SetBlipAndNametagColor();
ChatService.SendMessage(user.Player, "!{#FF614A}Du hast ein Verbrechen begangen: " + reason + "" + (cop != null ? " | Gemeldet von: " + cop.Name + "." : ""));
ChatService.SendMessage(user.Player, " !{#FFFF00}Fahnundgslevel:~s~ " + newWanteds);
@@ -237,11 +236,81 @@ namespace ReallifeGamemode.Server.Extensions
public static bool IsAdmin(this User user, AdminLevel adminLevel)
{
if(user == null)
if (user == null)
{
return false;
}
return user.AdminLevel >= adminLevel;
}
public static void SetBlipAndNametagColor(this User user)
{
if (user == null)
{
return;
}
int blipColor = 0;
int nameTagColor = 0;
Player player = user.Player;
bool duty = user.GetData<bool>("duty");
if (player.GetData<bool>("SAdminduty"))
{
blipColor = 30;
nameTagColor = -2;
}
else if (user.Wanteds > 0)
{
nameTagColor = -1;
blipColor = 64;
}
else if (user.Faction != null)
{
nameTagColor = user.FactionId.Value;
switch (user.FactionId)
{
case 1 when duty:
blipColor = 38;
break;
case 2 when duty:
blipColor = 6;
break;
case 3 when duty:
blipColor = 63;
break;
case 4:
blipColor = 5;
break;
case 5:
break;
case 6:
break;
case 7:
blipColor = 52;
break;
case 8:
blipColor = 83;
break;
case 9:
blipColor = 25;
break;
}
}
NAPI.Util.ConsoleOutput($"{player.Name} - Setting blip and nametag color: nametag = {nameTagColor}, blip = {blipColor}");
user.Player.SetSharedData("nameTagColor", nameTagColor);
user.Player.SetSharedData("blipColor", blipColor);
}
}
}