Haus erweiterungen
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
|
|
||||||
@@ -22,6 +23,8 @@ namespace ReallifeGamemode.Database.Entities
|
|||||||
|
|
||||||
public bool CanRentIn { get; set; }
|
public bool CanRentIn { get; set; }
|
||||||
|
|
||||||
|
public DateTime LastRentSetTime { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public Vector3 Position => new Vector3(X, Y, Z);
|
public Vector3 Position => new Vector3(X, Y, Z);
|
||||||
|
|
||||||
|
|||||||
1428
ReallifeGamemode.Database/Migrations/20200324175347_HouseWeeklyRentalFee.Designer.cs
generated
Normal file
1428
ReallifeGamemode.Database/Migrations/20200324175347_HouseWeeklyRentalFee.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
|
{
|
||||||
|
public partial class HouseWeeklyRentalFee : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<DateTime>(
|
||||||
|
name: "LastRentSetTime",
|
||||||
|
table: "Houses",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "LastRentSetTime",
|
||||||
|
table: "Houses");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -483,6 +483,8 @@ namespace ReallifeGamemode.Database.Migrations
|
|||||||
|
|
||||||
b.Property<bool>("CanRentIn");
|
b.Property<bool>("CanRentIn");
|
||||||
|
|
||||||
|
b.Property<DateTime>("LastRentSetTime");
|
||||||
|
|
||||||
b.Property<int?>("OwnerId");
|
b.Property<int?>("OwnerId");
|
||||||
|
|
||||||
b.Property<int>("Price");
|
b.Property<int>("Price");
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ namespace ReallifeGamemode.Server
|
|||||||
[ServerEvent(Event.ResourceStart)]
|
[ServerEvent(Event.ResourceStart)]
|
||||||
public void OnResourceStart()
|
public void OnResourceStart()
|
||||||
{
|
{
|
||||||
|
System.Console.WriteLine(System.DateTime.Now.ToShortTimeString());
|
||||||
|
|
||||||
var methods = Assembly.GetExecutingAssembly()
|
var methods = Assembly.GetExecutingAssembly()
|
||||||
.GetTypes()
|
.GetTypes()
|
||||||
.SelectMany(t => t.GetMethods())
|
.SelectMany(t => t.GetMethods())
|
||||||
|
|||||||
@@ -106,7 +106,12 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
|
|
||||||
if (house.OwnerId != null)
|
if (house.OwnerId != null)
|
||||||
{
|
{
|
||||||
text = $"{house.Type}\n~s~Besitzer: ~y~{house.Owner.Name}\n~s~Mietpreis: ~g~{house.RentalFee.ToMoneyString()}";
|
text = $"{house.Type}\n~s~Besitzer: ~y~{house.Owner.Name}";
|
||||||
|
|
||||||
|
if (house.RentalFee != 0)
|
||||||
|
{
|
||||||
|
text += $"\n~s~Mietpreis: ~g~{house.RentalFee.ToMoneyString()}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -264,6 +269,23 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
|
|
||||||
House house = GetHouseById(user.HouseId.Value, dbContext);
|
House house = GetHouseById(user.HouseId.Value, dbContext);
|
||||||
|
|
||||||
|
if (DateTime.Now - house.LastRentSetTime < TimeSpan.FromDays(7))
|
||||||
|
{
|
||||||
|
DateTime newPossibility = house.LastRentSetTime.AddDays(7);
|
||||||
|
string dateStr = newPossibility.ToLongDateString();
|
||||||
|
string timeStr = newPossibility.ToShortTimeString();
|
||||||
|
player.SendNotification(
|
||||||
|
$"~r~Die Miete wurde in den letzten 7 Tagen schon verändert. Die nächste Änderung kann am {dateStr} um {timeStr} Uhr geändert werden.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rentalFee < 0)
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Die Miete darf kein negativer Betrag sein!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
house.LastRentSetTime = DateTime.Now;
|
||||||
house.RentalFee = rentalFee;
|
house.RentalFee = rentalFee;
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
|
|||||||
Reference in New Issue
Block a user