add wanteds

This commit is contained in:
hydrant
2019-06-26 20:09:19 +02:00
parent 8125ba673e
commit 3a894ddb93
10 changed files with 135 additions and 7 deletions

View File

@@ -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();
}
}
}