maybe fix knast
This commit is contained in:
@@ -59,6 +59,34 @@ namespace ReallifeGamemode.Server.Extensions
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetJailTime(this User user, bool killed)
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int time = 26 * user.Wanteds;
|
||||
if (killed)
|
||||
{
|
||||
time *= 2;
|
||||
}
|
||||
|
||||
user.Wanteds = 0;
|
||||
user.JailTime = time;
|
||||
}
|
||||
|
||||
public static void AnnouncePlayerJailedIn(this User user)
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string message = user.Name + " wurde ins Gefängnis geliefert";
|
||||
|
||||
ChatService.HQMessage(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gibt zurück, ob ein Player eingeloggt ist
|
||||
/// </summary>
|
||||
@@ -76,8 +104,35 @@ namespace ReallifeGamemode.Server.Extensions
|
||||
|
||||
public static bool IsDuty(this Player player)
|
||||
{
|
||||
var user = player.GetUser();
|
||||
return user.GetData("duty", false);
|
||||
return player.GetServerData("duty", false);
|
||||
}
|
||||
|
||||
public static bool IsAlive(this Player player)
|
||||
{
|
||||
return !player.HasData("isDead") || (bool)player.GetData("isDead") == false;
|
||||
}
|
||||
|
||||
public static T GetServerData<T>(this Player player, string key, T defaultValue = default)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
key += "data_";
|
||||
if (!player.HasData(key)) return defaultValue;
|
||||
return JsonConvert.DeserializeObject<T>(player.GetData<dynamic>(key));
|
||||
}
|
||||
|
||||
public static void SetServerData(this Player player, string key, object value)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
key += "data_";
|
||||
player.SetData(key, JsonConvert.SerializeObject(value));
|
||||
}
|
||||
|
||||
public static bool IsAdminDuty(this Player player)
|
||||
@@ -98,27 +153,14 @@ namespace ReallifeGamemode.Server.Extensions
|
||||
|
||||
internal static T GetData<T>(this User user, string key, T nullValue)
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
key += "data_";
|
||||
if (!user.Player.HasData(key)) return nullValue;
|
||||
return JsonConvert.DeserializeObject<T>(user.Player.GetData<dynamic>(key));
|
||||
return user.Player.GetServerData(key, nullValue);
|
||||
}
|
||||
|
||||
internal static T GetData<T>(this User user, string key) => user.GetData<T>(key, default);
|
||||
|
||||
internal static void SetData(this User user, string key, object value)
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
key += "data_";
|
||||
user.Player.SetData(key, JsonConvert.SerializeObject(value));
|
||||
user.Player.SetServerData(key, value);
|
||||
}
|
||||
|
||||
internal static void GiveWanteds(this User user, Player cop, int amount, string reason)
|
||||
|
||||
Reference in New Issue
Block a user