add wanteds
This commit is contained in:
@@ -19,6 +19,9 @@ namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class User : IBankAccountOwner
|
||||
{
|
||||
[NotMapped]
|
||||
private int _wanteds;
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
@@ -66,7 +69,15 @@ namespace ReallifeGamemode.Server.Entities
|
||||
|
||||
public int? JobId { get; set; }
|
||||
|
||||
public int Wanteds { get; set; }
|
||||
public int Wanteds
|
||||
{
|
||||
get => _wanteds;
|
||||
set
|
||||
{
|
||||
this._wanteds = value;
|
||||
Client.TriggerEvent("SERVER:SetWanteds", value);
|
||||
}
|
||||
}
|
||||
|
||||
public FactionRank GetFactionRank()
|
||||
{
|
||||
@@ -182,10 +193,16 @@ namespace ReallifeGamemode.Server.Entities
|
||||
|
||||
internal void GiveWanteds(Client cop, int amount, string reason)
|
||||
{
|
||||
if(this.Wanteds + amount > 40)
|
||||
if (this.Wanteds + amount > 40)
|
||||
{
|
||||
ChatService.ErrorMessage(cop, "Die Wanteds dürfen ein Limit von 40 nicht überschreiten");
|
||||
return;
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
|
||||
User user = dbContext.Users.Where(u => u.Id == this.Id).FirstOrDefault();
|
||||
user.Wanteds += amount;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user