[+] Finished Payday-System
This commit is contained in:
@@ -89,6 +89,8 @@ namespace ReallifeGamemode.Server.Entities
|
|||||||
|
|
||||||
public int JailTime { get; set; }
|
public int JailTime { get; set; }
|
||||||
|
|
||||||
|
public int PaydayTimer { get; set; }
|
||||||
|
|
||||||
public bool IsAdmin(AdminLevel level) => AdminLevel >= level;
|
public bool IsAdmin(AdminLevel level) => AdminLevel >= level;
|
||||||
|
|
||||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
|
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
|
||||||
//player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ);
|
//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)
|
else if (dbContext.Users.Where(u => u.SocialClubName == player.SocialClubName).Count() >= 3)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -181,5 +181,39 @@ namespace ReallifeGamemode.Server.Finance
|
|||||||
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Du hast einen Payday von ~r~$" + paycheck.Amount + "~s~ bekommen.");
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1204
ReallifeGamemode.Server/Migrations/20190719210722_PaydayTimer.Designer.cs
generated
Normal file
1204
ReallifeGamemode.Server/Migrations/20190719210722_PaydayTimer.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -840,6 +840,8 @@ namespace ReallifeGamemode.Migrations
|
|||||||
|
|
||||||
b.Property<int?>("HouseId");
|
b.Property<int?>("HouseId");
|
||||||
|
|
||||||
|
b.Property<int>("JailTime");
|
||||||
|
|
||||||
b.Property<int?>("JobId");
|
b.Property<int?>("JobId");
|
||||||
|
|
||||||
b.Property<int>("LogUserId");
|
b.Property<int>("LogUserId");
|
||||||
@@ -849,6 +851,8 @@ namespace ReallifeGamemode.Migrations
|
|||||||
|
|
||||||
b.Property<string>("Password")
|
b.Property<string>("Password")
|
||||||
.HasMaxLength(64);
|
.HasMaxLength(64);
|
||||||
|
|
||||||
|
b.Property<int>("PaydayTimer");
|
||||||
|
|
||||||
b.Property<float>("PositionX");
|
b.Property<float>("PositionX");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user