rentcar cancel by afk
This commit is contained in:
2229
ReallifeGamemode.Database/Migrations/20210615083431_lol.Designer.cs
generated
Normal file
2229
ReallifeGamemode.Database/Migrations/20210615083431_lol.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
17
ReallifeGamemode.Database/Migrations/20210615083431_lol.cs
Normal file
17
ReallifeGamemode.Database/Migrations/20210615083431_lol.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace ReallifeGamemode.Database.Migrations
|
||||
{
|
||||
public partial class lol : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
2229
ReallifeGamemode.Database/Migrations/20210615083538_lol2.Designer.cs
generated
Normal file
2229
ReallifeGamemode.Database/Migrations/20210615083538_lol2.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
17
ReallifeGamemode.Database/Migrations/20210615083538_lol2.cs
Normal file
17
ReallifeGamemode.Database/Migrations/20210615083538_lol2.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace ReallifeGamemode.Database.Migrations
|
||||
{
|
||||
public partial class lol2 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -41,7 +41,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
Rentcar.cancelRent(player);
|
||||
Rentcar.cancelRent(player, RentCancelReason.byPlayer);
|
||||
}
|
||||
|
||||
[Command("eventport", "~m~eventport")]
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
|
||||
if (Rentcar.mapPlayerRentcarBill.ContainsKey(player.Name))
|
||||
{
|
||||
Rentcar.cancelRent(player);
|
||||
Rentcar.cancelRent(player, RentCancelReason.byDisconnect);
|
||||
}
|
||||
|
||||
//Vehicle LastVehicle = player.GetData<Vehicle>("LastVehicle");
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
@@ -30,6 +31,10 @@ namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Rentcar.mapPlayerRentcarBill.ContainsKey(player.Name))
|
||||
{
|
||||
Rentcar.cancelRent(player, RentCancelReason.byAfk);
|
||||
}
|
||||
|
||||
player.SendNotification("Du wurdest ~b~AFK~s~ gesetzt", true);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,14 @@ using ReallifeGamemode.Server.Services;
|
||||
|
||||
namespace ReallifeGamemode.Server.Util
|
||||
{
|
||||
public enum RentCancelReason
|
||||
{
|
||||
byPlayer,
|
||||
byDisconnect,
|
||||
byAfk,
|
||||
byNoMoney
|
||||
}
|
||||
|
||||
class Rentcar : Script
|
||||
{
|
||||
private static readonly ILogger logger = LogManager.GetLogger<Rentcar>();
|
||||
@@ -71,19 +79,31 @@ namespace ReallifeGamemode.Server.Util
|
||||
lamesaVehicleProperties.Add(new RentcarProperty("panto", 200));
|
||||
}
|
||||
|
||||
public static void cancelRent(Player player)
|
||||
public static void cancelRent(Player player, RentCancelReason cancelReason)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User user = player.GetUser(dbContext);
|
||||
user.BankAccount.Balance -= mapPlayerRentcarBill[player.Name].Item2;
|
||||
logger.LogInformation("Player {0} cancelled a rent and payed {1} dollars", player.Name, mapPlayerRentcarBill[player.Name].Item2);
|
||||
logger.LogInformation("Player {0} cancelled a rent and payed {1} dollars ({3})", player.Name, mapPlayerRentcarBill[player.Name].Item2, cancelReason.ToString());
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
if (cancelReason == RentCancelReason.byPlayer)
|
||||
{
|
||||
player.SendChatMessage("~y~[Fahrzeugverleih] ~w~Mietfahrzeug erfolgreich gekündigt (Kosten: ~g~$~w~" + mapPlayerRentcarBill[player.Name].Item2 + ").");
|
||||
}
|
||||
else if (cancelReason == RentCancelReason.byAfk)
|
||||
{
|
||||
player.SendChatMessage("~y~[Fahrzeugverleih] ~w~Da du Afk bist wurde die Fahrzeugmiete automatisch gekündigt");
|
||||
}
|
||||
else if (cancelReason == RentCancelReason.byNoMoney)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du hast nicht genügend Geld auf dem Konto. Dein Mietfahrzeug wurde zurückgegeben");
|
||||
}
|
||||
|
||||
player.SetData("hasRentcar", false);
|
||||
player.TriggerEvent("abortRentcarTimer");
|
||||
player.SendChatMessage("~y~[Fahrzeugverleih] ~w~Mietfahrzeug erfolgreich gekündigt (Kosten: ~g~$~w~" + mapPlayerRentcarBill[player.Name].Item2 + ").");
|
||||
VehicleManager.DeleteVehicle(mapPlayerRentcarBill[player.Name].Item1);
|
||||
Rentcar.mapPlayerRentcarBill.Remove(player.Name);
|
||||
}
|
||||
@@ -102,8 +122,7 @@ namespace ReallifeGamemode.Server.Util
|
||||
|
||||
if (bill > user.BankAccount.Balance)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du hast nicht genügend Geld auf dem Konto. Dein Mietfahrzeug wurde zurückgegeben");
|
||||
cancelRent(player);
|
||||
cancelRent(player, RentCancelReason.byNoMoney);
|
||||
dbContext.SaveChanges();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user