[+] Finished Payday-System

This commit is contained in:
Lukas Moungos
2019-07-19 23:22:21 +02:00
parent adfc6fe8e9
commit 82b91543a9
6 changed files with 1269 additions and 0 deletions

View File

@@ -89,6 +89,8 @@ namespace ReallifeGamemode.Server.Entities
public int JailTime { get; set; }
public int PaydayTimer { get; set; }
public bool IsAdmin(AdminLevel level) => AdminLevel >= level;
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)

View File

@@ -53,6 +53,8 @@ namespace ReallifeGamemode.Server.Events
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
//player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ);
user.PaydayTimer = 60;
}
else if (dbContext.Users.Where(u => u.SocialClubName == player.SocialClubName).Count() >= 3)
{

View File

@@ -181,5 +181,39 @@ namespace ReallifeGamemode.Server.Finance
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Du hast einen Payday von ~r~$" + paycheck.Amount + "~s~ bekommen.");
}
public static void PaydayTimer()
{
System.Timers.Timer timer = new System.Timers.Timer(60000);
timer.Start();
timer.Elapsed += Timer_Elapsed;
}
private static void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
foreach (var player in NAPI.Pools.GetAllPlayers())
{
User user = player.GetUser();
if (player.IsLoggedIn())
{
if (user.PaydayTimer <= 0)
{
Economy.SetPaycheck(player, user.Wage);
return;
}
if (user.PaydayTimer > 0)
{
using (var dbContext = new DatabaseContext())
{
player.GetUser(dbContext).PaydayTimer -= 1;
dbContext.SaveChanges();
}
}
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace ReallifeGamemode.Migrations
{
public partial class PaydayTimer : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "PaydayTimer",
table: "Users",
nullable: false,
defaultValue: 0);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "PaydayTimer",
table: "Users");
}
}
}

View File

@@ -840,6 +840,8 @@ namespace ReallifeGamemode.Migrations
b.Property<int?>("HouseId");
b.Property<int>("JailTime");
b.Property<int?>("JobId");
b.Property<int>("LogUserId");
@@ -849,6 +851,8 @@ namespace ReallifeGamemode.Migrations
b.Property<string>("Password")
.HasMaxLength(64);
b.Property<int>("PaydayTimer");
b.Property<float>("PositionX");