bissl formattiert
This commit is contained in:
@@ -29,7 +29,7 @@ namespace ReallifeGamemode.DataService
|
|||||||
private readonly IConfiguration configuration;
|
private readonly IConfiguration configuration;
|
||||||
private readonly IWebHostEnvironment environment;
|
private readonly IWebHostEnvironment environment;
|
||||||
|
|
||||||
public Startup(IConfiguration configuration,IWebHostEnvironment environment, ILogger<Startup> logger)
|
public Startup(IConfiguration configuration, IWebHostEnvironment environment, ILogger<Startup> logger)
|
||||||
{
|
{
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace ReallifeGamemode.Database.Entities
|
namespace ReallifeGamemode.Database.Entities
|
||||||
{
|
{
|
||||||
public partial class JobVehicle : ServerVehicle
|
public partial class JobVehicle : ServerVehicle
|
||||||
{
|
{
|
||||||
public int JobId { get; set; }
|
public int JobId { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace ReallifeGamemode.Database.Entities
|
|||||||
public float Range { get; set; }
|
public float Range { get; set; }
|
||||||
public int Color { get; set; }
|
public int Color { get; set; }
|
||||||
public string Vector { get; set; } = null;
|
public string Vector { get; set; } = null;
|
||||||
public int Value {get; set;} = 0;
|
public int Value { get; set; } = 0;
|
||||||
public int MaxValue { get; set; } = 0;
|
public int MaxValue { get; set; } = 0;
|
||||||
public bool Surplus { get; set; } = false;
|
public bool Surplus { get; set; } = false;
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -3,31 +3,31 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
|
|
||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class ShopItems : Migration
|
public partial class ShopItems : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.CreateTable(
|
||||||
{
|
name: "ShopItems",
|
||||||
migrationBuilder.CreateTable(
|
columns: table => new
|
||||||
name: "ShopItems",
|
{
|
||||||
columns: table => new
|
Id = table.Column<int>(nullable: false)
|
||||||
{
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
Id = table.Column<int>(nullable: false)
|
ShopId = table.Column<int>(nullable: false),
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
ItemId = table.Column<int>(nullable: false),
|
||||||
ShopId = table.Column<int>(nullable: false),
|
Amount = table.Column<int>(nullable: false),
|
||||||
ItemId = table.Column<int>(nullable: false),
|
Price = table.Column<int>(nullable: false)
|
||||||
Amount = table.Column<int>(nullable: false),
|
},
|
||||||
Price = table.Column<int>(nullable: false)
|
constraints: table =>
|
||||||
},
|
{
|
||||||
constraints: table =>
|
table.PrimaryKey("PK_ShopItems", x => x.Id);
|
||||||
{
|
});
|
||||||
table.PrimaryKey("PK_ShopItems", x => x.Id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ShopItems");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ShopItems");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,22 +2,22 @@
|
|||||||
|
|
||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class UserWeaponLicense : Migration
|
public partial class UserWeaponLicense : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<bool>(
|
||||||
{
|
name: "WeaponLicense",
|
||||||
migrationBuilder.AddColumn<bool>(
|
table: "Users",
|
||||||
name: "WeaponLicense",
|
nullable: false,
|
||||||
table: "Users",
|
defaultValue: false);
|
||||||
nullable: false,
|
|
||||||
defaultValue: false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "WeaponLicense",
|
|
||||||
table: "Users");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "WeaponLicense",
|
||||||
|
table: "Users");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,21 +2,21 @@
|
|||||||
|
|
||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class VehicleAddPrice : Migration
|
public partial class VehicleAddPrice : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<int>(
|
||||||
{
|
name: "UserVehicle_Price",
|
||||||
migrationBuilder.AddColumn<int>(
|
table: "ServerVehicles",
|
||||||
name: "UserVehicle_Price",
|
nullable: true);
|
||||||
table: "ServerVehicles",
|
|
||||||
nullable: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "UserVehicle_Price",
|
|
||||||
table: "ServerVehicles");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "UserVehicle_Price",
|
||||||
|
table: "ServerVehicles");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,22 +3,22 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
|
|
||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class HouseWeeklyRentalFee : Migration
|
public partial class HouseWeeklyRentalFee : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<DateTime>(
|
||||||
{
|
name: "LastRentSetTime",
|
||||||
migrationBuilder.AddColumn<DateTime>(
|
table: "Houses",
|
||||||
name: "LastRentSetTime",
|
nullable: false,
|
||||||
table: "Houses",
|
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "LastRentSetTime",
|
||||||
|
table: "Houses");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,58 +3,58 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
|
|
||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class HouseBankAccounts : Migration
|
public partial class HouseBankAccounts : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<int>(
|
||||||
{
|
name: "BankAccountId",
|
||||||
migrationBuilder.AddColumn<int>(
|
table: "Houses",
|
||||||
name: "BankAccountId",
|
nullable: true);
|
||||||
table: "Houses",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "HouseBankAccounts",
|
name: "HouseBankAccounts",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<int>(nullable: false)
|
Id = table.Column<int>(nullable: false)
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
Balance = table.Column<int>(nullable: false)
|
Balance = table.Column<int>(nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_HouseBankAccounts", x => x.Id);
|
table.PrimaryKey("PK_HouseBankAccounts", x => x.Id);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Houses_BankAccountId",
|
name: "IX_Houses_BankAccountId",
|
||||||
table: "Houses",
|
table: "Houses",
|
||||||
column: "BankAccountId");
|
column: "BankAccountId");
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
migrationBuilder.AddForeignKey(
|
||||||
name: "FK_Houses_HouseBankAccounts_BankAccountId",
|
name: "FK_Houses_HouseBankAccounts_BankAccountId",
|
||||||
table: "Houses",
|
table: "Houses",
|
||||||
column: "BankAccountId",
|
column: "BankAccountId",
|
||||||
principalTable: "HouseBankAccounts",
|
principalTable: "HouseBankAccounts",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_Houses_HouseBankAccounts_BankAccountId",
|
|
||||||
table: "Houses");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "HouseBankAccounts");
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_Houses_BankAccountId",
|
|
||||||
table: "Houses");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "BankAccountId",
|
|
||||||
table: "Houses");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Houses_HouseBankAccounts_BankAccountId",
|
||||||
|
table: "Houses");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "HouseBankAccounts");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Houses_BankAccountId",
|
||||||
|
table: "Houses");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "BankAccountId",
|
||||||
|
table: "Houses");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,32 +2,32 @@
|
|||||||
|
|
||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class TurfSurplusValue : Migration
|
public partial class TurfSurplusValue : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<bool>(
|
||||||
{
|
name: "Surplus",
|
||||||
migrationBuilder.AddColumn<bool>(
|
table: "Turfs",
|
||||||
name: "Surplus",
|
nullable: false,
|
||||||
table: "Turfs",
|
defaultValue: false);
|
||||||
nullable: false,
|
|
||||||
defaultValue: false);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
migrationBuilder.AddColumn<int>(
|
||||||
name: "Value",
|
name: "Value",
|
||||||
table: "Turfs",
|
table: "Turfs",
|
||||||
nullable: false,
|
nullable: false,
|
||||||
defaultValue: 0);
|
defaultValue: 0);
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Surplus",
|
|
||||||
table: "Turfs");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Value",
|
|
||||||
table: "Turfs");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Surplus",
|
||||||
|
table: "Turfs");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Value",
|
||||||
|
table: "Turfs");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,22 +2,22 @@
|
|||||||
|
|
||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class TurfMaxValue : Migration
|
public partial class TurfMaxValue : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<int>(
|
||||||
{
|
name: "MaxValue",
|
||||||
migrationBuilder.AddColumn<int>(
|
table: "Turfs",
|
||||||
name: "MaxValue",
|
nullable: false,
|
||||||
table: "Turfs",
|
defaultValue: 0);
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "MaxValue",
|
|
||||||
table: "Turfs");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "MaxValue",
|
||||||
|
table: "Turfs");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,22 +2,22 @@
|
|||||||
|
|
||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class PedType : Migration
|
public partial class PedType : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<int>(
|
||||||
{
|
name: "Type",
|
||||||
migrationBuilder.AddColumn<int>(
|
table: "Peds",
|
||||||
name: "Type",
|
nullable: false,
|
||||||
table: "Peds",
|
defaultValue: 0);
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Type",
|
|
||||||
table: "Peds");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Type",
|
||||||
|
table: "Peds");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,22 +2,22 @@
|
|||||||
|
|
||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class UserPoints : Migration
|
public partial class UserPoints : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<int>(
|
||||||
{
|
name: "Points",
|
||||||
migrationBuilder.AddColumn<int>(
|
table: "Users",
|
||||||
name: "Points",
|
nullable: false,
|
||||||
table: "Users",
|
defaultValue: 0);
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Points",
|
|
||||||
table: "Users");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Points",
|
||||||
|
table: "Users");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace ReallifeGamemode.Server.Core.Commands
|
|||||||
|
|
||||||
logger.LogInformation("Player '{Name}' executed command '{command}'", player.Name, command);
|
logger.LogInformation("Player '{Name}' executed command '{command}'", player.Name, command);
|
||||||
|
|
||||||
if(legacyCommands.Contains(command))
|
if (legacyCommands.Contains(command))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,21 @@
|
|||||||
namespace ReallifeGamemode.Server.Business
|
namespace ReallifeGamemode.Server.Business
|
||||||
{
|
{
|
||||||
public class BikeDealerBusiness : CarDealerBusinessBase
|
public class BikeDealerBusiness : CarDealerBusinessBase
|
||||||
|
{
|
||||||
|
public override int Id => 8;
|
||||||
|
|
||||||
|
public override string Name => "Motorrad Shop";
|
||||||
|
|
||||||
|
public override Vector3 Position => new Vector3(1180.997, -394.9542, 68.01635);
|
||||||
|
|
||||||
|
public override Vector3 CarSpawnPositon => new Vector3(1148.25, -369.0642, 67.06199);
|
||||||
|
|
||||||
|
public override float CarSpawnHeading => 356.6f;
|
||||||
|
|
||||||
|
public override int? BlipSprite => 226;
|
||||||
|
|
||||||
|
public override void Load()
|
||||||
{
|
{
|
||||||
public override int Id => 8;
|
|
||||||
|
|
||||||
public override string Name => "Motorrad Shop";
|
|
||||||
|
|
||||||
public override Vector3 Position => new Vector3(1180.997, -394.9542, 68.01635);
|
|
||||||
|
|
||||||
public override Vector3 CarSpawnPositon => new Vector3(1148.25, -369.0642, 67.06199);
|
|
||||||
|
|
||||||
public override float CarSpawnHeading => 356.6f;
|
|
||||||
|
|
||||||
public override int? BlipSprite => 226;
|
|
||||||
|
|
||||||
public override void Load()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,21 @@
|
|||||||
namespace ReallifeGamemode.Server.Business
|
namespace ReallifeGamemode.Server.Business
|
||||||
{
|
{
|
||||||
public class BoatDealerBusiness : CarDealerBusinessBase
|
public class BoatDealerBusiness : CarDealerBusinessBase
|
||||||
|
{
|
||||||
|
public override int Id => 5;
|
||||||
|
|
||||||
|
public override string Name => "Boot Shop";
|
||||||
|
|
||||||
|
public override Vector3 Position => new Vector3(-712.2401, -1298.818, 5.101922);
|
||||||
|
|
||||||
|
public override Vector3 CarSpawnPositon => new Vector3(-792.5602, -1433.158, 1.333062);
|
||||||
|
|
||||||
|
public override float CarSpawnHeading => 356.6f;
|
||||||
|
|
||||||
|
public override int? BlipSprite => 410;
|
||||||
|
|
||||||
|
public override void Load()
|
||||||
{
|
{
|
||||||
public override int Id => 5;
|
|
||||||
|
|
||||||
public override string Name => "Boot Shop";
|
|
||||||
|
|
||||||
public override Vector3 Position => new Vector3(-712.2401, -1298.818, 5.101922);
|
|
||||||
|
|
||||||
public override Vector3 CarSpawnPositon => new Vector3(-792.5602, -1433.158, 1.333062);
|
|
||||||
|
|
||||||
public override float CarSpawnHeading => 356.6f;
|
|
||||||
|
|
||||||
public override int? BlipSprite => 410;
|
|
||||||
|
|
||||||
public override void Load()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,188 +10,188 @@ using ReallifeGamemode.Server.Extensions;
|
|||||||
namespace ReallifeGamemode.Server.Business
|
namespace ReallifeGamemode.Server.Business
|
||||||
{
|
{
|
||||||
public abstract class BusinessBase : BankAccountHolder<BusinessBankAccount>, IBankAccountOwner
|
public abstract class BusinessBase : BankAccountHolder<BusinessBankAccount>, IBankAccountOwner
|
||||||
|
{
|
||||||
|
private TextLabel _informationLabel;
|
||||||
|
private ColShape _colShape;
|
||||||
|
private Blip _blip;
|
||||||
|
private Marker _marker;
|
||||||
|
|
||||||
|
public virtual int? BlipSprite { get; } = null;
|
||||||
|
|
||||||
|
public abstract int Id { get; }
|
||||||
|
|
||||||
|
public abstract string Name { get; }
|
||||||
|
|
||||||
|
public abstract Vector3 Position { get; }
|
||||||
|
|
||||||
|
public override BusinessBankAccount BankAccount
|
||||||
{
|
{
|
||||||
private TextLabel _informationLabel;
|
get
|
||||||
private ColShape _colShape;
|
{
|
||||||
private Blip _blip;
|
using (var dbContext = new DatabaseContext())
|
||||||
private Marker _marker;
|
|
||||||
|
|
||||||
public virtual int? BlipSprite { get; } = null;
|
|
||||||
|
|
||||||
public abstract int Id { get; }
|
|
||||||
|
|
||||||
public abstract string Name { get; }
|
|
||||||
|
|
||||||
public abstract Vector3 Position { get; }
|
|
||||||
|
|
||||||
public override BusinessBankAccount BankAccount
|
|
||||||
{
|
{
|
||||||
get
|
return dbContext.BusinessBankAccounts.Where(b => b.BusinessId == this.Id).FirstOrDefault();
|
||||||
{
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
return dbContext.BusinessBankAccounts.Where(b => b.BusinessId == this.Id).FirstOrDefault();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
set => throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override int? BankAccountId
|
set => throw new NotImplementedException();
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
return dbContext.BusinessBankAccounts.Where(b => b.BusinessId == this.Id).Select(b => b.Id).FirstOrDefault();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
set => throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string BankAccountName => Name;
|
|
||||||
|
|
||||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
|
||||||
{
|
|
||||||
if (databaseContext == null)
|
|
||||||
{
|
|
||||||
using (databaseContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == Id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == Id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Setup()
|
|
||||||
{
|
|
||||||
_informationLabel = NAPI.TextLabel.CreateTextLabel(Name, Position.Add(new Vector3(0, 0, 0.5)), 20.0f, 1.3f, 0, new Color(255, 255, 255));
|
|
||||||
_marker = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, Position.Subtract(new Vector3(0, 0, 1.5)), new Vector3(), new Vector3(), 1f, new Color(255, 255, 255));
|
|
||||||
|
|
||||||
if (BlipSprite != null)
|
|
||||||
{
|
|
||||||
_blip = NAPI.Blip.CreateBlip(BlipSprite.Value, Position, 1f, 4, Name, shortRange: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
_colShape = NAPI.ColShape.CreateSphereColShape(Position.Subtract(new Vector3(0, 0, 1.5)), 3f);
|
|
||||||
_colShape.OnEntityEnterColShape += EntityEnterBusinessColShape;
|
|
||||||
_colShape.OnEntityExitColShape += EntityExitBusinessColShape;
|
|
||||||
|
|
||||||
if (GetBankAccount() == null)
|
|
||||||
{
|
|
||||||
NAPI.Util.ConsoleOutput("Creating Bank Account for Business: " + Name);
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
dbContext.BusinessBankAccounts.Add(new BusinessBankAccount()
|
|
||||||
{
|
|
||||||
BusinessId = Id,
|
|
||||||
Balance = 0
|
|
||||||
});
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BusinessData data = GetData();
|
|
||||||
|
|
||||||
if (data == null)
|
|
||||||
{
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
data = new BusinessData()
|
|
||||||
{
|
|
||||||
BusinessId = this.Id,
|
|
||||||
Price = -1
|
|
||||||
};
|
|
||||||
|
|
||||||
dbContext.BusinessData.Add(data);
|
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void EntityExitBusinessColShape(ColShape colShape, Player client)
|
|
||||||
{
|
|
||||||
client.TriggerEvent("SERVER:Business_RemoveHelp", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BusinessData GetData(DatabaseContext dbContext = null)
|
|
||||||
{
|
|
||||||
if (dbContext == null)
|
|
||||||
{
|
|
||||||
using (dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
return dbContext.BusinessData.Where(b => b.BusinessId == this.Id).FirstOrDefault();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return dbContext.BusinessData.Where(b => b.BusinessId == this.Id).FirstOrDefault();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void EntityEnterBusinessColShape(ColShape colShape, Player client)
|
|
||||||
{
|
|
||||||
if (client.IsInVehicle || !client.IsLoggedIn()) return;
|
|
||||||
|
|
||||||
SendBusinessDataToPlayer(client);
|
|
||||||
client.TriggerEvent("SERVER:Business_ShowMenuHelp");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SendBusinessDataToPlayer(Player player)
|
|
||||||
{
|
|
||||||
User owner = GetOwner();
|
|
||||||
|
|
||||||
int state = -1; // Keine Beziehung
|
|
||||||
|
|
||||||
if (owner == null) // Kein Besitzer
|
|
||||||
{
|
|
||||||
state = 0;
|
|
||||||
}
|
|
||||||
else if (owner.Id == player.GetUser()?.Id) // Besitzer
|
|
||||||
{
|
|
||||||
state = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var business = new
|
|
||||||
{
|
|
||||||
this.Name,
|
|
||||||
Price = this.GetData().Price.ToMoneyString(),
|
|
||||||
Balance = this.GetBankAccount().Balance.ToMoneyString()
|
|
||||||
};
|
|
||||||
|
|
||||||
player.TriggerEvent("SERVER:Business_SetData", JsonConvert.SerializeObject(business), state);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(int? money = null)
|
|
||||||
{
|
|
||||||
if (money == null) money = GetBankAccount()?.Balance ?? 0;
|
|
||||||
User owner = GetOwner();
|
|
||||||
string infoText = Name;
|
|
||||||
if (owner == null) infoText += "\n~g~Zum Verkauf\n~s~Preis: ~y~" + this.GetData().Price.ToMoneyString();
|
|
||||||
else infoText += $"\nBesitzer: ~g~{owner.Name}\n~s~Kasse: ~y~{money.ToMoneyString()}";
|
|
||||||
_informationLabel.Text = infoText;
|
|
||||||
}
|
|
||||||
|
|
||||||
public User GetOwner(DatabaseContext dbContext = null)
|
|
||||||
{
|
|
||||||
if (dbContext == null)
|
|
||||||
{
|
|
||||||
using (dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void Load();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override int? BankAccountId
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
return dbContext.BusinessBankAccounts.Where(b => b.BusinessId == this.Id).Select(b => b.Id).FirstOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set => throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string BankAccountName => Name;
|
||||||
|
|
||||||
|
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||||
|
{
|
||||||
|
if (databaseContext == null)
|
||||||
|
{
|
||||||
|
using (databaseContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
_informationLabel = NAPI.TextLabel.CreateTextLabel(Name, Position.Add(new Vector3(0, 0, 0.5)), 20.0f, 1.3f, 0, new Color(255, 255, 255));
|
||||||
|
_marker = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, Position.Subtract(new Vector3(0, 0, 1.5)), new Vector3(), new Vector3(), 1f, new Color(255, 255, 255));
|
||||||
|
|
||||||
|
if (BlipSprite != null)
|
||||||
|
{
|
||||||
|
_blip = NAPI.Blip.CreateBlip(BlipSprite.Value, Position, 1f, 4, Name, shortRange: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
_colShape = NAPI.ColShape.CreateSphereColShape(Position.Subtract(new Vector3(0, 0, 1.5)), 3f);
|
||||||
|
_colShape.OnEntityEnterColShape += EntityEnterBusinessColShape;
|
||||||
|
_colShape.OnEntityExitColShape += EntityExitBusinessColShape;
|
||||||
|
|
||||||
|
if (GetBankAccount() == null)
|
||||||
|
{
|
||||||
|
NAPI.Util.ConsoleOutput("Creating Bank Account for Business: " + Name);
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
dbContext.BusinessBankAccounts.Add(new BusinessBankAccount()
|
||||||
|
{
|
||||||
|
BusinessId = Id,
|
||||||
|
Balance = 0
|
||||||
|
});
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BusinessData data = GetData();
|
||||||
|
|
||||||
|
if (data == null)
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
data = new BusinessData()
|
||||||
|
{
|
||||||
|
BusinessId = this.Id,
|
||||||
|
Price = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
dbContext.BusinessData.Add(data);
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EntityExitBusinessColShape(ColShape colShape, Player client)
|
||||||
|
{
|
||||||
|
client.TriggerEvent("SERVER:Business_RemoveHelp", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BusinessData GetData(DatabaseContext dbContext = null)
|
||||||
|
{
|
||||||
|
if (dbContext == null)
|
||||||
|
{
|
||||||
|
using (dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
return dbContext.BusinessData.Where(b => b.BusinessId == this.Id).FirstOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return dbContext.BusinessData.Where(b => b.BusinessId == this.Id).FirstOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EntityEnterBusinessColShape(ColShape colShape, Player client)
|
||||||
|
{
|
||||||
|
if (client.IsInVehicle || !client.IsLoggedIn()) return;
|
||||||
|
|
||||||
|
SendBusinessDataToPlayer(client);
|
||||||
|
client.TriggerEvent("SERVER:Business_ShowMenuHelp");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SendBusinessDataToPlayer(Player player)
|
||||||
|
{
|
||||||
|
User owner = GetOwner();
|
||||||
|
|
||||||
|
int state = -1; // Keine Beziehung
|
||||||
|
|
||||||
|
if (owner == null) // Kein Besitzer
|
||||||
|
{
|
||||||
|
state = 0;
|
||||||
|
}
|
||||||
|
else if (owner.Id == player.GetUser()?.Id) // Besitzer
|
||||||
|
{
|
||||||
|
state = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var business = new
|
||||||
|
{
|
||||||
|
this.Name,
|
||||||
|
Price = this.GetData().Price.ToMoneyString(),
|
||||||
|
Balance = this.GetBankAccount().Balance.ToMoneyString()
|
||||||
|
};
|
||||||
|
|
||||||
|
player.TriggerEvent("SERVER:Business_SetData", JsonConvert.SerializeObject(business), state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(int? money = null)
|
||||||
|
{
|
||||||
|
if (money == null) money = GetBankAccount()?.Balance ?? 0;
|
||||||
|
User owner = GetOwner();
|
||||||
|
string infoText = Name;
|
||||||
|
if (owner == null) infoText += "\n~g~Zum Verkauf\n~s~Preis: ~y~" + this.GetData().Price.ToMoneyString();
|
||||||
|
else infoText += $"\nBesitzer: ~g~{owner.Name}\n~s~Kasse: ~y~{money.ToMoneyString()}";
|
||||||
|
_informationLabel.Text = infoText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User GetOwner(DatabaseContext dbContext = null)
|
||||||
|
{
|
||||||
|
if (dbContext == null)
|
||||||
|
{
|
||||||
|
using (dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void Load();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
namespace ReallifeGamemode.Server.Business
|
namespace ReallifeGamemode.Server.Business
|
||||||
{
|
{
|
||||||
public abstract class CarDealerBusinessBase : BusinessBase
|
public abstract class CarDealerBusinessBase : BusinessBase
|
||||||
{
|
{
|
||||||
public abstract Vector3 CarSpawnPositon { get; }
|
public abstract Vector3 CarSpawnPositon { get; }
|
||||||
public abstract float CarSpawnHeading { get; }
|
public abstract float CarSpawnHeading { get; }
|
||||||
|
|
||||||
public override int? BlipSprite => 225;
|
public override int? BlipSprite => 225;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,19 +3,19 @@
|
|||||||
namespace ReallifeGamemode.Server.Business
|
namespace ReallifeGamemode.Server.Business
|
||||||
{
|
{
|
||||||
internal class PremiumDeluxeMotorsportCarDealerBusiness : CarDealerBusinessBase
|
internal class PremiumDeluxeMotorsportCarDealerBusiness : CarDealerBusinessBase
|
||||||
|
{
|
||||||
|
public override Vector3 CarSpawnPositon => new Vector3(-59, -1108.1, 26.5);
|
||||||
|
|
||||||
|
public override float CarSpawnHeading => 90;
|
||||||
|
|
||||||
|
public override int Id => 4;
|
||||||
|
|
||||||
|
public override string Name => "Premium Deluxe Motorsport";
|
||||||
|
|
||||||
|
public override Vector3 Position => new Vector3(-31.56, -1113.5, 26.42);
|
||||||
|
|
||||||
|
public override void Load()
|
||||||
{
|
{
|
||||||
public override Vector3 CarSpawnPositon => new Vector3(-59, -1108.1, 26.5);
|
|
||||||
|
|
||||||
public override float CarSpawnHeading => 90;
|
|
||||||
|
|
||||||
public override int Id => 4;
|
|
||||||
|
|
||||||
public override string Name => "Premium Deluxe Motorsport";
|
|
||||||
|
|
||||||
public override Vector3 Position => new Vector3(-31.56, -1113.5, 26.42);
|
|
||||||
|
|
||||||
public override void Load()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,15 @@
|
|||||||
namespace ReallifeGamemode.Server.Business
|
namespace ReallifeGamemode.Server.Business
|
||||||
{
|
{
|
||||||
public class ShopBusiness : BusinessBase
|
public class ShopBusiness : BusinessBase
|
||||||
|
{
|
||||||
|
public override int Id => 2;
|
||||||
|
|
||||||
|
public override string Name => "24/7 Business";
|
||||||
|
|
||||||
|
public override Vector3 Position => new Vector3(-443, 1134, 326);
|
||||||
|
|
||||||
|
public override void Load()
|
||||||
{
|
{
|
||||||
public override int Id => 2;
|
|
||||||
|
|
||||||
public override string Name => "24/7 Business";
|
|
||||||
|
|
||||||
public override Vector3 Position => new Vector3(-443, 1134, 326);
|
|
||||||
|
|
||||||
public override void Load()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,15 @@
|
|||||||
namespace ReallifeGamemode.Server.Business
|
namespace ReallifeGamemode.Server.Business
|
||||||
{
|
{
|
||||||
public class TelefonBusiness : BusinessBase
|
public class TelefonBusiness : BusinessBase
|
||||||
|
{
|
||||||
|
public override int Id => 1;
|
||||||
|
|
||||||
|
public override string Name => "Telefon Business";
|
||||||
|
|
||||||
|
public override Vector3 Position => new Vector3(-423, 1130, 326);
|
||||||
|
|
||||||
|
public override void Load()
|
||||||
{
|
{
|
||||||
public override int Id => 1;
|
|
||||||
|
|
||||||
public override string Name => "Telefon Business";
|
|
||||||
|
|
||||||
public override Vector3 Position => new Vector3(-423, 1130, 326);
|
|
||||||
|
|
||||||
public override void Load()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,19 +3,19 @@
|
|||||||
namespace ReallifeGamemode.Server.Business
|
namespace ReallifeGamemode.Server.Business
|
||||||
{
|
{
|
||||||
public class VapidCarDealerBusiness : CarDealerBusinessBase
|
public class VapidCarDealerBusiness : CarDealerBusinessBase
|
||||||
|
{
|
||||||
|
public override int Id => 3;
|
||||||
|
|
||||||
|
public override string Name => "Vapid Autohaus";
|
||||||
|
|
||||||
|
public override Vector3 Position => new Vector3(-177, -1156, 23);
|
||||||
|
|
||||||
|
public override Vector3 CarSpawnPositon => new Vector3(-222, -1162, 22.5);
|
||||||
|
|
||||||
|
public override float CarSpawnHeading => 356.6f;
|
||||||
|
|
||||||
|
public override void Load()
|
||||||
{
|
{
|
||||||
public override int Id => 3;
|
|
||||||
|
|
||||||
public override string Name => "Vapid Autohaus";
|
|
||||||
|
|
||||||
public override Vector3 Position => new Vector3(-177, -1156, 23);
|
|
||||||
|
|
||||||
public override Vector3 CarSpawnPositon => new Vector3(-222, -1162, 22.5);
|
|
||||||
|
|
||||||
public override float CarSpawnHeading => 356.6f;
|
|
||||||
|
|
||||||
public override void Load()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
namespace ReallifeGamemode.Server.Classes
|
namespace ReallifeGamemode.Server.Classes
|
||||||
{
|
{
|
||||||
public class TempBlip
|
public class TempBlip
|
||||||
{
|
{
|
||||||
public byte Color { get; set; }
|
public byte Color { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public byte Transparency { get; set; }
|
public byte Transparency { get; set; }
|
||||||
public bool ShortRange { get; set; }
|
public bool ShortRange { get; set; }
|
||||||
public uint Sprite { get; set; }
|
public uint Sprite { get; set; }
|
||||||
public float Scale { get; set; }
|
public float Scale { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,25 +3,25 @@
|
|||||||
namespace ReallifeGamemode.Server.DrivingSchool
|
namespace ReallifeGamemode.Server.DrivingSchool
|
||||||
{
|
{
|
||||||
public class Licenses
|
public class Licenses
|
||||||
|
{
|
||||||
|
[JsonProperty("drivingLicenseCar")]
|
||||||
|
public bool CarLicense { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("drivingLicenseBike")]
|
||||||
|
public bool BikeLicense { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("flightLicensePlane")]
|
||||||
|
public bool PlaneLicense { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("weaponLicense")]
|
||||||
|
public bool WeaponLicense { get; set; }
|
||||||
|
|
||||||
|
public Licenses(bool CarLicense, bool BikeLicense, bool PlaneLicense, bool weaponLicense)
|
||||||
{
|
{
|
||||||
[JsonProperty("drivingLicenseCar")]
|
this.CarLicense = CarLicense;
|
||||||
public bool CarLicense { get; set; }
|
this.BikeLicense = BikeLicense;
|
||||||
|
this.PlaneLicense = PlaneLicense;
|
||||||
[JsonProperty("drivingLicenseBike")]
|
this.WeaponLicense = weaponLicense;
|
||||||
public bool BikeLicense { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("flightLicensePlane")]
|
|
||||||
public bool PlaneLicense { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("weaponLicense")]
|
|
||||||
public bool WeaponLicense { get; set; }
|
|
||||||
|
|
||||||
public Licenses(bool CarLicense, bool BikeLicense, bool PlaneLicense, bool weaponLicense)
|
|
||||||
{
|
|
||||||
this.CarLicense = CarLicense;
|
|
||||||
this.BikeLicense = BikeLicense;
|
|
||||||
this.PlaneLicense = PlaneLicense;
|
|
||||||
this.WeaponLicense = weaponLicense;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,16 +5,16 @@ using ReallifeGamemode.Server.Services;
|
|||||||
namespace ReallifeGamemode.Server.Events
|
namespace ReallifeGamemode.Server.Events
|
||||||
{
|
{
|
||||||
public class Chat : Script
|
public class Chat : Script
|
||||||
|
{
|
||||||
|
[ServerEvent(Event.ChatMessage)]
|
||||||
|
public void ChatEvent(Player player, string message)
|
||||||
{
|
{
|
||||||
[ServerEvent(Event.ChatMessage)]
|
string serverMsg = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||||
public void ChatEvent(Player player, string message)
|
if (serverMsg.Trim().Length == 0) return;
|
||||||
{
|
NAPI.Player.GetPlayersInRadiusOfPlayer(10, player).ForEach(p =>
|
||||||
string serverMsg = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
{
|
||||||
if (serverMsg.Trim().Length == 0) return;
|
ChatService.SendMessage(p, $"{player.Name} sagt: {serverMsg}");
|
||||||
NAPI.Player.GetPlayersInRadiusOfPlayer(10, player).ForEach(p =>
|
});
|
||||||
{
|
|
||||||
ChatService.SendMessage(p, $"{player.Name} sagt: {serverMsg}");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,49 +22,49 @@ using ReallifeGamemode.Server.Wanted;
|
|||||||
namespace ReallifeGamemode.Server.Events
|
namespace ReallifeGamemode.Server.Events
|
||||||
{
|
{
|
||||||
public class Death : Script
|
public class Death : Script
|
||||||
|
{
|
||||||
|
[ServerEvent(Event.PlayerDeath)]
|
||||||
|
public void OnPlayerDeath(Player player, Player killer, uint reason)
|
||||||
{
|
{
|
||||||
[ServerEvent(Event.PlayerDeath)]
|
if (!player.IsLoggedIn()) player.Kick();
|
||||||
public void OnPlayerDeath(Player player, Player killer, uint reason)
|
player.SetData("isDead", true);
|
||||||
|
|
||||||
|
//TODO: Zum Full Release entfernen
|
||||||
|
ChatService.SendMessage(player, "Du bist durch " + (killer?.Name ?? "Niemanden") + " gestorben: " + reason.ToString());
|
||||||
|
|
||||||
|
int? killerId;
|
||||||
|
float killerPosX;
|
||||||
|
float killerPosY;
|
||||||
|
float killerPosZ;
|
||||||
|
float killerHeading;
|
||||||
|
|
||||||
|
if (killer == null || killer.IsNull)
|
||||||
|
{
|
||||||
|
killerId = null;
|
||||||
|
killerPosX = -1;
|
||||||
|
killerPosY = -1;
|
||||||
|
killerPosZ = -1;
|
||||||
|
killerHeading = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
killerId = killer.GetUser().Id;
|
||||||
|
killerPosX = killer.Position.X;
|
||||||
|
killerPosY = killer.Position.Y;
|
||||||
|
killerPosZ = killer.Position.Z;
|
||||||
|
killerHeading = killer.Heading;
|
||||||
|
if (player.HasData("inGangWar") && killer.HasData("inGangWar"))
|
||||||
{
|
{
|
||||||
if (!player.IsLoggedIn()) player.Kick();
|
Gangwar.Gangwar.GangwarKill(killer, player);
|
||||||
player.SetData("isDead", true);
|
}
|
||||||
|
|
||||||
//TODO: Zum Full Release entfernen
|
if (player != killer)
|
||||||
ChatService.SendMessage(player, "Du bist durch " + (killer?.Name ?? "Niemanden") + " gestorben: " + reason.ToString());
|
{
|
||||||
|
Autowanted.Check_AutoWanted(killer, player);
|
||||||
int? killerId;
|
string message = "~y~[HINWEIS]: " + killer.Name + " hat " + player.Name + " getötet (" + Managers.WeaponManager.GetCauseOfDeathByHash(reason) + ")";
|
||||||
float killerPosX;
|
ChatService.BroadcastAdmin(message, AdminLevel.ADMIN);
|
||||||
float killerPosY;
|
}
|
||||||
float killerPosZ;
|
}
|
||||||
float killerHeading;
|
|
||||||
|
|
||||||
if (killer == null || killer.IsNull)
|
|
||||||
{
|
|
||||||
killerId = null;
|
|
||||||
killerPosX = -1;
|
|
||||||
killerPosY = -1;
|
|
||||||
killerPosZ = -1;
|
|
||||||
killerHeading = -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
killerId = killer.GetUser().Id;
|
|
||||||
killerPosX = killer.Position.X;
|
|
||||||
killerPosY = killer.Position.Y;
|
|
||||||
killerPosZ = killer.Position.Z;
|
|
||||||
killerHeading = killer.Heading;
|
|
||||||
if (player.HasData("inGangWar") && killer.HasData("inGangWar"))
|
|
||||||
{
|
|
||||||
Gangwar.Gangwar.GangwarKill(killer, player);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player != killer)
|
|
||||||
{
|
|
||||||
Autowanted.Check_AutoWanted(killer, player);
|
|
||||||
string message = "~y~[HINWEIS]: " + killer.Name + " hat " + player.Name + " getötet (" + Managers.WeaponManager.GetCauseOfDeathByHash(reason) + ")";
|
|
||||||
ChatService.BroadcastAdmin(message, AdminLevel.ADMIN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
User user = player.GetUser();
|
User user = player.GetUser();
|
||||||
if (user.JailTime <= 0)
|
if (user.JailTime <= 0)
|
||||||
@@ -83,75 +83,75 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
};
|
};
|
||||||
Medic.AddTaskToList(reviveTask);
|
Medic.AddTaskToList(reviveTask);
|
||||||
|
|
||||||
if (player.GetUser().IsAdmin(AdminLevel.ADMIN) == true)
|
if (player.GetUser().IsAdmin(AdminLevel.ADMIN) == true)
|
||||||
{
|
|
||||||
player.TriggerEvent("startDeathTimer", true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.TriggerEvent("startDeathTimer", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO PICTURE NOTIFICATION + SOUND für Medics
|
|
||||||
|
|
||||||
player.ClearAttachments();
|
|
||||||
|
|
||||||
using (var userDeath = new DatabaseContext())
|
|
||||||
{
|
|
||||||
List<UserItem> fItem = userDeath.UserItems.Where(u => u.UserId == user.Id).ToList();
|
|
||||||
foreach (var item in fItem)
|
|
||||||
{
|
|
||||||
IItem iItem = InventoryManager.GetItemById(item.ItemId);
|
|
||||||
if (iItem is IWeaponDealItem obj)
|
|
||||||
{
|
|
||||||
int amount = item.Amount;
|
|
||||||
|
|
||||||
Vector3 dropPosition = PlayerExtension.GetPositionFromPlayer(player, 0.6f, 0);
|
|
||||||
//new Vector3(player.Position.X, player.Position.Y, player.Position.Z - 0.8f);
|
|
||||||
Random r = new Random();
|
|
||||||
GTANetworkAPI.Object grndObject;
|
|
||||||
Vector3 textPos = dropPosition;
|
|
||||||
|
|
||||||
dropPosition.Z -= 1.05f;
|
|
||||||
grndObject = NAPI.Object.CreateObject(3666746839, dropPosition, new Vector3(0, 0, r.Next(0, 360)), 255, 0);
|
|
||||||
|
|
||||||
GroundItem grndItem = new GroundItem { ItemId = iItem.Id, Amount = amount, Position = dropPosition };
|
|
||||||
TextLabel grndTxtLbl = NAPI.TextLabel.CreateTextLabel(iItem.Name + " ~s~(~y~" + amount + "~s~)", textPos, 5, 0.5f, 4, new Color(255, 255, 255), false, 0);
|
|
||||||
GroundItem.AddGroundItem(grndItem, grndObject, grndTxtLbl);
|
|
||||||
|
|
||||||
userDeath.Remove(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var dead = new Database.Entities.Logs.Death
|
|
||||||
{
|
|
||||||
VictimId = player.GetUser().Id,
|
|
||||||
KillerId = killerId,
|
|
||||||
KillerPositionX = killerPosX,
|
|
||||||
KillerPositionY = killerPosY,
|
|
||||||
KillerPositionZ = killerPosZ,
|
|
||||||
KillerHeading = killerHeading,
|
|
||||||
VictimPositionX = player.Position.X,
|
|
||||||
VictimPositionY = player.Position.Y,
|
|
||||||
VictimPositionZ = player.Position.Z,
|
|
||||||
VictimHeading = player.Heading,
|
|
||||||
CauseOfDeath = reason.ToString()
|
|
||||||
};
|
|
||||||
userDeath.DeathLogs.Add(dead);
|
|
||||||
userDeath.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//JailTime.cs
|
|
||||||
Jail.Check_PutBehindBars(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("RespawnPlayerAtHospital")]
|
|
||||||
public void RespawnPlayerAtHospital(Player player)
|
|
||||||
{
|
{
|
||||||
player.SetData("isDead", false);
|
player.TriggerEvent("startDeathTimer", true);
|
||||||
player.RemoveAllWeapons();
|
|
||||||
NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5));
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.TriggerEvent("startDeathTimer", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO PICTURE NOTIFICATION + SOUND für Medics
|
||||||
|
|
||||||
|
player.ClearAttachments();
|
||||||
|
|
||||||
|
using (var userDeath = new DatabaseContext())
|
||||||
|
{
|
||||||
|
List<UserItem> fItem = userDeath.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||||
|
foreach (var item in fItem)
|
||||||
|
{
|
||||||
|
IItem iItem = InventoryManager.GetItemById(item.ItemId);
|
||||||
|
if (iItem is IWeaponDealItem obj)
|
||||||
|
{
|
||||||
|
int amount = item.Amount;
|
||||||
|
|
||||||
|
Vector3 dropPosition = PlayerExtension.GetPositionFromPlayer(player, 0.6f, 0);
|
||||||
|
//new Vector3(player.Position.X, player.Position.Y, player.Position.Z - 0.8f);
|
||||||
|
Random r = new Random();
|
||||||
|
GTANetworkAPI.Object grndObject;
|
||||||
|
Vector3 textPos = dropPosition;
|
||||||
|
|
||||||
|
dropPosition.Z -= 1.05f;
|
||||||
|
grndObject = NAPI.Object.CreateObject(3666746839, dropPosition, new Vector3(0, 0, r.Next(0, 360)), 255, 0);
|
||||||
|
|
||||||
|
GroundItem grndItem = new GroundItem { ItemId = iItem.Id, Amount = amount, Position = dropPosition };
|
||||||
|
TextLabel grndTxtLbl = NAPI.TextLabel.CreateTextLabel(iItem.Name + " ~s~(~y~" + amount + "~s~)", textPos, 5, 0.5f, 4, new Color(255, 255, 255), false, 0);
|
||||||
|
GroundItem.AddGroundItem(grndItem, grndObject, grndTxtLbl);
|
||||||
|
|
||||||
|
userDeath.Remove(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var dead = new Database.Entities.Logs.Death
|
||||||
|
{
|
||||||
|
VictimId = player.GetUser().Id,
|
||||||
|
KillerId = killerId,
|
||||||
|
KillerPositionX = killerPosX,
|
||||||
|
KillerPositionY = killerPosY,
|
||||||
|
KillerPositionZ = killerPosZ,
|
||||||
|
KillerHeading = killerHeading,
|
||||||
|
VictimPositionX = player.Position.X,
|
||||||
|
VictimPositionY = player.Position.Y,
|
||||||
|
VictimPositionZ = player.Position.Z,
|
||||||
|
VictimHeading = player.Heading,
|
||||||
|
CauseOfDeath = reason.ToString()
|
||||||
|
};
|
||||||
|
userDeath.DeathLogs.Add(dead);
|
||||||
|
userDeath.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//JailTime.cs
|
||||||
|
Jail.Check_PutBehindBars(player);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
[RemoteEvent("RespawnPlayerAtHospital")]
|
||||||
|
public void RespawnPlayerAtHospital(Player player)
|
||||||
|
{
|
||||||
|
player.SetData("isDead", false);
|
||||||
|
player.RemoveAllWeapons();
|
||||||
|
NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,50 +16,50 @@ using ReallifeGamemode.Server.Util;
|
|||||||
namespace ReallifeGamemode.Server.Events
|
namespace ReallifeGamemode.Server.Events
|
||||||
{
|
{
|
||||||
public class Disconnect : Script
|
public class Disconnect : Script
|
||||||
|
{
|
||||||
|
[ServerEvent(Event.PlayerDisconnected)]
|
||||||
|
public void OnPlayerDisconnected(Player player, DisconnectionType type, string reason)
|
||||||
{
|
{
|
||||||
[ServerEvent(Event.PlayerDisconnected)]
|
if (!player.IsLoggedIn()) return;
|
||||||
public void OnPlayerDisconnected(Player player, DisconnectionType type, string reason)
|
|
||||||
{
|
|
||||||
if (!player.IsLoggedIn()) return;
|
|
||||||
|
|
||||||
if (type == DisconnectionType.Left)
|
if (type == DisconnectionType.Left)
|
||||||
{
|
{
|
||||||
NAPI.Util.ConsoleOutput(player.Name + " left");
|
NAPI.Util.ConsoleOutput(player.Name + " left");
|
||||||
}
|
}
|
||||||
if (type == DisconnectionType.Kicked)
|
if (type == DisconnectionType.Kicked)
|
||||||
{
|
{
|
||||||
NAPI.Util.ConsoleOutput(player.Name + " kicked");
|
NAPI.Util.ConsoleOutput(player.Name + " kicked");
|
||||||
}
|
}
|
||||||
if (type == DisconnectionType.Timeout)
|
if (type == DisconnectionType.Timeout)
|
||||||
{
|
{
|
||||||
NAPI.Util.ConsoleOutput(player.Name + " Timeoutet");
|
NAPI.Util.ConsoleOutput(player.Name + " Timeoutet");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GlobalHelper.DutyAdmins.Contains(player))
|
if (GlobalHelper.DutyAdmins.Contains(player))
|
||||||
{
|
{
|
||||||
GlobalHelper.DutyAdmins.Remove(player);
|
GlobalHelper.DutyAdmins.Remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.GetUser().IsAdmin(AdminLevel.MAPPING))
|
if (player.GetUser().IsAdmin(AdminLevel.MAPPING))
|
||||||
{
|
{
|
||||||
ChatService.BroadcastAdmin("!{#FFFF00}*** " + player.Name + " hat den Server verlassen", AdminLevel.MAPPING);
|
ChatService.BroadcastAdmin("!{#FFFF00}*** " + player.Name + " hat den Server verlassen", AdminLevel.MAPPING);
|
||||||
}
|
}
|
||||||
|
|
||||||
JobBase job = JobManager.GetJob(player.GetUser().JobId ?? -1);
|
JobBase job = JobManager.GetJob(player.GetUser().JobId ?? -1);
|
||||||
if (job != null) job.StopJob(player, true);
|
if (job != null) job.StopJob(player, true);
|
||||||
|
|
||||||
using (var saveUser = new DatabaseContext())
|
using (var saveUser = new DatabaseContext())
|
||||||
{
|
{
|
||||||
var user = player.GetUser(saveUser);
|
var user = player.GetUser(saveUser);
|
||||||
Vector3 pos = player.Position;
|
Vector3 pos = player.Position;
|
||||||
|
|
||||||
user.PositionX = pos.X;
|
user.PositionX = pos.X;
|
||||||
user.PositionY = pos.Y;
|
user.PositionY = pos.Y;
|
||||||
user.PositionZ = pos.Z;
|
user.PositionZ = pos.Z;
|
||||||
saveUser.SaveChanges();
|
saveUser.SaveChanges();
|
||||||
user.Dead = player.HasData("isDead") ? (bool)player.GetData<bool>("isDead") : false;
|
user.Dead = player.HasData("isDead") ? (bool)player.GetData<bool>("isDead") : false;
|
||||||
}
|
}
|
||||||
player.SetData("isLoggedIn", false);
|
player.SetData("isLoggedIn", false);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,49 +8,49 @@ using ReallifeGamemode.Server.WeaponDeal;
|
|||||||
namespace ReallifeGamemode.Server.Events
|
namespace ReallifeGamemode.Server.Events
|
||||||
{
|
{
|
||||||
public class EnterVehicleAttempt : Script
|
public class EnterVehicleAttempt : Script
|
||||||
|
{
|
||||||
|
[ServerEvent(Event.PlayerEnterVehicleAttempt)]
|
||||||
|
public void OnPlayerEnterVehicleAttempt(Player player, GTANetworkAPI.Vehicle vehicle, sbyte seat)
|
||||||
{
|
{
|
||||||
[ServerEvent(Event.PlayerEnterVehicleAttempt)]
|
if ((VehicleHash)vehicle.Model == VehicleHash.Dune3)
|
||||||
public void OnPlayerEnterVehicleAttempt(Player player, GTANetworkAPI.Vehicle vehicle, sbyte seat)
|
{
|
||||||
|
if (seat == 1) seat = 0;
|
||||||
|
else if (seat == 0) seat = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (seat != 0) return;
|
||||||
|
|
||||||
|
User u = player.GetUser();
|
||||||
|
|
||||||
|
if (vehicle.GetServerVehicle() is FactionVehicle veh)
|
||||||
|
{
|
||||||
|
if (!veh.GetOwners().Contains(player.GetUser().FactionId ?? 0) && !(u.IsAdmin(AdminLevel.HEADADMIN) && GlobalHelper.DutyAdmins.Contains(player)))
|
||||||
{
|
{
|
||||||
if ((VehicleHash)vehicle.Model == VehicleHash.Dune3)
|
if ((VehicleHash)vehicle.Model == VehicleHash.Burrito3)
|
||||||
{
|
{
|
||||||
if (seat == 1) seat = 0;
|
if (WeaponDealManager.checkWeaponDbyVehicle(vehicle))
|
||||||
else if (seat == 0) seat = 1;
|
return;
|
||||||
}
|
}
|
||||||
|
player.StopAnimation();
|
||||||
if (seat != 0) return;
|
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||||
|
return;
|
||||||
User u = player.GetUser();
|
|
||||||
|
|
||||||
if (vehicle.GetServerVehicle() is FactionVehicle veh)
|
|
||||||
{
|
|
||||||
if (!veh.GetOwners().Contains(player.GetUser().FactionId ?? 0) && !(u.IsAdmin(AdminLevel.HEADADMIN) && GlobalHelper.DutyAdmins.Contains(player)))
|
|
||||||
{
|
|
||||||
if ((VehicleHash)vehicle.Model == VehicleHash.Burrito3)
|
|
||||||
{
|
|
||||||
if (WeaponDealManager.checkWeaponDbyVehicle(vehicle))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
player.StopAnimation();
|
|
||||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (vehicle.GetServerVehicle() is SchoolVehicle sVeh)
|
|
||||||
{
|
|
||||||
if (!player.HasData("ActiveSchool"))
|
|
||||||
{
|
|
||||||
player.StopAnimation();
|
|
||||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (sVeh.SchoolId != player.GetData<int>("ActiveSchool"))
|
|
||||||
{
|
|
||||||
player.StopAnimation();
|
|
||||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (vehicle.GetServerVehicle() is SchoolVehicle sVeh)
|
||||||
|
{
|
||||||
|
if (!player.HasData("ActiveSchool"))
|
||||||
|
{
|
||||||
|
player.StopAnimation();
|
||||||
|
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (sVeh.SchoolId != player.GetData<int>("ActiveSchool"))
|
||||||
|
{
|
||||||
|
player.StopAnimation();
|
||||||
|
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,65 +11,65 @@ using ReallifeGamemode.Server.Util;
|
|||||||
namespace ReallifeGamemode.Server.Events
|
namespace ReallifeGamemode.Server.Events
|
||||||
{
|
{
|
||||||
public class Inventory : Script
|
public class Inventory : Script
|
||||||
|
{
|
||||||
|
[RemoteEvent("getNearVehicles")]
|
||||||
|
public void SrvEvent_GetNearVehicles(Player client)
|
||||||
{
|
{
|
||||||
[RemoteEvent("getNearVehicles")]
|
var user = client.GetUser();
|
||||||
public void SrvEvent_GetNearVehicles(Player client)
|
if (!client.IsInVehicle)
|
||||||
|
{
|
||||||
|
using (var context = new DatabaseContext())
|
||||||
{
|
{
|
||||||
var user = client.GetUser();
|
foreach (GTANetworkAPI.Vehicle veh in NAPI.Pools.GetAllVehicles())
|
||||||
if (!client.IsInVehicle)
|
{
|
||||||
{
|
|
||||||
using (var context = new DatabaseContext())
|
|
||||||
{
|
|
||||||
foreach (GTANetworkAPI.Vehicle veh in NAPI.Pools.GetAllVehicles())
|
|
||||||
{
|
|
||||||
List<VehicleInventory> vehicleInventory = new List<VehicleInventory>();
|
|
||||||
if (veh.Position.DistanceTo(client.Position) < 5f)
|
|
||||||
{
|
|
||||||
if (VehicleStreaming.GetDoorState(veh, DoorID.DoorTrunk) == DoorState.DoorOpen || VehicleStreaming.GetDoorState(veh, DoorID.DoorRearLeft) == DoorState.DoorOpen || VehicleStreaming.GetDoorState(veh, DoorID.DoorRearRight) == DoorState.DoorOpen)
|
|
||||||
{
|
|
||||||
vehicleInventory = getVehItem(veh);
|
|
||||||
}
|
|
||||||
client.TriggerEvent("setVehiclesInventory", vehicleInventory.ToArray());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<VehicleInventory> getVehItem(GTANetworkAPI.Vehicle veh)
|
|
||||||
{
|
|
||||||
List<string> iName = new List<string>();
|
|
||||||
List<int> iAmount = new List<int>();
|
|
||||||
List<int> iId = new List<int>();
|
|
||||||
List<VehicleInventory> vehicleInventory = new List<VehicleInventory>();
|
List<VehicleInventory> vehicleInventory = new List<VehicleInventory>();
|
||||||
var inventoryWeight = 0;
|
if (veh.Position.DistanceTo(client.Position) < 5f)
|
||||||
using (var context = new DatabaseContext())
|
|
||||||
{
|
{
|
||||||
ServerVehicle serverVehicle = VehicleManager.GetServerVehicleFromVehicle(veh, context);
|
if (VehicleStreaming.GetDoorState(veh, DoorID.DoorTrunk) == DoorState.DoorOpen || VehicleStreaming.GetDoorState(veh, DoorID.DoorRearLeft) == DoorState.DoorOpen || VehicleStreaming.GetDoorState(veh, DoorID.DoorRearRight) == DoorState.DoorOpen)
|
||||||
List<VehicleItem> vehicleItems = context.VehicleItems.ToList().FindAll(i => i.VehicleId == serverVehicle.Id);
|
{
|
||||||
foreach (var vehItem in vehicleItems)
|
vehicleInventory = getVehItem(veh);
|
||||||
{
|
}
|
||||||
IItem iItem = InventoryManager.GetItemById(vehItem.ItemId);
|
client.TriggerEvent("setVehiclesInventory", vehicleInventory.ToArray());
|
||||||
var currentItemWeight = iItem.Gewicht * vehItem.Amount;
|
return;
|
||||||
inventoryWeight += currentItemWeight;
|
|
||||||
|
|
||||||
iName.Add(iItem.Name);
|
|
||||||
iAmount.Add(vehItem.Amount);
|
|
||||||
iId.Add(iItem.Id);
|
|
||||||
}
|
|
||||||
var vehInv = new VehicleInventory
|
|
||||||
{
|
|
||||||
ID = serverVehicle.Id,
|
|
||||||
currentWeight = inventoryWeight,
|
|
||||||
totalWeight = 250,
|
|
||||||
ivehName = iName.ToArray(),
|
|
||||||
ivehAmount = iAmount.ToArray(),
|
|
||||||
ivehId = iId.ToArray()
|
|
||||||
};
|
|
||||||
vehicleInventory.Add(vehInv);
|
|
||||||
}
|
}
|
||||||
return vehicleInventory;
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<VehicleInventory> getVehItem(GTANetworkAPI.Vehicle veh)
|
||||||
|
{
|
||||||
|
List<string> iName = new List<string>();
|
||||||
|
List<int> iAmount = new List<int>();
|
||||||
|
List<int> iId = new List<int>();
|
||||||
|
List<VehicleInventory> vehicleInventory = new List<VehicleInventory>();
|
||||||
|
var inventoryWeight = 0;
|
||||||
|
using (var context = new DatabaseContext())
|
||||||
|
{
|
||||||
|
ServerVehicle serverVehicle = VehicleManager.GetServerVehicleFromVehicle(veh, context);
|
||||||
|
List<VehicleItem> vehicleItems = context.VehicleItems.ToList().FindAll(i => i.VehicleId == serverVehicle.Id);
|
||||||
|
foreach (var vehItem in vehicleItems)
|
||||||
|
{
|
||||||
|
IItem iItem = InventoryManager.GetItemById(vehItem.ItemId);
|
||||||
|
var currentItemWeight = iItem.Gewicht * vehItem.Amount;
|
||||||
|
inventoryWeight += currentItemWeight;
|
||||||
|
|
||||||
|
iName.Add(iItem.Name);
|
||||||
|
iAmount.Add(vehItem.Amount);
|
||||||
|
iId.Add(iItem.Id);
|
||||||
|
}
|
||||||
|
var vehInv = new VehicleInventory
|
||||||
|
{
|
||||||
|
ID = serverVehicle.Id,
|
||||||
|
currentWeight = inventoryWeight,
|
||||||
|
totalWeight = 250,
|
||||||
|
ivehName = iName.ToArray(),
|
||||||
|
ivehAmount = iAmount.ToArray(),
|
||||||
|
ivehId = iId.ToArray()
|
||||||
|
};
|
||||||
|
vehicleInventory.Add(vehInv);
|
||||||
|
}
|
||||||
|
return vehicleInventory;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,141 +19,141 @@ using ReallifeGamemode.Server.Wanted;
|
|||||||
namespace ReallifeGamemode.Server.Events
|
namespace ReallifeGamemode.Server.Events
|
||||||
{
|
{
|
||||||
public class Login : Script
|
public class Login : Script
|
||||||
|
{
|
||||||
|
[RemoteEvent("CLIENT:Login_LoginRequest")]
|
||||||
|
public void OnPlayerLogin(Player player, string username, string password)
|
||||||
{
|
{
|
||||||
[RemoteEvent("CLIENT:Login_LoginRequest")]
|
using (var dbContext = new DatabaseContext())
|
||||||
public void OnPlayerLogin(Player player, string username, string password)
|
{
|
||||||
|
var user = dbContext.Users
|
||||||
|
.Include(u => u.Group)
|
||||||
|
.Include(u => u.BankAccount)
|
||||||
|
.SingleOrDefault(b => b.Name == username);
|
||||||
|
|
||||||
|
if (user == null)
|
||||||
{
|
{
|
||||||
using (var dbContext = new DatabaseContext())
|
player.TriggerEvent("SERVER:Login_Error", "Benutzer existiert nicht! Registriere dich zuerst!");
|
||||||
{
|
|
||||||
var user = dbContext.Users
|
|
||||||
.Include(u => u.Group)
|
|
||||||
.Include(u => u.BankAccount)
|
|
||||||
.SingleOrDefault(b => b.Name == username);
|
|
||||||
|
|
||||||
if (user == null)
|
|
||||||
{
|
|
||||||
player.TriggerEvent("SERVER:Login_Error", "Benutzer existiert nicht! Registriere dich zuerst!");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (user.SocialClubName != player.SocialClubName && user.Password == NAPI.Util.GetHashSha256(password))
|
|
||||||
{
|
|
||||||
player.TriggerEvent("SERVER:Login_Error", "Dieser Benutzer gehört dir nicht!");
|
|
||||||
//TODO ?? Log einbauen für den bösen Bub.
|
|
||||||
player.Kick();
|
|
||||||
}
|
|
||||||
if (user.Password != NAPI.Util.GetHashSha256(password))
|
|
||||||
{
|
|
||||||
player.TriggerEvent("SERVER:Login_Error", "Passwort inkorrekt!");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.Name = username;
|
|
||||||
player.TriggerEvent("SERVER:Login_Success");
|
|
||||||
player.SetData("isLoggedIn", true);
|
|
||||||
player.SetSharedData("isLoggedIn", JsonConvert.SerializeObject(true));
|
|
||||||
player.SetData("spec", true);
|
|
||||||
player.SetData("duty", false);
|
|
||||||
player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0);
|
|
||||||
Gangwar.Gangwar.loadPlayer(player);
|
|
||||||
if (user.FactionLeader)
|
|
||||||
{
|
|
||||||
player.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
|
||||||
}
|
|
||||||
if (user.IsAdmin(AdminLevel.HEADADMIN))
|
|
||||||
{
|
|
||||||
player.SetData("editmode", false);
|
|
||||||
player.SetData("quicksavemode", "none");
|
|
||||||
}
|
|
||||||
|
|
||||||
var userBankAccount = user.BankAccount;
|
|
||||||
userBankAccount.Balance = userBankAccount.Balance;
|
|
||||||
|
|
||||||
user.Wanteds = user.Wanteds;
|
|
||||||
|
|
||||||
if (user.Group != null)
|
|
||||||
{
|
|
||||||
string msg = $"{player.Name} ist wieder online.";
|
|
||||||
ChatService.BroadcastGroup(msg, user.Group);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GlobalHelper.CustomJoinMessages.ContainsKey(player.SocialClubName))
|
|
||||||
{
|
|
||||||
ChatService.BroadcastAdmin("!{#FFFF00}*** " + GlobalHelper.CustomJoinMessages[player.SocialClubName] + " [ID: " + player.Handle.Value + "] (" + user.AdminLevel.GetName() + ")", AdminLevel.MAPPING);
|
|
||||||
}
|
|
||||||
else if (user.IsAdmin(AdminLevel.MAPPING))
|
|
||||||
{
|
|
||||||
ChatService.BroadcastAdmin("!{#FFFF00}*** " + user.Name + " [ID: " + player.Handle.Value + "]" + " hat sich als " + user.AdminLevel.GetName() + " eingeloggt!", AdminLevel.MAPPING);
|
|
||||||
}
|
|
||||||
|
|
||||||
var userItems = dbContext.UserItems.Where(u => u.UserId == user.Id).ToList();
|
|
||||||
player.SetData("items", userItems);
|
|
||||||
|
|
||||||
switch (user.FactionId)
|
|
||||||
{
|
|
||||||
case null:
|
|
||||||
player.SetSharedData("blipColor", 0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 8:
|
|
||||||
player.SetSharedData("blipColor", 83);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 7:
|
|
||||||
player.SetSharedData("blipColor", 52);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
player.SetSharedData("blipColor", 5);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user.CharacterId == null)
|
|
||||||
{
|
|
||||||
var currentPlayerCreatorDimension = (uint)NAPI.Data.GetWorldData("playerCreatorDimension");
|
|
||||||
currentPlayerCreatorDimension++;
|
|
||||||
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
|
|
||||||
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
|
|
||||||
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
|
|
||||||
player.Rotation = new Vector3(0, 0, 180);
|
|
||||||
player.TriggerEvent("toggleCreator");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CharacterCreator.ApplyCharacter(player);
|
|
||||||
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
|
||||||
if (user.JailTime <= 0)
|
|
||||||
{
|
|
||||||
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Jail.Check_PutBehindBars(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
|
||||||
if (user.Dead == true)
|
|
||||||
{
|
|
||||||
if (user.IsAdmin(AdminLevel.ADMIN) == true)
|
|
||||||
{
|
|
||||||
player.TriggerEvent("startDeathTimer", true);
|
|
||||||
player.Health = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.TriggerEvent("startDeathTimer", false);
|
|
||||||
player.Health = 0;
|
|
||||||
}
|
|
||||||
player.SetData("isDead", true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.SetData("isDead", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (user.SocialClubName != player.SocialClubName && user.Password == NAPI.Util.GetHashSha256(password))
|
||||||
|
{
|
||||||
|
player.TriggerEvent("SERVER:Login_Error", "Dieser Benutzer gehört dir nicht!");
|
||||||
|
//TODO ?? Log einbauen für den bösen Bub.
|
||||||
|
player.Kick();
|
||||||
|
}
|
||||||
|
if (user.Password != NAPI.Util.GetHashSha256(password))
|
||||||
|
{
|
||||||
|
player.TriggerEvent("SERVER:Login_Error", "Passwort inkorrekt!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.Name = username;
|
||||||
|
player.TriggerEvent("SERVER:Login_Success");
|
||||||
|
player.SetData("isLoggedIn", true);
|
||||||
|
player.SetSharedData("isLoggedIn", JsonConvert.SerializeObject(true));
|
||||||
|
player.SetData("spec", true);
|
||||||
|
player.SetData("duty", false);
|
||||||
|
player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0);
|
||||||
|
Gangwar.Gangwar.loadPlayer(player);
|
||||||
|
if (user.FactionLeader)
|
||||||
|
{
|
||||||
|
player.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
||||||
|
}
|
||||||
|
if (user.IsAdmin(AdminLevel.HEADADMIN))
|
||||||
|
{
|
||||||
|
player.SetData("editmode", false);
|
||||||
|
player.SetData("quicksavemode", "none");
|
||||||
|
}
|
||||||
|
|
||||||
|
var userBankAccount = user.BankAccount;
|
||||||
|
userBankAccount.Balance = userBankAccount.Balance;
|
||||||
|
|
||||||
|
user.Wanteds = user.Wanteds;
|
||||||
|
|
||||||
|
if (user.Group != null)
|
||||||
|
{
|
||||||
|
string msg = $"{player.Name} ist wieder online.";
|
||||||
|
ChatService.BroadcastGroup(msg, user.Group);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GlobalHelper.CustomJoinMessages.ContainsKey(player.SocialClubName))
|
||||||
|
{
|
||||||
|
ChatService.BroadcastAdmin("!{#FFFF00}*** " + GlobalHelper.CustomJoinMessages[player.SocialClubName] + " [ID: " + player.Handle.Value + "] (" + user.AdminLevel.GetName() + ")", AdminLevel.MAPPING);
|
||||||
|
}
|
||||||
|
else if (user.IsAdmin(AdminLevel.MAPPING))
|
||||||
|
{
|
||||||
|
ChatService.BroadcastAdmin("!{#FFFF00}*** " + user.Name + " [ID: " + player.Handle.Value + "]" + " hat sich als " + user.AdminLevel.GetName() + " eingeloggt!", AdminLevel.MAPPING);
|
||||||
|
}
|
||||||
|
|
||||||
|
var userItems = dbContext.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||||
|
player.SetData("items", userItems);
|
||||||
|
|
||||||
|
switch (user.FactionId)
|
||||||
|
{
|
||||||
|
case null:
|
||||||
|
player.SetSharedData("blipColor", 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
player.SetSharedData("blipColor", 83);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 7:
|
||||||
|
player.SetSharedData("blipColor", 52);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
player.SetSharedData("blipColor", 5);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user.CharacterId == null)
|
||||||
|
{
|
||||||
|
var currentPlayerCreatorDimension = (uint)NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||||
|
currentPlayerCreatorDimension++;
|
||||||
|
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
|
||||||
|
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||||
|
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
|
||||||
|
player.Rotation = new Vector3(0, 0, 180);
|
||||||
|
player.TriggerEvent("toggleCreator");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CharacterCreator.ApplyCharacter(player);
|
||||||
|
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||||
|
if (user.JailTime <= 0)
|
||||||
|
{
|
||||||
|
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Jail.Check_PutBehindBars(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||||
|
if (user.Dead == true)
|
||||||
|
{
|
||||||
|
if (user.IsAdmin(AdminLevel.ADMIN) == true)
|
||||||
|
{
|
||||||
|
player.TriggerEvent("startDeathTimer", true);
|
||||||
|
player.Health = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.TriggerEvent("startDeathTimer", false);
|
||||||
|
player.Health = 0;
|
||||||
|
}
|
||||||
|
player.SetData("isDead", true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.SetData("isDead", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,24 +11,24 @@ using ReallifeGamemode.Database.Models;
|
|||||||
namespace ReallifeGamemode.Server.Events
|
namespace ReallifeGamemode.Server.Events
|
||||||
{
|
{
|
||||||
public class ResourceStop : Script
|
public class ResourceStop : Script
|
||||||
|
{
|
||||||
|
[ServerEvent(Event.ResourceStop)]
|
||||||
|
public void OnResourceStop()
|
||||||
{
|
{
|
||||||
[ServerEvent(Event.ResourceStop)]
|
var users = NAPI.Pools.GetAllPlayers();
|
||||||
public void OnResourceStop()
|
|
||||||
|
foreach (Player user in users)
|
||||||
|
{
|
||||||
|
using (var saveUsers = new DatabaseContext())
|
||||||
{
|
{
|
||||||
var users = NAPI.Pools.GetAllPlayers();
|
var saveUser = saveUsers.Users.SingleOrDefault(u => u.Name == user.Name);
|
||||||
|
|
||||||
foreach (Player user in users)
|
saveUser.PositionX = user.Position.X;
|
||||||
{
|
saveUser.PositionY = user.Position.Y;
|
||||||
using (var saveUsers = new DatabaseContext())
|
saveUser.PositionZ = user.Position.Z;
|
||||||
{
|
saveUsers.SaveChanges();
|
||||||
var saveUser = saveUsers.Users.SingleOrDefault(u => u.Name == user.Name);
|
|
||||||
|
|
||||||
saveUser.PositionX = user.Position.X;
|
|
||||||
saveUser.PositionY = user.Position.Y;
|
|
||||||
saveUser.PositionZ = user.Position.Z;
|
|
||||||
saveUsers.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,253 +9,253 @@ using ReallifeGamemode.Server.Extensions;
|
|||||||
namespace ReallifeGamemode.Server.Events
|
namespace ReallifeGamemode.Server.Events
|
||||||
{
|
{
|
||||||
public class UpdateCharacterCloth : Script
|
public class UpdateCharacterCloth : Script
|
||||||
|
{
|
||||||
|
[RemoteEvent("updateDutyProp")]
|
||||||
|
public void UpdateDutyProp(Player player, int componentId, int componentVariation)
|
||||||
{
|
{
|
||||||
[RemoteEvent("updateDutyProp")]
|
if (componentId != -1)
|
||||||
public void UpdateDutyProp(Player player, int componentId, int componentVariation)
|
{
|
||||||
{
|
player.SetAccessories(componentId, componentVariation, 0);
|
||||||
if (componentId != -1)
|
}
|
||||||
{
|
else
|
||||||
player.SetAccessories(componentId, componentVariation, 0);
|
{
|
||||||
}
|
player.ClearAccessory(0);
|
||||||
else
|
player.ClearAccessory(1);
|
||||||
{
|
player.ClearAccessory(2);
|
||||||
player.ClearAccessory(0);
|
}
|
||||||
player.ClearAccessory(1);
|
|
||||||
player.ClearAccessory(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("updateDutyCloth")]
|
|
||||||
public void UpdateDutyCloth(Player player, int componentId, int componentVariation)
|
|
||||||
{
|
|
||||||
if (componentId == 11)
|
|
||||||
{
|
|
||||||
//TODO Spezielle Duty Kleidung in Datenbank einpflegen (Ergibt bei Cop-Kleidung NULL)
|
|
||||||
using (var context = new DatabaseContext())
|
|
||||||
{
|
|
||||||
var character = player.GetUser().GetCharacter();
|
|
||||||
|
|
||||||
var combination = context.ClothCombinations.FirstOrDefault(c => c.Top == componentVariation && c.Gender == character.Gender);
|
|
||||||
player.SetClothes(11, componentVariation, 0);
|
|
||||||
if (combination != null)
|
|
||||||
{
|
|
||||||
player.SetClothes(3, combination.Torso, 0);
|
|
||||||
player.SetClothes(8, combination.Undershirt, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.SetClothes(componentId, componentVariation, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("saveCharacterCloth")]
|
|
||||||
public void SaveDutyCloth(Player client, string JSlotType, string JSlotId, string JClothId)
|
|
||||||
{
|
|
||||||
using (var context = new DatabaseContext())
|
|
||||||
{
|
|
||||||
int[] slotType = JsonConvert.DeserializeObject<int[]>(JSlotType);
|
|
||||||
int[] slotId = JsonConvert.DeserializeObject<int[]>(JSlotId);
|
|
||||||
int[] clothId = JsonConvert.DeserializeObject<int[]>(JClothId);
|
|
||||||
|
|
||||||
User user = client.GetUser();
|
|
||||||
user = context.Users.FirstOrDefault(u => u.Id == user.Id);
|
|
||||||
|
|
||||||
var character = client.GetUser().GetCharacter();
|
|
||||||
|
|
||||||
var charClothes = context.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id);
|
|
||||||
if (charClothes == null)
|
|
||||||
{
|
|
||||||
for (var x = 0; x < slotType.Length; x++)
|
|
||||||
{
|
|
||||||
CharacterCloth newCloth = new CharacterCloth
|
|
||||||
{
|
|
||||||
UserId = user.Id,
|
|
||||||
|
|
||||||
Duty = true,
|
|
||||||
|
|
||||||
SlotType = (byte)slotType[x],
|
|
||||||
SlotId = slotId[x],
|
|
||||||
ClothId = clothId[x]
|
|
||||||
};
|
|
||||||
context.CharacterClothes.Add(newCloth);
|
|
||||||
}
|
|
||||||
if (user.GetCharacter().Gender == false)
|
|
||||||
{
|
|
||||||
CharacterCloth newTorso = new CharacterCloth
|
|
||||||
{
|
|
||||||
UserId = user.Id,
|
|
||||||
|
|
||||||
Duty = true,
|
|
||||||
|
|
||||||
SlotType = 0,
|
|
||||||
SlotId = 3,
|
|
||||||
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso
|
|
||||||
};
|
|
||||||
CharacterCloth newUndershirt = new CharacterCloth
|
|
||||||
{
|
|
||||||
UserId = user.Id,
|
|
||||||
|
|
||||||
Duty = true,
|
|
||||||
|
|
||||||
SlotType = 0,
|
|
||||||
SlotId = 8,
|
|
||||||
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt
|
|
||||||
};
|
|
||||||
context.CharacterClothes.Add(newTorso);
|
|
||||||
context.CharacterClothes.Add(newUndershirt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (var x = 0; x < slotType.Length; x++)
|
|
||||||
{
|
|
||||||
var loopCloth = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == slotType[x] && u.SlotId == slotId[x]);
|
|
||||||
loopCloth.ClothId = clothId[x];
|
|
||||||
}
|
|
||||||
CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3);
|
|
||||||
CharacterCloth undershirt = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 8);
|
|
||||||
|
|
||||||
torso.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso;
|
|
||||||
undershirt.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt;
|
|
||||||
}
|
|
||||||
context.SaveChanges();
|
|
||||||
}
|
|
||||||
LoadCharacterDefaults(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("defaultCharacterCloth")]
|
|
||||||
public static void LoadCharacterDefaults(Player player)
|
|
||||||
{
|
|
||||||
User user = player.GetUser();
|
|
||||||
using (var context = new DatabaseContext())
|
|
||||||
{
|
|
||||||
List<CharacterCloth> charClothes = context.CharacterClothes.ToList().FindAll(c => c.UserId == user.Id && c.Duty == false);
|
|
||||||
player.ClearAccessory(0);
|
|
||||||
player.ClearAccessory(1);
|
|
||||||
player.ClearAccessory(2);
|
|
||||||
player.ClearAccessory(6);
|
|
||||||
player.ClearAccessory(7);
|
|
||||||
|
|
||||||
foreach (var cloth in charClothes)
|
|
||||||
{
|
|
||||||
if (cloth.SlotType == 1)
|
|
||||||
{
|
|
||||||
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.SetClothes(cloth.SlotId, cloth.ClothId, cloth.Texture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("SERVER:BuyCharacterClothes")]
|
|
||||||
public void RmtEvent_BuyClothes(Player client, string type, string jsonData)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* [0] ComponentID
|
|
||||||
* [1] TextureID
|
|
||||||
* [2] ClotheID
|
|
||||||
* [3] TorsoID
|
|
||||||
* [4] UndershirtID
|
|
||||||
* [5] UndershirtTextureID
|
|
||||||
* [6] Price
|
|
||||||
*/
|
|
||||||
|
|
||||||
int[] data = JsonConvert.DeserializeObject<int[]>(jsonData);
|
|
||||||
User user = client.GetUser();
|
|
||||||
if (user.Handmoney < data[6])
|
|
||||||
{
|
|
||||||
client.TriggerEvent("clothesMenu:Error");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == "clothe")
|
|
||||||
{
|
|
||||||
if (data[0] == 11)//for tops
|
|
||||||
{
|
|
||||||
client.SetClothes(11, data[2], data[1]); //set Top
|
|
||||||
client.SetClothes(8, data[4], data[5]); //set undershirt
|
|
||||||
client.SetClothes(3, data[3], 0); //set Torso
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
client.SetClothes(data[0], data[2], data[1]);
|
|
||||||
}
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
var clothes = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == data[0] && c.Duty == false);
|
|
||||||
|
|
||||||
if (clothes == null)
|
|
||||||
{
|
|
||||||
CharacterCloth newCloth = new CharacterCloth
|
|
||||||
{
|
|
||||||
UserId = user.Id,
|
|
||||||
|
|
||||||
Duty = false,
|
|
||||||
|
|
||||||
SlotType = 0,
|
|
||||||
SlotId = data[0],
|
|
||||||
ClothId = data[2],
|
|
||||||
Texture = data[1]
|
|
||||||
};
|
|
||||||
dbContext.CharacterClothes.Add(newCloth);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
clothes.ClothId = data[2];
|
|
||||||
clothes.Texture = data[1];
|
|
||||||
}
|
|
||||||
if (data[0] == 11)
|
|
||||||
{
|
|
||||||
var torso = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 3 && c.Duty == false);
|
|
||||||
var undershirt = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 8 && c.Duty == false);
|
|
||||||
if (torso == null)
|
|
||||||
{
|
|
||||||
CharacterCloth newTorso = new CharacterCloth
|
|
||||||
{
|
|
||||||
UserId = user.Id,
|
|
||||||
|
|
||||||
Duty = false,
|
|
||||||
|
|
||||||
SlotType = 0,
|
|
||||||
SlotId = 3,
|
|
||||||
ClothId = data[3]
|
|
||||||
};
|
|
||||||
dbContext.CharacterClothes.Add(newTorso);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
torso.ClothId = data[3];
|
|
||||||
}
|
|
||||||
if (undershirt == null)
|
|
||||||
{
|
|
||||||
CharacterCloth newUndershirt = new CharacterCloth
|
|
||||||
{
|
|
||||||
UserId = user.Id,
|
|
||||||
Duty = false,
|
|
||||||
SlotType = 0,
|
|
||||||
SlotId = 8,
|
|
||||||
ClothId = data[4],
|
|
||||||
Texture = data[5]
|
|
||||||
};
|
|
||||||
dbContext.CharacterClothes.Add(newUndershirt);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
undershirt.ClothId = data[4];
|
|
||||||
undershirt.Texture = data[5];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
client.GetUser(dbContext).Handmoney -= data[6];
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
|
||||||
}
|
|
||||||
client.TriggerEvent("clothesMenu:updateLast", data[2], data[1], data[4], data[5], data[3]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("updateDutyCloth")]
|
||||||
|
public void UpdateDutyCloth(Player player, int componentId, int componentVariation)
|
||||||
|
{
|
||||||
|
if (componentId == 11)
|
||||||
|
{
|
||||||
|
//TODO Spezielle Duty Kleidung in Datenbank einpflegen (Ergibt bei Cop-Kleidung NULL)
|
||||||
|
using (var context = new DatabaseContext())
|
||||||
|
{
|
||||||
|
var character = player.GetUser().GetCharacter();
|
||||||
|
|
||||||
|
var combination = context.ClothCombinations.FirstOrDefault(c => c.Top == componentVariation && c.Gender == character.Gender);
|
||||||
|
player.SetClothes(11, componentVariation, 0);
|
||||||
|
if (combination != null)
|
||||||
|
{
|
||||||
|
player.SetClothes(3, combination.Torso, 0);
|
||||||
|
player.SetClothes(8, combination.Undershirt, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.SetClothes(componentId, componentVariation, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("saveCharacterCloth")]
|
||||||
|
public void SaveDutyCloth(Player client, string JSlotType, string JSlotId, string JClothId)
|
||||||
|
{
|
||||||
|
using (var context = new DatabaseContext())
|
||||||
|
{
|
||||||
|
int[] slotType = JsonConvert.DeserializeObject<int[]>(JSlotType);
|
||||||
|
int[] slotId = JsonConvert.DeserializeObject<int[]>(JSlotId);
|
||||||
|
int[] clothId = JsonConvert.DeserializeObject<int[]>(JClothId);
|
||||||
|
|
||||||
|
User user = client.GetUser();
|
||||||
|
user = context.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||||
|
|
||||||
|
var character = client.GetUser().GetCharacter();
|
||||||
|
|
||||||
|
var charClothes = context.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id);
|
||||||
|
if (charClothes == null)
|
||||||
|
{
|
||||||
|
for (var x = 0; x < slotType.Length; x++)
|
||||||
|
{
|
||||||
|
CharacterCloth newCloth = new CharacterCloth
|
||||||
|
{
|
||||||
|
UserId = user.Id,
|
||||||
|
|
||||||
|
Duty = true,
|
||||||
|
|
||||||
|
SlotType = (byte)slotType[x],
|
||||||
|
SlotId = slotId[x],
|
||||||
|
ClothId = clothId[x]
|
||||||
|
};
|
||||||
|
context.CharacterClothes.Add(newCloth);
|
||||||
|
}
|
||||||
|
if (user.GetCharacter().Gender == false)
|
||||||
|
{
|
||||||
|
CharacterCloth newTorso = new CharacterCloth
|
||||||
|
{
|
||||||
|
UserId = user.Id,
|
||||||
|
|
||||||
|
Duty = true,
|
||||||
|
|
||||||
|
SlotType = 0,
|
||||||
|
SlotId = 3,
|
||||||
|
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso
|
||||||
|
};
|
||||||
|
CharacterCloth newUndershirt = new CharacterCloth
|
||||||
|
{
|
||||||
|
UserId = user.Id,
|
||||||
|
|
||||||
|
Duty = true,
|
||||||
|
|
||||||
|
SlotType = 0,
|
||||||
|
SlotId = 8,
|
||||||
|
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt
|
||||||
|
};
|
||||||
|
context.CharacterClothes.Add(newTorso);
|
||||||
|
context.CharacterClothes.Add(newUndershirt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (var x = 0; x < slotType.Length; x++)
|
||||||
|
{
|
||||||
|
var loopCloth = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == slotType[x] && u.SlotId == slotId[x]);
|
||||||
|
loopCloth.ClothId = clothId[x];
|
||||||
|
}
|
||||||
|
CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3);
|
||||||
|
CharacterCloth undershirt = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 8);
|
||||||
|
|
||||||
|
torso.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso;
|
||||||
|
undershirt.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt;
|
||||||
|
}
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
LoadCharacterDefaults(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("defaultCharacterCloth")]
|
||||||
|
public static void LoadCharacterDefaults(Player player)
|
||||||
|
{
|
||||||
|
User user = player.GetUser();
|
||||||
|
using (var context = new DatabaseContext())
|
||||||
|
{
|
||||||
|
List<CharacterCloth> charClothes = context.CharacterClothes.ToList().FindAll(c => c.UserId == user.Id && c.Duty == false);
|
||||||
|
player.ClearAccessory(0);
|
||||||
|
player.ClearAccessory(1);
|
||||||
|
player.ClearAccessory(2);
|
||||||
|
player.ClearAccessory(6);
|
||||||
|
player.ClearAccessory(7);
|
||||||
|
|
||||||
|
foreach (var cloth in charClothes)
|
||||||
|
{
|
||||||
|
if (cloth.SlotType == 1)
|
||||||
|
{
|
||||||
|
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.SetClothes(cloth.SlotId, cloth.ClothId, cloth.Texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("SERVER:BuyCharacterClothes")]
|
||||||
|
public void RmtEvent_BuyClothes(Player client, string type, string jsonData)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* [0] ComponentID
|
||||||
|
* [1] TextureID
|
||||||
|
* [2] ClotheID
|
||||||
|
* [3] TorsoID
|
||||||
|
* [4] UndershirtID
|
||||||
|
* [5] UndershirtTextureID
|
||||||
|
* [6] Price
|
||||||
|
*/
|
||||||
|
|
||||||
|
int[] data = JsonConvert.DeserializeObject<int[]>(jsonData);
|
||||||
|
User user = client.GetUser();
|
||||||
|
if (user.Handmoney < data[6])
|
||||||
|
{
|
||||||
|
client.TriggerEvent("clothesMenu:Error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == "clothe")
|
||||||
|
{
|
||||||
|
if (data[0] == 11)//for tops
|
||||||
|
{
|
||||||
|
client.SetClothes(11, data[2], data[1]); //set Top
|
||||||
|
client.SetClothes(8, data[4], data[5]); //set undershirt
|
||||||
|
client.SetClothes(3, data[3], 0); //set Torso
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
client.SetClothes(data[0], data[2], data[1]);
|
||||||
|
}
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
var clothes = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == data[0] && c.Duty == false);
|
||||||
|
|
||||||
|
if (clothes == null)
|
||||||
|
{
|
||||||
|
CharacterCloth newCloth = new CharacterCloth
|
||||||
|
{
|
||||||
|
UserId = user.Id,
|
||||||
|
|
||||||
|
Duty = false,
|
||||||
|
|
||||||
|
SlotType = 0,
|
||||||
|
SlotId = data[0],
|
||||||
|
ClothId = data[2],
|
||||||
|
Texture = data[1]
|
||||||
|
};
|
||||||
|
dbContext.CharacterClothes.Add(newCloth);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
clothes.ClothId = data[2];
|
||||||
|
clothes.Texture = data[1];
|
||||||
|
}
|
||||||
|
if (data[0] == 11)
|
||||||
|
{
|
||||||
|
var torso = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 3 && c.Duty == false);
|
||||||
|
var undershirt = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 8 && c.Duty == false);
|
||||||
|
if (torso == null)
|
||||||
|
{
|
||||||
|
CharacterCloth newTorso = new CharacterCloth
|
||||||
|
{
|
||||||
|
UserId = user.Id,
|
||||||
|
|
||||||
|
Duty = false,
|
||||||
|
|
||||||
|
SlotType = 0,
|
||||||
|
SlotId = 3,
|
||||||
|
ClothId = data[3]
|
||||||
|
};
|
||||||
|
dbContext.CharacterClothes.Add(newTorso);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
torso.ClothId = data[3];
|
||||||
|
}
|
||||||
|
if (undershirt == null)
|
||||||
|
{
|
||||||
|
CharacterCloth newUndershirt = new CharacterCloth
|
||||||
|
{
|
||||||
|
UserId = user.Id,
|
||||||
|
Duty = false,
|
||||||
|
SlotType = 0,
|
||||||
|
SlotId = 8,
|
||||||
|
ClothId = data[4],
|
||||||
|
Texture = data[5]
|
||||||
|
};
|
||||||
|
dbContext.CharacterClothes.Add(newUndershirt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
undershirt.ClothId = data[4];
|
||||||
|
undershirt.Texture = data[5];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
client.GetUser(dbContext).Handmoney -= data[6];
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||||
|
}
|
||||||
|
client.TriggerEvent("clothesMenu:updateLast", data[2], data[1], data[4], data[5], data[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ using ReallifeGamemode.Server.Managers;
|
|||||||
namespace ReallifeGamemode.Server.Events
|
namespace ReallifeGamemode.Server.Events
|
||||||
{
|
{
|
||||||
public class UpdateCharacterElevator : Script
|
public class UpdateCharacterElevator : Script
|
||||||
|
{
|
||||||
|
[RemoteEvent("sendPlayerToStage")]
|
||||||
|
public void SaveWeaponSelection(Player client, string stage)
|
||||||
{
|
{
|
||||||
[RemoteEvent("sendPlayerToStage")]
|
ElevatorPoint elevator = PositionManager.ElevatorPoints.Find(e => e.Stage == stage);
|
||||||
public void SaveWeaponSelection(Player client, string stage)
|
if (elevator != null)
|
||||||
{
|
{
|
||||||
ElevatorPoint elevator = PositionManager.ElevatorPoints.Find(e => e.Stage == stage);
|
client.Position = elevator.Position;
|
||||||
if (elevator != null)
|
}
|
||||||
{
|
|
||||||
client.Position = elevator.Position;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,101 +7,101 @@ using ReallifeGamemode.Server.Extensions;
|
|||||||
namespace ReallifeGamemode.Server.Events
|
namespace ReallifeGamemode.Server.Events
|
||||||
{
|
{
|
||||||
public class UpdateCharacterWeapon : Script
|
public class UpdateCharacterWeapon : Script
|
||||||
|
{
|
||||||
|
[RemoteEvent("updateWeaponSelection")]
|
||||||
|
public void UpdateWeaponSelection(Player client, string weaponModel, int slot)
|
||||||
{
|
{
|
||||||
[RemoteEvent("updateWeaponSelection")]
|
if (weaponModel == "Keine")
|
||||||
public void UpdateWeaponSelection(Player client, string weaponModel, int slot)
|
{
|
||||||
{
|
client.RemoveAllWeapons();
|
||||||
if (weaponModel == "Keine")
|
return;
|
||||||
{
|
}
|
||||||
client.RemoveAllWeapons();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
WeaponHash weaponHash = NAPI.Util.WeaponNameToModel(weaponModel);
|
WeaponHash weaponHash = NAPI.Util.WeaponNameToModel(weaponModel);
|
||||||
|
|
||||||
if (slot == 1)
|
if (slot == 1)
|
||||||
{
|
{
|
||||||
client.RemoveAllWeapons();
|
client.RemoveAllWeapons();
|
||||||
client.GiveWeapon(weaponHash, 0);
|
client.GiveWeapon(weaponHash, 0);
|
||||||
}
|
}
|
||||||
if (slot == 2)
|
if (slot == 2)
|
||||||
{
|
{
|
||||||
client.RemoveAllWeapons();
|
client.RemoveAllWeapons();
|
||||||
client.GiveWeapon(weaponHash, 0);
|
client.GiveWeapon(weaponHash, 0);
|
||||||
}
|
}
|
||||||
if (slot == 3)
|
if (slot == 3)
|
||||||
{
|
{
|
||||||
client.RemoveAllWeapons();
|
client.RemoveAllWeapons();
|
||||||
client.GiveWeapon(weaponHash, 0);
|
client.GiveWeapon(weaponHash, 0);
|
||||||
}
|
}
|
||||||
if (slot == 4)
|
if (slot == 4)
|
||||||
{
|
{
|
||||||
client.RemoveAllWeapons();
|
client.RemoveAllWeapons();
|
||||||
client.GiveWeapon(weaponHash, 0);
|
client.GiveWeapon(weaponHash, 0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("cancelWeaponSelection")]
|
|
||||||
public void CancelWeaponSelection(Player client)
|
|
||||||
{
|
|
||||||
client.RemoveAllWeapons();
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("saveWeaponSelection")]
|
|
||||||
public void SaveWeaponSelection(Player client, string primaryModel, string secondaryModel, string meleeModel, string specialModel)
|
|
||||||
{
|
|
||||||
client.RemoveAllWeapons();
|
|
||||||
if (!uint.TryParse(primaryModel, out uint primary))
|
|
||||||
{
|
|
||||||
if (primaryModel.Contains("mk2") && !primaryModel.Contains("_mk2")) primaryModel = primaryModel.Replace("mk2", "_mk2");
|
|
||||||
primary = NAPI.Util.GetHashKey($"weapon_{primaryModel}");
|
|
||||||
}
|
|
||||||
if (!uint.TryParse(secondaryModel, out uint secondary))
|
|
||||||
{
|
|
||||||
if (secondaryModel.Contains("mk2") && !secondaryModel.Contains("_mk2")) secondaryModel = secondaryModel.Replace("mk2", "_mk2");
|
|
||||||
secondary = NAPI.Util.GetHashKey($"weapon_{secondaryModel}");
|
|
||||||
}
|
|
||||||
if (!uint.TryParse(meleeModel, out uint melee))
|
|
||||||
{
|
|
||||||
if (meleeModel.Contains("mk2") && !meleeModel.Contains("_mk2")) meleeModel = meleeModel.Replace("mk2", "_mk2");
|
|
||||||
melee = NAPI.Util.GetHashKey($"weapon_{meleeModel}");
|
|
||||||
}
|
|
||||||
|
|
||||||
client.GiveWeapon((WeaponHash)primary, 50);
|
|
||||||
client.GiveWeapon((WeaponHash)secondary, 150);
|
|
||||||
client.GiveWeapon((WeaponHash)melee, 1);
|
|
||||||
if (specialModel != "Schutzweste")
|
|
||||||
{
|
|
||||||
client.Armor = 0;
|
|
||||||
if (!uint.TryParse(specialModel, out uint special))
|
|
||||||
{
|
|
||||||
if (specialModel.Contains("mk2") && !specialModel.Contains("_mk2")) specialModel = specialModel.Replace("mk2", "_mk2");
|
|
||||||
special = NAPI.Util.GetHashKey($"weapon_{specialModel}");
|
|
||||||
}
|
|
||||||
client.GiveWeapon((WeaponHash)special, 50);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
client.Armor = 50;
|
|
||||||
}
|
|
||||||
|
|
||||||
using (var context = new DatabaseContext())
|
|
||||||
{
|
|
||||||
User user = client.GetUser();
|
|
||||||
FactionWeapon slot1 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == primaryModel).FirstOrDefault();
|
|
||||||
if (slot1 != null)
|
|
||||||
slot1.Ammount -= 1;
|
|
||||||
FactionWeapon slot2 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == secondaryModel).FirstOrDefault();
|
|
||||||
if (slot2 != null)
|
|
||||||
slot2.Ammount -= 1;
|
|
||||||
FactionWeapon slot3 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == meleeModel).FirstOrDefault();
|
|
||||||
if (slot3 != null)
|
|
||||||
slot3.Ammount -= 1;
|
|
||||||
FactionWeapon slot4 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == specialModel).FirstOrDefault();
|
|
||||||
if (slot4 != null)
|
|
||||||
slot4.Ammount -= 1;
|
|
||||||
context.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("cancelWeaponSelection")]
|
||||||
|
public void CancelWeaponSelection(Player client)
|
||||||
|
{
|
||||||
|
client.RemoveAllWeapons();
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("saveWeaponSelection")]
|
||||||
|
public void SaveWeaponSelection(Player client, string primaryModel, string secondaryModel, string meleeModel, string specialModel)
|
||||||
|
{
|
||||||
|
client.RemoveAllWeapons();
|
||||||
|
if (!uint.TryParse(primaryModel, out uint primary))
|
||||||
|
{
|
||||||
|
if (primaryModel.Contains("mk2") && !primaryModel.Contains("_mk2")) primaryModel = primaryModel.Replace("mk2", "_mk2");
|
||||||
|
primary = NAPI.Util.GetHashKey($"weapon_{primaryModel}");
|
||||||
|
}
|
||||||
|
if (!uint.TryParse(secondaryModel, out uint secondary))
|
||||||
|
{
|
||||||
|
if (secondaryModel.Contains("mk2") && !secondaryModel.Contains("_mk2")) secondaryModel = secondaryModel.Replace("mk2", "_mk2");
|
||||||
|
secondary = NAPI.Util.GetHashKey($"weapon_{secondaryModel}");
|
||||||
|
}
|
||||||
|
if (!uint.TryParse(meleeModel, out uint melee))
|
||||||
|
{
|
||||||
|
if (meleeModel.Contains("mk2") && !meleeModel.Contains("_mk2")) meleeModel = meleeModel.Replace("mk2", "_mk2");
|
||||||
|
melee = NAPI.Util.GetHashKey($"weapon_{meleeModel}");
|
||||||
|
}
|
||||||
|
|
||||||
|
client.GiveWeapon((WeaponHash)primary, 50);
|
||||||
|
client.GiveWeapon((WeaponHash)secondary, 150);
|
||||||
|
client.GiveWeapon((WeaponHash)melee, 1);
|
||||||
|
if (specialModel != "Schutzweste")
|
||||||
|
{
|
||||||
|
client.Armor = 0;
|
||||||
|
if (!uint.TryParse(specialModel, out uint special))
|
||||||
|
{
|
||||||
|
if (specialModel.Contains("mk2") && !specialModel.Contains("_mk2")) specialModel = specialModel.Replace("mk2", "_mk2");
|
||||||
|
special = NAPI.Util.GetHashKey($"weapon_{specialModel}");
|
||||||
|
}
|
||||||
|
client.GiveWeapon((WeaponHash)special, 50);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
client.Armor = 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var context = new DatabaseContext())
|
||||||
|
{
|
||||||
|
User user = client.GetUser();
|
||||||
|
FactionWeapon slot1 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == primaryModel).FirstOrDefault();
|
||||||
|
if (slot1 != null)
|
||||||
|
slot1.Ammount -= 1;
|
||||||
|
FactionWeapon slot2 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == secondaryModel).FirstOrDefault();
|
||||||
|
if (slot2 != null)
|
||||||
|
slot2.Ammount -= 1;
|
||||||
|
FactionWeapon slot3 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == meleeModel).FirstOrDefault();
|
||||||
|
if (slot3 != null)
|
||||||
|
slot3.Ammount -= 1;
|
||||||
|
FactionWeapon slot4 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == specialModel).FirstOrDefault();
|
||||||
|
if (slot4 != null)
|
||||||
|
slot4.Ammount -= 1;
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,274 +9,274 @@ using ReallifeGamemode.Server.Util;
|
|||||||
namespace ReallifeGamemode.Server.Events
|
namespace ReallifeGamemode.Server.Events
|
||||||
{
|
{
|
||||||
public class Vehicle : Script
|
public class Vehicle : Script
|
||||||
|
{
|
||||||
|
[RemoteEvent("VehicleMenu_ToggleEngine")]
|
||||||
|
public void VehicleMenuToggleEngineEvent(Player player)
|
||||||
{
|
{
|
||||||
[RemoteEvent("VehicleMenu_ToggleEngine")]
|
if (player.IsInVehicle && player.VehicleSeat == 0)
|
||||||
public void VehicleMenuToggleEngineEvent(Player player)
|
{
|
||||||
|
GTANetworkAPI.Vehicle v = player.Vehicle;
|
||||||
|
|
||||||
|
User u = player.GetUser();
|
||||||
|
if (u == null) return;
|
||||||
|
|
||||||
|
if (NAPI.Entity.GetEntityVelocity(v).Length() > 1 && v.Class != 16)
|
||||||
{
|
{
|
||||||
if (player.IsInVehicle && player.VehicleSeat == 0)
|
player.SendNotification("~r~Der Motor kann nur im Stand betätigt werden.", true);
|
||||||
{
|
return;
|
||||||
GTANetworkAPI.Vehicle v = player.Vehicle;
|
|
||||||
|
|
||||||
User u = player.GetUser();
|
|
||||||
if (u == null) return;
|
|
||||||
|
|
||||||
if (NAPI.Entity.GetEntityVelocity(v).Length() > 1 && v.Class != 16)
|
|
||||||
{
|
|
||||||
player.SendNotification("~r~Der Motor kann nur im Stand betätigt werden.", true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool state = VehicleStreaming.GetEngineState(v);
|
|
||||||
ServerVehicle sV = v.GetServerVehicle();
|
|
||||||
if (sV != null)
|
|
||||||
{
|
|
||||||
if (sV is ShopVehicle)
|
|
||||||
{
|
|
||||||
VehicleStreaming.SetEngineState(v, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (sV is FactionVehicle fV)
|
|
||||||
{
|
|
||||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0) && !state && !(u.IsAdmin(AdminLevel.HEADADMIN) && GlobalHelper.DutyAdmins.Contains(player)))
|
|
||||||
{
|
|
||||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (sV is GroupVehicle gV)
|
|
||||||
{
|
|
||||||
if (gV.GroupId != u.Group.Id && !state && !u.IsAdmin(AdminLevel.ADMIN3))
|
|
||||||
{
|
|
||||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (sV is JobVehicle jV)
|
|
||||||
{
|
|
||||||
if (!jV.GetJob().GetUsersInJob().Contains(player) && !u.IsAdmin(AdminLevel.ADMIN3))
|
|
||||||
{
|
|
||||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (sV is UserVehicle uV)
|
|
||||||
{
|
|
||||||
if (uV.UserId != u.Id)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
VehicleStreaming.SetEngineState(v, !state);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[RemoteEvent("VehicleMenu_LockCar")]
|
bool state = VehicleStreaming.GetEngineState(v);
|
||||||
public static void VehicleMenuLockCarEvent(Player player)
|
ServerVehicle sV = v.GetServerVehicle();
|
||||||
|
if (sV != null)
|
||||||
{
|
{
|
||||||
if (player.IsInVehicle && player.VehicleSeat == 0)
|
if (sV is ShopVehicle)
|
||||||
|
{
|
||||||
|
VehicleStreaming.SetEngineState(v, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (sV is FactionVehicle fV)
|
||||||
|
{
|
||||||
|
if (!fV.GetOwners().Contains(u.FactionId ?? 0) && !state && !(u.IsAdmin(AdminLevel.HEADADMIN) && GlobalHelper.DutyAdmins.Contains(player)))
|
||||||
{
|
{
|
||||||
GTANetworkAPI.Vehicle v = player.Vehicle;
|
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||||
|
return;
|
||||||
User u = player.GetUser();
|
|
||||||
if (u == null) return;
|
|
||||||
|
|
||||||
bool state = VehicleStreaming.GetLockState(v);
|
|
||||||
ServerVehicle sV = v.GetServerVehicle();
|
|
||||||
|
|
||||||
if (sV != null)
|
|
||||||
{
|
|
||||||
if (sV is ShopVehicle)
|
|
||||||
{
|
|
||||||
VehicleStreaming.SetEngineState(v, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (sV is FactionVehicle fV)
|
|
||||||
{
|
|
||||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (sV is UserVehicle uV)
|
|
||||||
{
|
|
||||||
if (uV.UserId != u.Id)
|
|
||||||
{
|
|
||||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (sV is JobVehicle)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (sV is SchoolVehicle)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
state = !state;
|
|
||||||
VehicleStreaming.SetLockStatus(v, state);
|
|
||||||
string msg = "Fahrzeug ";
|
|
||||||
msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen";
|
|
||||||
player.TriggerEvent("vehsync:OpenCar", state);
|
|
||||||
player.SendNotification(msg);
|
|
||||||
}
|
}
|
||||||
else if (!player.IsInVehicle)
|
}
|
||||||
|
else if (sV is GroupVehicle gV)
|
||||||
|
{
|
||||||
|
if (gV.GroupId != u.Group.Id && !state && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||||
{
|
{
|
||||||
GTANetworkAPI.Vehicle vehicle = null;
|
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||||
foreach (var veh in NAPI.Pools.GetAllVehicles())
|
return;
|
||||||
{
|
|
||||||
if (player.Position.DistanceTo(veh.Position) <= 3f)
|
|
||||||
{
|
|
||||||
vehicle = veh;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vehicle == null)
|
|
||||||
return;
|
|
||||||
User u = player.GetUser();
|
|
||||||
if (u == null) return;
|
|
||||||
|
|
||||||
bool state = VehicleStreaming.GetLockState(vehicle);
|
|
||||||
ServerVehicle sV = vehicle.GetServerVehicle();
|
|
||||||
|
|
||||||
if (sV != null)
|
|
||||||
{
|
|
||||||
if (sV is ShopVehicle)
|
|
||||||
{
|
|
||||||
VehicleStreaming.SetEngineState(vehicle, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (sV is FactionVehicle fV)
|
|
||||||
{
|
|
||||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (sV is UserVehicle uV)
|
|
||||||
{
|
|
||||||
if (uV.UserId != u.Id)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (sV is JobVehicle)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
state = !state;
|
|
||||||
VehicleStreaming.SetLockStatus(vehicle, state);
|
|
||||||
string msg = "Fahrzeug ";
|
|
||||||
msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen";
|
|
||||||
player.TriggerEvent("vehsync:OpenCar", state);
|
|
||||||
player.SendNotification(msg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (sV is JobVehicle jV)
|
||||||
[RemoteEvent("CLIENT:VehicleMenu_ParkCar")]
|
{
|
||||||
public void VehicleMenuParkCarEvent(Player player)
|
if (!jV.GetJob().GetUsersInJob().Contains(player) && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||||
{
|
|
||||||
if (player.IsInVehicle && player.VehicleSeat == 0)
|
|
||||||
{
|
{
|
||||||
GTANetworkAPI.Vehicle v = player.Vehicle;
|
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||||
|
return;
|
||||||
User u = player.GetUser();
|
|
||||||
if (u == null) return;
|
|
||||||
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
ServerVehicle sV = v.GetServerVehicle(dbContext);
|
|
||||||
|
|
||||||
if (sV == null) return;
|
|
||||||
|
|
||||||
if (sV is UserVehicle uV)
|
|
||||||
{
|
|
||||||
if (uV.UserId != u.Id)
|
|
||||||
{
|
|
||||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (sV is FactionVehicle fV)
|
|
||||||
{
|
|
||||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0) || !u.FactionLeader)
|
|
||||||
{
|
|
||||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (sV is GroupVehicle gV)
|
|
||||||
{
|
|
||||||
if (gV.GroupId != u.Group.Id || u.GroupRank < GroupRank.MANAGER)
|
|
||||||
{
|
|
||||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (sV is JobVehicle)
|
|
||||||
{
|
|
||||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (sV is SchoolVehicle)
|
|
||||||
{
|
|
||||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector3 pos = v.Position;
|
|
||||||
|
|
||||||
sV.PositionX = pos.X;
|
|
||||||
sV.PositionY = pos.Y;
|
|
||||||
sV.PositionZ = pos.Z;
|
|
||||||
sV.Heading = v.Heading;
|
|
||||||
|
|
||||||
player.SendNotification("~g~Das Fahrzeug wurde geparkt.");
|
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (sV is UserVehicle uV)
|
||||||
[RemoteEvent("VehicleMenu_ToggleSingleDoor")]
|
{
|
||||||
public void VehicleMenuToggleSingleDoorEvent(Player player, int door)
|
if (uV.UserId != u.Id)
|
||||||
{
|
|
||||||
if (!player.IsInVehicle) return;
|
|
||||||
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
|
||||||
|
|
||||||
DoorID doorId = (DoorID)door;
|
|
||||||
|
|
||||||
DoorState state = VehicleStreaming.GetDoorState(veh, doorId);
|
|
||||||
|
|
||||||
VehicleStreaming.SetDoorState(veh, doorId, state == DoorState.DoorOpen ? DoorState.DoorClosed : DoorState.DoorOpen);
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("VehicleMenu_OpenAllDoors")]
|
|
||||||
public void VehicleMenuOpenAllDoorsEvent(Player player)
|
|
||||||
{
|
|
||||||
if (!player.IsInVehicle) return;
|
|
||||||
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
|
||||||
|
|
||||||
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
|
||||||
{
|
{
|
||||||
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorOpen);
|
return;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("VehicleMenu_CloseAllDoors")]
|
|
||||||
public void VehicleMenuCloseAllDoorsEvent(Player player)
|
|
||||||
{
|
|
||||||
if (!player.IsInVehicle) return;
|
|
||||||
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
|
||||||
|
|
||||||
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
|
||||||
{
|
|
||||||
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorClosed);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
VehicleStreaming.SetEngineState(v, !state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("VehicleMenu_LockCar")]
|
||||||
|
public static void VehicleMenuLockCarEvent(Player player)
|
||||||
|
{
|
||||||
|
if (player.IsInVehicle && player.VehicleSeat == 0)
|
||||||
|
{
|
||||||
|
GTANetworkAPI.Vehicle v = player.Vehicle;
|
||||||
|
|
||||||
|
User u = player.GetUser();
|
||||||
|
if (u == null) return;
|
||||||
|
|
||||||
|
bool state = VehicleStreaming.GetLockState(v);
|
||||||
|
ServerVehicle sV = v.GetServerVehicle();
|
||||||
|
|
||||||
|
if (sV != null)
|
||||||
|
{
|
||||||
|
if (sV is ShopVehicle)
|
||||||
|
{
|
||||||
|
VehicleStreaming.SetEngineState(v, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (sV is FactionVehicle fV)
|
||||||
|
{
|
||||||
|
if (!fV.GetOwners().Contains(u.FactionId ?? 0))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (sV is UserVehicle uV)
|
||||||
|
{
|
||||||
|
if (uV.UserId != u.Id)
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (sV is JobVehicle)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (sV is SchoolVehicle)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
state = !state;
|
||||||
|
VehicleStreaming.SetLockStatus(v, state);
|
||||||
|
string msg = "Fahrzeug ";
|
||||||
|
msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen";
|
||||||
|
player.TriggerEvent("vehsync:OpenCar", state);
|
||||||
|
player.SendNotification(msg);
|
||||||
|
}
|
||||||
|
else if (!player.IsInVehicle)
|
||||||
|
{
|
||||||
|
GTANetworkAPI.Vehicle vehicle = null;
|
||||||
|
foreach (var veh in NAPI.Pools.GetAllVehicles())
|
||||||
|
{
|
||||||
|
if (player.Position.DistanceTo(veh.Position) <= 3f)
|
||||||
|
{
|
||||||
|
vehicle = veh;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vehicle == null)
|
||||||
|
return;
|
||||||
|
User u = player.GetUser();
|
||||||
|
if (u == null) return;
|
||||||
|
|
||||||
|
bool state = VehicleStreaming.GetLockState(vehicle);
|
||||||
|
ServerVehicle sV = vehicle.GetServerVehicle();
|
||||||
|
|
||||||
|
if (sV != null)
|
||||||
|
{
|
||||||
|
if (sV is ShopVehicle)
|
||||||
|
{
|
||||||
|
VehicleStreaming.SetEngineState(vehicle, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (sV is FactionVehicle fV)
|
||||||
|
{
|
||||||
|
if (!fV.GetOwners().Contains(u.FactionId ?? 0))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (sV is UserVehicle uV)
|
||||||
|
{
|
||||||
|
if (uV.UserId != u.Id)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (sV is JobVehicle)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
state = !state;
|
||||||
|
VehicleStreaming.SetLockStatus(vehicle, state);
|
||||||
|
string msg = "Fahrzeug ";
|
||||||
|
msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen";
|
||||||
|
player.TriggerEvent("vehsync:OpenCar", state);
|
||||||
|
player.SendNotification(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:VehicleMenu_ParkCar")]
|
||||||
|
public void VehicleMenuParkCarEvent(Player player)
|
||||||
|
{
|
||||||
|
if (player.IsInVehicle && player.VehicleSeat == 0)
|
||||||
|
{
|
||||||
|
GTANetworkAPI.Vehicle v = player.Vehicle;
|
||||||
|
|
||||||
|
User u = player.GetUser();
|
||||||
|
if (u == null) return;
|
||||||
|
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
ServerVehicle sV = v.GetServerVehicle(dbContext);
|
||||||
|
|
||||||
|
if (sV == null) return;
|
||||||
|
|
||||||
|
if (sV is UserVehicle uV)
|
||||||
|
{
|
||||||
|
if (uV.UserId != u.Id)
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (sV is FactionVehicle fV)
|
||||||
|
{
|
||||||
|
if (!fV.GetOwners().Contains(u.FactionId ?? 0) || !u.FactionLeader)
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (sV is GroupVehicle gV)
|
||||||
|
{
|
||||||
|
if (gV.GroupId != u.Group.Id || u.GroupRank < GroupRank.MANAGER)
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (sV is JobVehicle)
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (sV is SchoolVehicle)
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 pos = v.Position;
|
||||||
|
|
||||||
|
sV.PositionX = pos.X;
|
||||||
|
sV.PositionY = pos.Y;
|
||||||
|
sV.PositionZ = pos.Z;
|
||||||
|
sV.Heading = v.Heading;
|
||||||
|
|
||||||
|
player.SendNotification("~g~Das Fahrzeug wurde geparkt.");
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("VehicleMenu_ToggleSingleDoor")]
|
||||||
|
public void VehicleMenuToggleSingleDoorEvent(Player player, int door)
|
||||||
|
{
|
||||||
|
if (!player.IsInVehicle) return;
|
||||||
|
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
||||||
|
|
||||||
|
DoorID doorId = (DoorID)door;
|
||||||
|
|
||||||
|
DoorState state = VehicleStreaming.GetDoorState(veh, doorId);
|
||||||
|
|
||||||
|
VehicleStreaming.SetDoorState(veh, doorId, state == DoorState.DoorOpen ? DoorState.DoorClosed : DoorState.DoorOpen);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("VehicleMenu_OpenAllDoors")]
|
||||||
|
public void VehicleMenuOpenAllDoorsEvent(Player player)
|
||||||
|
{
|
||||||
|
if (!player.IsInVehicle) return;
|
||||||
|
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
||||||
|
|
||||||
|
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
||||||
|
{
|
||||||
|
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorOpen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("VehicleMenu_CloseAllDoors")]
|
||||||
|
public void VehicleMenuCloseAllDoorsEvent(Player player)
|
||||||
|
{
|
||||||
|
if (!player.IsInVehicle) return;
|
||||||
|
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
||||||
|
|
||||||
|
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
||||||
|
{
|
||||||
|
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorClosed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,53 +17,53 @@ using ReallifeGamemode.Server.Services;
|
|||||||
namespace ReallifeGamemode.Server.Extensions
|
namespace ReallifeGamemode.Server.Extensions
|
||||||
{
|
{
|
||||||
public static class PlayerExtension
|
public static class PlayerExtension
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gibt das User-Objekt eines Player's zurück.
|
||||||
|
/// Gibt nichts zurück, wenn der Player nicht eingeloggt ist
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client">Der Player, dessen User man bekommen möchte</param>
|
||||||
|
/// <param name="context">Ein eventuell vorhandener Datenbank-Context, falls man Änderungen in der Datenbank vornehmen will</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static User GetUser(this Player client, DatabaseContext context = null)
|
||||||
{
|
{
|
||||||
/// <summary>
|
context = context ?? new DatabaseContext();
|
||||||
/// Gibt das User-Objekt eines Player's zurück.
|
if (!client.IsLoggedIn()) return null;
|
||||||
/// Gibt nichts zurück, wenn der Player nicht eingeloggt ist
|
return context
|
||||||
/// </summary>
|
.Users
|
||||||
/// <param name="client">Der Player, dessen User man bekommen möchte</param>
|
.Include(u => u.Faction)
|
||||||
/// <param name="context">Ein eventuell vorhandener Datenbank-Context, falls man Änderungen in der Datenbank vornehmen will</param>
|
.Include(u => u.FactionRank)
|
||||||
/// <returns></returns>
|
.Include(u => u.Group)
|
||||||
public static User GetUser(this Player client, DatabaseContext context = null)
|
.Include(u => u.House)
|
||||||
{
|
.Include(u => u.BankAccount)
|
||||||
context = context ?? new DatabaseContext();
|
.Where(u => u.Name == client.Name)
|
||||||
if (!client.IsLoggedIn()) return null;
|
.FirstOrDefault();
|
||||||
return context
|
}
|
||||||
.Users
|
|
||||||
.Include(u => u.Faction)
|
|
||||||
.Include(u => u.FactionRank)
|
|
||||||
.Include(u => u.Group)
|
|
||||||
.Include(u => u.House)
|
|
||||||
.Include(u => u.BankAccount)
|
|
||||||
.Where(u => u.Name == client.Name)
|
|
||||||
.FirstOrDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Character GetCharacter(this User user, DatabaseContext context = null)
|
public static Character GetCharacter(this User user, DatabaseContext context = null)
|
||||||
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
using (context = new DatabaseContext())
|
||||||
{
|
{
|
||||||
if (context == null)
|
return context.Characters.FirstOrDefault(u => u.UserId == user.Id);
|
||||||
{
|
|
||||||
using (context = new DatabaseContext())
|
|
||||||
{
|
|
||||||
return context.Characters.FirstOrDefault(u => u.UserId == user.Id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return context.Characters.FirstOrDefault(u => u.UserId == user.Id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return context.Characters.FirstOrDefault(u => u.UserId == user.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gibt zurück, ob ein Player eingeloggt ist
|
/// Gibt zurück, ob ein Player eingeloggt ist
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="player">Der Player, dessen Login-Status man bekommen möchte</param>
|
/// <param name="player">Der Player, dessen Login-Status man bekommen möchte</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool IsLoggedIn(this Player player)
|
public static bool IsLoggedIn(this Player player)
|
||||||
{
|
{
|
||||||
return player.HasData("isLoggedIn") ? player.GetData<bool>("isLoggedIn") : false;
|
return player.HasData("isLoggedIn") ? player.GetData<bool>("isLoggedIn") : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsDuty(this Player player)
|
public static bool IsDuty(this Player player)
|
||||||
{
|
{
|
||||||
@@ -81,126 +81,126 @@ namespace ReallifeGamemode.Server.Extensions
|
|||||||
return newpos;
|
return newpos;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static T GetData<T>(this User user, string key, T nullValue)
|
internal static T GetData<T>(this User user, string key, T nullValue)
|
||||||
{
|
{
|
||||||
key += "data_";
|
key += "data_";
|
||||||
if (!user.Player.HasData(key)) return nullValue;
|
if (!user.Player.HasData(key)) return nullValue;
|
||||||
return JsonConvert.DeserializeObject<T>(user.Player.GetData<dynamic>(key));
|
return JsonConvert.DeserializeObject<T>(user.Player.GetData<dynamic>(key));
|
||||||
}
|
|
||||||
|
|
||||||
internal static T GetData<T>(this User user, string key) => user.GetData<T>(key, default);
|
|
||||||
|
|
||||||
internal static void SetData(this User user, string key, object value)
|
|
||||||
{
|
|
||||||
key += "data_";
|
|
||||||
user.Player.SetData(key, JsonConvert.SerializeObject(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void GiveWanteds(this User user, Player cop, int amount, string reason)
|
|
||||||
{
|
|
||||||
if (user.Wanteds + amount > 50)
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(cop, "Die Wanteds dürfen ein Limit von 50 nicht überschreiten");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int newWanteds = user.Wanteds + amount;
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
User dbUser = dbContext.Users.Where(u => u.Id == user.Id).FirstOrDefault();
|
|
||||||
dbUser.Wanteds = newWanteds;
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
user.Player.SetSharedData("blipColor", 64);
|
|
||||||
ChatService.SendMessage(user.Player, "!{#FF614A}Du hast ein Verbrechen begangen: " + reason + "" + (cop != null ? " | Gemeldet von: " + cop.Name + "." : ""));
|
|
||||||
ChatService.SendMessage(user.Player, " !{#FFFF00}Fahnundgslevel:~s~ " + newWanteds);
|
|
||||||
|
|
||||||
foreach (var copPlayer in NAPI.Pools.GetAllPlayers())
|
|
||||||
{
|
|
||||||
User copUser = copPlayer.GetUser();
|
|
||||||
if (cop != null && (copUser.FactionId == 1 || copUser.FactionId == 3))
|
|
||||||
{
|
|
||||||
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Straftat gemeldet von " + cop.Name + " mit Fahndungslevel " + amount + ". Straftäter: " + user.Name + ".");
|
|
||||||
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Grund: " + reason + ".");
|
|
||||||
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Der Straftäter: " + user.Name + " wird nun mit Fahndungslevel " + newWanteds + " gesucht.");
|
|
||||||
}
|
|
||||||
else if ((copUser.FactionId == 1 || copUser.FactionId == 3) && cop == null)
|
|
||||||
{
|
|
||||||
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: " + user.Name + " hat eine Straftat begangen. Grund: " + reason + ".");
|
|
||||||
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Der Straftäter: " + user.Name + " wird nun mit Fahndungslevel " + newWanteds + " gesucht.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionRank GetFactionRank(this User user)
|
|
||||||
{
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
FactionRank toReturn = dbContext.FactionRanks.FirstOrDefault(fR => fR.Id == user.FactionRankId);
|
|
||||||
if (toReturn == null)
|
|
||||||
{
|
|
||||||
toReturn = dbContext.FactionRanks.OrderBy(f => f.Order).FirstOrDefault(f => f.FactionId == user.FactionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toReturn == null)
|
|
||||||
{
|
|
||||||
toReturn = new FactionRank
|
|
||||||
{
|
|
||||||
RankName = "Rang-Fehler"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return toReturn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void BanPlayer(this User user, Player admin, string reason, int mins)
|
|
||||||
{
|
|
||||||
using (var banUserContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
|
||||||
Ban banUser;
|
|
||||||
|
|
||||||
if (mins == 0)
|
|
||||||
{
|
|
||||||
ChatService.Broadcast("!{#FF4040}[BAN] " + user.Name + " wurde von " + admin.Name + " permanent gebannt. [" + reason + "]");
|
|
||||||
banUser = new Ban { UserId = user.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp };
|
|
||||||
|
|
||||||
user.Player?.Kick();
|
|
||||||
|
|
||||||
mins--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ChatService.Broadcast("!{#FF4040}[BAN] " + user.Name + " wurde von " + admin.Name + " für " + mins + " Minuten gebannt. [" + reason + "]");
|
|
||||||
banUser = new Ban { UserId = user.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp + mins * 60 };
|
|
||||||
user.Player?.Kick();
|
|
||||||
}
|
|
||||||
|
|
||||||
banUserContext.Bans.Add(banUser);
|
|
||||||
banUserContext.SaveChanges();
|
|
||||||
|
|
||||||
var targetUser = banUserContext.Users.Where(u => u.Name == user.Name).FirstOrDefault();
|
|
||||||
targetUser.BanId = banUser.Id;
|
|
||||||
banUserContext.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void UnbanPlayer(this User user)
|
|
||||||
{
|
|
||||||
using (var unbanUser = new DatabaseContext())
|
|
||||||
{
|
|
||||||
var targetUser = unbanUser.Users.Where(u => u.Id == user.Id).FirstOrDefault();
|
|
||||||
targetUser.BanId = null;
|
|
||||||
unbanUser.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<UserItem> GetItems(this User user)
|
|
||||||
{
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
return dbContext.UserItems.Where(u => u.UserId == user.Id).ToList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
internal static T GetData<T>(this User user, string key) => user.GetData<T>(key, default);
|
||||||
|
|
||||||
|
internal static void SetData(this User user, string key, object value)
|
||||||
|
{
|
||||||
|
key += "data_";
|
||||||
|
user.Player.SetData(key, JsonConvert.SerializeObject(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void GiveWanteds(this User user, Player cop, int amount, string reason)
|
||||||
|
{
|
||||||
|
if (user.Wanteds + amount > 50)
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(cop, "Die Wanteds dürfen ein Limit von 50 nicht überschreiten");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int newWanteds = user.Wanteds + amount;
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
User dbUser = dbContext.Users.Where(u => u.Id == user.Id).FirstOrDefault();
|
||||||
|
dbUser.Wanteds = newWanteds;
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
user.Player.SetSharedData("blipColor", 64);
|
||||||
|
ChatService.SendMessage(user.Player, "!{#FF614A}Du hast ein Verbrechen begangen: " + reason + "" + (cop != null ? " | Gemeldet von: " + cop.Name + "." : ""));
|
||||||
|
ChatService.SendMessage(user.Player, " !{#FFFF00}Fahnundgslevel:~s~ " + newWanteds);
|
||||||
|
|
||||||
|
foreach (var copPlayer in NAPI.Pools.GetAllPlayers())
|
||||||
|
{
|
||||||
|
User copUser = copPlayer.GetUser();
|
||||||
|
if (cop != null && (copUser.FactionId == 1 || copUser.FactionId == 3))
|
||||||
|
{
|
||||||
|
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Straftat gemeldet von " + cop.Name + " mit Fahndungslevel " + amount + ". Straftäter: " + user.Name + ".");
|
||||||
|
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Grund: " + reason + ".");
|
||||||
|
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Der Straftäter: " + user.Name + " wird nun mit Fahndungslevel " + newWanteds + " gesucht.");
|
||||||
|
}
|
||||||
|
else if ((copUser.FactionId == 1 || copUser.FactionId == 3) && cop == null)
|
||||||
|
{
|
||||||
|
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: " + user.Name + " hat eine Straftat begangen. Grund: " + reason + ".");
|
||||||
|
ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Der Straftäter: " + user.Name + " wird nun mit Fahndungslevel " + newWanteds + " gesucht.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FactionRank GetFactionRank(this User user)
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
FactionRank toReturn = dbContext.FactionRanks.FirstOrDefault(fR => fR.Id == user.FactionRankId);
|
||||||
|
if (toReturn == null)
|
||||||
|
{
|
||||||
|
toReturn = dbContext.FactionRanks.OrderBy(f => f.Order).FirstOrDefault(f => f.FactionId == user.FactionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toReturn == null)
|
||||||
|
{
|
||||||
|
toReturn = new FactionRank
|
||||||
|
{
|
||||||
|
RankName = "Rang-Fehler"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void BanPlayer(this User user, Player admin, string reason, int mins)
|
||||||
|
{
|
||||||
|
using (var banUserContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||||
|
Ban banUser;
|
||||||
|
|
||||||
|
if (mins == 0)
|
||||||
|
{
|
||||||
|
ChatService.Broadcast("!{#FF4040}[BAN] " + user.Name + " wurde von " + admin.Name + " permanent gebannt. [" + reason + "]");
|
||||||
|
banUser = new Ban { UserId = user.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp };
|
||||||
|
|
||||||
|
user.Player?.Kick();
|
||||||
|
|
||||||
|
mins--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ChatService.Broadcast("!{#FF4040}[BAN] " + user.Name + " wurde von " + admin.Name + " für " + mins + " Minuten gebannt. [" + reason + "]");
|
||||||
|
banUser = new Ban { UserId = user.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp + mins * 60 };
|
||||||
|
user.Player?.Kick();
|
||||||
|
}
|
||||||
|
|
||||||
|
banUserContext.Bans.Add(banUser);
|
||||||
|
banUserContext.SaveChanges();
|
||||||
|
|
||||||
|
var targetUser = banUserContext.Users.Where(u => u.Name == user.Name).FirstOrDefault();
|
||||||
|
targetUser.BanId = banUser.Id;
|
||||||
|
banUserContext.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void UnbanPlayer(this User user)
|
||||||
|
{
|
||||||
|
using (var unbanUser = new DatabaseContext())
|
||||||
|
{
|
||||||
|
var targetUser = unbanUser.Users.Where(u => u.Id == user.Id).FirstOrDefault();
|
||||||
|
targetUser.BanId = null;
|
||||||
|
unbanUser.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<UserItem> GetItems(this User user)
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
return dbContext.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,57 +4,57 @@ using static ReallifeGamemode.Server.Types.AdminLevel;
|
|||||||
namespace ReallifeGamemode.Server.Extensions
|
namespace ReallifeGamemode.Server.Extensions
|
||||||
{
|
{
|
||||||
public static class EnumExtensions
|
public static class EnumExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gibt den richtigen Namen eines Admin Levels zurück
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="level">Das Admin Level, dessen Namen man bekommen möchte.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetName(this AdminLevel level)
|
||||||
{
|
{
|
||||||
/// <summary>
|
switch (level)
|
||||||
/// Gibt den richtigen Namen eines Admin Levels zurück
|
{
|
||||||
/// </summary>
|
case MAPPING:
|
||||||
/// <param name="level">Das Admin Level, dessen Namen man bekommen möchte.</param>
|
return "Mapper";
|
||||||
/// <returns></returns>
|
|
||||||
public static string GetName(this AdminLevel level)
|
|
||||||
{
|
|
||||||
switch (level)
|
|
||||||
{
|
|
||||||
case MAPPING:
|
|
||||||
return "Mapper";
|
|
||||||
|
|
||||||
case ENTWICKLUNG:
|
case ENTWICKLUNG:
|
||||||
return "Entwickler";
|
return "Entwickler";
|
||||||
|
|
||||||
case SUPPORTER:
|
case SUPPORTER:
|
||||||
return "Supporter";
|
return "Supporter";
|
||||||
|
|
||||||
case ADMIN:
|
case ADMIN:
|
||||||
case ADMIN2:
|
case ADMIN2:
|
||||||
case ADMIN3:
|
case ADMIN3:
|
||||||
return "Admin";
|
return "Admin";
|
||||||
|
|
||||||
case HEADADMIN:
|
case HEADADMIN:
|
||||||
return "Headadmin";
|
return "Headadmin";
|
||||||
|
|
||||||
case PROJEKTLEITUNG:
|
case PROJEKTLEITUNG:
|
||||||
return "Projektleiter";
|
return "Projektleiter";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return "Spieler";
|
return "Spieler";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetName(this GroupRank rank)
|
|
||||||
{
|
|
||||||
switch (rank)
|
|
||||||
{
|
|
||||||
case GroupRank.OWNER:
|
|
||||||
return "Besitzer";
|
|
||||||
|
|
||||||
case GroupRank.MANAGER:
|
|
||||||
return "Manager";
|
|
||||||
|
|
||||||
case GroupRank.MEMBER:
|
|
||||||
return "Mitglied";
|
|
||||||
|
|
||||||
default:
|
|
||||||
return "Keiner";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetName(this GroupRank rank)
|
||||||
|
{
|
||||||
|
switch (rank)
|
||||||
|
{
|
||||||
|
case GroupRank.OWNER:
|
||||||
|
return "Besitzer";
|
||||||
|
|
||||||
|
case GroupRank.MANAGER:
|
||||||
|
return "Manager";
|
||||||
|
|
||||||
|
case GroupRank.MEMBER:
|
||||||
|
return "Mitglied";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return "Keiner";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
namespace ReallifeGamemode.Server.Extensions
|
namespace ReallifeGamemode.Server.Extensions
|
||||||
{
|
{
|
||||||
public static class IntegerExtension
|
public static class IntegerExtension
|
||||||
|
{
|
||||||
|
public static string ToMoneyString(this int? money)
|
||||||
{
|
{
|
||||||
public static string ToMoneyString(this int? money)
|
return ToMoneyString(money ?? 0);
|
||||||
{
|
|
||||||
return ToMoneyString(money ?? 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string ToMoneyString(this int money)
|
|
||||||
{
|
|
||||||
return "$" + string.Format(Main.SERVER_CULTURE, "{0:C0}", money).Replace("€", "").Trim();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string ToMoneyString(this int money)
|
||||||
|
{
|
||||||
|
return "$" + string.Format(Main.SERVER_CULTURE, "{0:C0}", money).Replace("€", "").Trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,66 +7,66 @@ using ReallifeGamemode.Server.Util;
|
|||||||
namespace ReallifeGamemode.Server.Extensions
|
namespace ReallifeGamemode.Server.Extensions
|
||||||
{
|
{
|
||||||
public static class ServerVehicleExtensions
|
public static class ServerVehicleExtensions
|
||||||
|
{
|
||||||
|
public static JobBase GetJob(this JobVehicle vehicle)
|
||||||
{
|
{
|
||||||
public static JobBase GetJob(this JobVehicle vehicle)
|
return JobManager.GetJob(vehicle.JobId);
|
||||||
{
|
|
||||||
return JobManager.GetJob(vehicle.JobId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vehicle GetVehicle(this ServerVehicle veh) => VehicleManager.GetVehicleFromServerVehicle(veh);
|
|
||||||
|
|
||||||
public static Vehicle Spawn(this ServerVehicle veh, Vehicle currentVeh = null)
|
|
||||||
{
|
|
||||||
if (currentVeh != null) VehicleManager.DeleteVehicle(currentVeh);
|
|
||||||
Vector3 position = veh.Position;
|
|
||||||
uint model = (uint)veh.Model;
|
|
||||||
float heading = veh.Heading;
|
|
||||||
int c1 = veh.PrimaryColor;
|
|
||||||
int c2 = veh.SecondaryColor;
|
|
||||||
Vehicle newVeh = NAPI.Vehicle.CreateVehicle(model, position, heading, c1, c2, "", 255, false, false);
|
|
||||||
veh.Livery = veh.Livery;
|
|
||||||
VehicleStreaming.SetEngineState(newVeh, false);
|
|
||||||
VehicleStreaming.SetLockStatus(newVeh, veh.Locked);
|
|
||||||
VehicleManager.AddVehicle(veh, newVeh);
|
|
||||||
newVeh.Rotation = new Vector3(0, 0, heading);
|
|
||||||
|
|
||||||
newVeh.SetSharedData("drivenDistance", veh.DistanceDriven);
|
|
||||||
|
|
||||||
string numberplate = $"{veh.Id}";
|
|
||||||
|
|
||||||
if (veh is FactionVehicle fV)
|
|
||||||
{
|
|
||||||
numberplate = $"F{string.Join(".", fV.GetOwners())} " + numberplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (veh is UserVehicle uV)
|
|
||||||
{
|
|
||||||
numberplate = $"U{uV.UserId} " + numberplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (veh is ShopVehicle sV)
|
|
||||||
{
|
|
||||||
numberplate = "Shop";
|
|
||||||
VehicleStreaming.SetLockStatus(newVeh, false);
|
|
||||||
TextLabel label = NAPI.TextLabel.CreateTextLabel("SHOPVEHICLE\n" + "~g~" + sV.Price.ToMoneyString(),
|
|
||||||
veh.Position.Add(new Vector3(0, 0, 1.3)), 20.0f, 1f, 1, new Color(255, 255, 255));
|
|
||||||
|
|
||||||
newVeh.SetSharedData("shopVehicleTextLabel", label.Handle.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (veh is GroupVehicle gV)
|
|
||||||
{
|
|
||||||
numberplate = $"G{gV.GroupId} " + numberplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (veh is JobVehicle jV)
|
|
||||||
{
|
|
||||||
numberplate = $"J{jV.JobId} " + numberplate;
|
|
||||||
}
|
|
||||||
NAPI.Vehicle.SetVehicleNumberPlate(newVeh, numberplate);
|
|
||||||
veh.NumberPlate = numberplate;
|
|
||||||
|
|
||||||
return newVeh;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Vehicle GetVehicle(this ServerVehicle veh) => VehicleManager.GetVehicleFromServerVehicle(veh);
|
||||||
|
|
||||||
|
public static Vehicle Spawn(this ServerVehicle veh, Vehicle currentVeh = null)
|
||||||
|
{
|
||||||
|
if (currentVeh != null) VehicleManager.DeleteVehicle(currentVeh);
|
||||||
|
Vector3 position = veh.Position;
|
||||||
|
uint model = (uint)veh.Model;
|
||||||
|
float heading = veh.Heading;
|
||||||
|
int c1 = veh.PrimaryColor;
|
||||||
|
int c2 = veh.SecondaryColor;
|
||||||
|
Vehicle newVeh = NAPI.Vehicle.CreateVehicle(model, position, heading, c1, c2, "", 255, false, false);
|
||||||
|
veh.Livery = veh.Livery;
|
||||||
|
VehicleStreaming.SetEngineState(newVeh, false);
|
||||||
|
VehicleStreaming.SetLockStatus(newVeh, veh.Locked);
|
||||||
|
VehicleManager.AddVehicle(veh, newVeh);
|
||||||
|
newVeh.Rotation = new Vector3(0, 0, heading);
|
||||||
|
|
||||||
|
newVeh.SetSharedData("drivenDistance", veh.DistanceDriven);
|
||||||
|
|
||||||
|
string numberplate = $"{veh.Id}";
|
||||||
|
|
||||||
|
if (veh is FactionVehicle fV)
|
||||||
|
{
|
||||||
|
numberplate = $"F{string.Join(".", fV.GetOwners())} " + numberplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (veh is UserVehicle uV)
|
||||||
|
{
|
||||||
|
numberplate = $"U{uV.UserId} " + numberplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (veh is ShopVehicle sV)
|
||||||
|
{
|
||||||
|
numberplate = "Shop";
|
||||||
|
VehicleStreaming.SetLockStatus(newVeh, false);
|
||||||
|
TextLabel label = NAPI.TextLabel.CreateTextLabel("SHOPVEHICLE\n" + "~g~" + sV.Price.ToMoneyString(),
|
||||||
|
veh.Position.Add(new Vector3(0, 0, 1.3)), 20.0f, 1f, 1, new Color(255, 255, 255));
|
||||||
|
|
||||||
|
newVeh.SetSharedData("shopVehicleTextLabel", label.Handle.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (veh is GroupVehicle gV)
|
||||||
|
{
|
||||||
|
numberplate = $"G{gV.GroupId} " + numberplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (veh is JobVehicle jV)
|
||||||
|
{
|
||||||
|
numberplate = $"J{jV.JobId} " + numberplate;
|
||||||
|
}
|
||||||
|
NAPI.Vehicle.SetVehicleNumberPlate(newVeh, numberplate);
|
||||||
|
veh.NumberPlate = numberplate;
|
||||||
|
|
||||||
|
return newVeh;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ using ReallifeGamemode.Server.Managers;
|
|||||||
namespace ReallifeGamemode.Server.Extensions
|
namespace ReallifeGamemode.Server.Extensions
|
||||||
{
|
{
|
||||||
public static class VehicleExtension
|
public static class VehicleExtension
|
||||||
|
{
|
||||||
|
public static ServerVehicle GetServerVehicle(this Vehicle veh, DatabaseContext context = null)
|
||||||
{
|
{
|
||||||
public static ServerVehicle GetServerVehicle(this Vehicle veh, DatabaseContext context = null)
|
return VehicleManager.GetServerVehicleFromVehicle(veh, context);
|
||||||
{
|
|
||||||
return VehicleManager.GetServerVehicleFromVehicle(veh, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Player GetDriver(this Vehicle veh)
|
|
||||||
{
|
|
||||||
return NAPI.Pools.GetAllPlayers().Where(p => p.Vehicle.Handle == veh.Handle && p.VehicleSeat == 0).FirstOrDefault();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Player GetDriver(this Vehicle veh)
|
||||||
|
{
|
||||||
|
return NAPI.Pools.GetAllPlayers().Where(p => p.Vehicle.Handle == veh.Handle && p.VehicleSeat == 0).FirstOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,93 +11,93 @@ using Newtonsoft.Json;
|
|||||||
namespace ReallifeGamemode.Server.Factions.Medic
|
namespace ReallifeGamemode.Server.Factions.Medic
|
||||||
{
|
{
|
||||||
public class Medic : Script
|
public class Medic : Script
|
||||||
|
{
|
||||||
|
public static List<MedicTask> ReviveTasks = new List<MedicTask>();
|
||||||
|
public static List<MedicTask> HealTasks = new List<MedicTask>();
|
||||||
|
public static List<MedicTask> FireTasks = new List<MedicTask>();
|
||||||
|
|
||||||
|
public static void AddTaskToList(MedicTask task)
|
||||||
{
|
{
|
||||||
public static List<MedicTask> ReviveTasks = new List<MedicTask>();
|
if (task == null)
|
||||||
public static List<MedicTask> HealTasks = new List<MedicTask>();
|
{
|
||||||
public static List<MedicTask> FireTasks = new List<MedicTask>();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
public static void AddTaskToList(MedicTask task)
|
switch (task.Type)
|
||||||
{
|
{
|
||||||
if (task == null)
|
case MedicTaskType.REVIVE:
|
||||||
{
|
ReviveTasks.Add(task);
|
||||||
return;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
switch (task.Type)
|
case MedicTaskType.HEAL:
|
||||||
{
|
HealTasks.Add(task);
|
||||||
case MedicTaskType.REVIVE:
|
break;
|
||||||
ReviveTasks.Add(task);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MedicTaskType.HEAL:
|
case MedicTaskType.FIRE:
|
||||||
HealTasks.Add(task);
|
FireTasks.Add(task);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case MedicTaskType.FIRE:
|
|
||||||
FireTasks.Add(task);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void RemoveTaskFromList(MedicTask task)
|
|
||||||
{
|
|
||||||
if (task == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (task.Type)
|
|
||||||
{
|
|
||||||
case MedicTaskType.REVIVE:
|
|
||||||
ReviveTasks.Remove(task);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MedicTaskType.HEAL:
|
|
||||||
HealTasks.Remove(task);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MedicTaskType.FIRE:
|
|
||||||
FireTasks.Remove(task);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("loadMedicTasks")]
|
|
||||||
public void LoadMedicTasks(Player player, int type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
player.TriggerEvent("showMedicTasks", 0, JsonConvert.SerializeObject(ReviveTasks));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
player.TriggerEvent("showMedicTasks", 1, JsonConvert.SerializeObject(HealTasks));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
player.TriggerEvent("showMedicTasks", 2, JsonConvert.SerializeObject(FireTasks));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("updateMedicTask")]
|
|
||||||
public void UpdateMedicTasks(Player player, int type, int index, string medicName)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
ReviveTasks[index].MedicName = medicName;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
HealTasks[index].MedicName = medicName;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
FireTasks[index].MedicName = medicName;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void RemoveTaskFromList(MedicTask task)
|
||||||
|
{
|
||||||
|
if (task == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (task.Type)
|
||||||
|
{
|
||||||
|
case MedicTaskType.REVIVE:
|
||||||
|
ReviveTasks.Remove(task);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MedicTaskType.HEAL:
|
||||||
|
HealTasks.Remove(task);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MedicTaskType.FIRE:
|
||||||
|
FireTasks.Remove(task);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("loadMedicTasks")]
|
||||||
|
public void LoadMedicTasks(Player player, int type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
player.TriggerEvent("showMedicTasks", 0, JsonConvert.SerializeObject(ReviveTasks));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
player.TriggerEvent("showMedicTasks", 1, JsonConvert.SerializeObject(HealTasks));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
player.TriggerEvent("showMedicTasks", 2, JsonConvert.SerializeObject(FireTasks));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("updateMedicTask")]
|
||||||
|
public void UpdateMedicTasks(Player player, int type, int index, string medicName)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
ReviveTasks[index].MedicName = medicName;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
HealTasks[index].MedicName = medicName;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
FireTasks[index].MedicName = medicName;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,21 +10,21 @@ using GTANetworkAPI;
|
|||||||
namespace ReallifeGamemode.Server.Factions.Medic
|
namespace ReallifeGamemode.Server.Factions.Medic
|
||||||
{
|
{
|
||||||
public class MedicTask
|
public class MedicTask
|
||||||
{
|
{
|
||||||
public string Victim { get; set; }
|
public string Victim { get; set; }
|
||||||
public Vector3 Position { get; set; }
|
public Vector3 Position { get; set; }
|
||||||
public MedicTaskType Type { get; set; }
|
public MedicTaskType Type { get; set; }
|
||||||
public string CauseOfDeath { get; set; }
|
public string CauseOfDeath { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public string Caller { get; set; }
|
public string Caller { get; set; }
|
||||||
public DateTime Time { get; set; }
|
public DateTime Time { get; set; }
|
||||||
public string MedicName { get; set; }
|
public string MedicName { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum MedicTaskType
|
public enum MedicTaskType
|
||||||
{
|
{
|
||||||
REVIVE,
|
REVIVE,
|
||||||
HEAL,
|
HEAL,
|
||||||
FIRE
|
FIRE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,64 +18,64 @@ using ReallifeGamemode.Server.Services;
|
|||||||
namespace ReallifeGamemode.Server.Finance
|
namespace ReallifeGamemode.Server.Finance
|
||||||
{
|
{
|
||||||
public class Economy
|
public class Economy
|
||||||
|
{
|
||||||
|
public static Dictionary<int, Paycheck> Paychecks { get; set; } = new Dictionary<int, Paycheck>();
|
||||||
|
|
||||||
|
public static (int, float, float) GetEconomyClass(Player client, int wage)
|
||||||
{
|
{
|
||||||
public static Dictionary<int, Paycheck> Paychecks { get; set; } = new Dictionary<int, Paycheck>();
|
int bankAccount = client.GetUser().BankAccount.Balance;
|
||||||
|
float financialHelp = -(float)Math.Pow(1.0005, -bankAccount) * -1000;
|
||||||
|
float financialInterest = 1 - (float)Math.Pow(1.00006, -wage) * 1;
|
||||||
|
if (financialInterest >= 0.7)
|
||||||
|
financialInterest = 0.7f;
|
||||||
|
|
||||||
public static (int, float, float) GetEconomyClass(Player client, int wage)
|
if (financialHelp > 2500)
|
||||||
|
financialHelp = 2500;
|
||||||
|
|
||||||
|
return (bankAccount, financialHelp, financialInterest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetVehicleTaxation(Player client)
|
||||||
|
{
|
||||||
|
int vehicleTaxation = 0;
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
User user = client.GetUser(dbContext);
|
||||||
|
foreach (UserVehicle uVeh in dbContext.UserVehicles.Where(u => u.UserId == user.Id))
|
||||||
{
|
{
|
||||||
int bankAccount = client.GetUser().BankAccount.Balance;
|
if (uVeh.Price == null)
|
||||||
float financialHelp = -(float)Math.Pow(1.0005, -bankAccount) * -1000;
|
{
|
||||||
float financialInterest = 1 - (float)Math.Pow(1.00006, -wage) * 1;
|
vehicleTaxation += 400;
|
||||||
if (financialInterest >= 0.7)
|
continue;
|
||||||
financialInterest = 0.7f;
|
}
|
||||||
|
vehicleTaxation += (int)(uVeh.Price * 0.005f);
|
||||||
if (financialHelp > 2500)
|
|
||||||
financialHelp = 2500;
|
|
||||||
|
|
||||||
return (bankAccount, financialHelp, financialInterest);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return vehicleTaxation;
|
||||||
|
}
|
||||||
|
|
||||||
public static int GetVehicleTaxation(Player client)
|
public static float GetPropertyTaxation(Player client)
|
||||||
{
|
{
|
||||||
int vehicleTaxation = 0;
|
float propertyTaxation = 0;
|
||||||
using (var dbContext = new DatabaseContext())
|
User user = client.GetUser();
|
||||||
{
|
if (user.HouseId != null)
|
||||||
User user = client.GetUser(dbContext);
|
{
|
||||||
foreach (UserVehicle uVeh in dbContext.UserVehicles.Where(u => u.UserId == user.Id))
|
propertyTaxation += user.House.Price * 0.005f;
|
||||||
{
|
}
|
||||||
if (uVeh.Price == null)
|
|
||||||
{
|
|
||||||
vehicleTaxation += 400;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
vehicleTaxation += (int)(uVeh.Price * 0.005f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return vehicleTaxation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float GetPropertyTaxation(Player client)
|
return propertyTaxation;
|
||||||
{
|
}
|
||||||
float propertyTaxation = 0;
|
|
||||||
User user = client.GetUser();
|
|
||||||
if (user.HouseId != null)
|
|
||||||
{
|
|
||||||
propertyTaxation += user.House.Price * 0.005f;
|
|
||||||
}
|
|
||||||
|
|
||||||
return propertyTaxation;
|
public static void SetPaycheck(Player client)
|
||||||
}
|
{
|
||||||
|
User user = client.GetUser();
|
||||||
|
int wage = user.Wage;
|
||||||
|
(int bankAccount, float financialHelp, float financialInterest) = GetEconomyClass(client, wage);
|
||||||
|
float propertyTax = GetPropertyTaxation(client);
|
||||||
|
int vehicleTaxation = GetVehicleTaxation(client);
|
||||||
|
int rentalFees = GetRentalFees(client);
|
||||||
|
|
||||||
public static void SetPaycheck(Player client)
|
int healthInsurance = (int)(user.BankAccount.Balance * 0.001);
|
||||||
{
|
|
||||||
User user = client.GetUser();
|
|
||||||
int wage = user.Wage;
|
|
||||||
(int bankAccount, float financialHelp, float financialInterest) = GetEconomyClass(client, wage);
|
|
||||||
float propertyTax = GetPropertyTaxation(client);
|
|
||||||
int vehicleTaxation = GetVehicleTaxation(client);
|
|
||||||
int rentalFees = GetRentalFees(client);
|
|
||||||
|
|
||||||
int healthInsurance = (int)(user.BankAccount.Balance * 0.001);
|
|
||||||
|
|
||||||
int? factionMoney = null;
|
int? factionMoney = null;
|
||||||
|
|
||||||
@@ -91,85 +91,85 @@ namespace ReallifeGamemode.Server.Finance
|
|||||||
ReleasePayDay(client, paycheck);
|
ReleasePayDay(client, paycheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int GetRentalFees(Player client)
|
private static int GetRentalFees(Player client)
|
||||||
{
|
{
|
||||||
using (var dbContext = new DatabaseContext())
|
using (var dbContext = new DatabaseContext())
|
||||||
{
|
{
|
||||||
User user = client.GetUser();
|
User user = client.GetUser();
|
||||||
return dbContext.HouseRentals.Where(h => h.UserId == user.Id).Include(h => h.House).Sum(h => h.House.RentalFee);
|
return dbContext.HouseRentals.Where(h => h.UserId == user.Id).Include(h => h.House).Sum(h => h.House.RentalFee);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void ReleasePayDay(Player client, Paycheck paycheck)
|
|
||||||
{
|
|
||||||
NAPI.Util.ConsoleOutput("in release payday");
|
|
||||||
if (client == null || paycheck == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
NAPI.Util.ConsoleOutput($"client = {client.Name}, paycheck = {JsonConvert.SerializeObject(paycheck)}");
|
|
||||||
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
User u = client.GetUser(dbContext);
|
|
||||||
NAPI.Util.ConsoleOutput("get user");
|
|
||||||
u.BankAccount.Balance += paycheck.Amount;
|
|
||||||
u.Wage = 0;
|
|
||||||
|
|
||||||
u.PaydayTimer = 60;
|
|
||||||
|
|
||||||
NAPI.Util.ConsoleOutput("set sachen");
|
|
||||||
|
|
||||||
var rentals = dbContext.HouseRentals
|
|
||||||
.Include(hR => hR.House)
|
|
||||||
.ThenInclude(h => h.BankAccount)
|
|
||||||
.Where(hR => hR.UserId == u.Id);
|
|
||||||
|
|
||||||
NAPI.Util.ConsoleOutput("get rentals");
|
|
||||||
|
|
||||||
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += (int)(paycheck.HealthInsurance * 0.1);
|
|
||||||
|
|
||||||
if (rentals.Any())
|
|
||||||
{
|
|
||||||
NAPI.Util.ConsoleOutput("hat rentals");
|
|
||||||
foreach (var rental in rentals)
|
|
||||||
{
|
|
||||||
if (rental?.House?.BankAccount != null)
|
|
||||||
{
|
|
||||||
rental.House.BankAccount.Balance += (int)(rental.House.RentalFee * 0.7);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
if (paycheck.Amount > 0)
|
|
||||||
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt + $~g~" + paycheck.Amount + "~s~.");
|
|
||||||
else
|
|
||||||
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt - $~r~" + paycheck.Amount + "~s~.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Timer_Elapsed()
|
|
||||||
{
|
|
||||||
using var dbContext = new DatabaseContext();
|
|
||||||
foreach (var player in NAPI.Pools.GetAllPlayers())
|
|
||||||
{
|
|
||||||
User user = player.GetUser(dbContext);
|
|
||||||
if (player.IsLoggedIn())
|
|
||||||
{
|
|
||||||
if (user.PaydayTimer <= 0)
|
|
||||||
{
|
|
||||||
Economy.SetPaycheck(player);
|
|
||||||
user.PaydayTimer = 60;
|
|
||||||
}
|
|
||||||
else if (user.PaydayTimer > 0)
|
|
||||||
{
|
|
||||||
user.PaydayTimer -= 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public static void ReleasePayDay(Player client, Paycheck paycheck)
|
||||||
|
{
|
||||||
|
NAPI.Util.ConsoleOutput("in release payday");
|
||||||
|
if (client == null || paycheck == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NAPI.Util.ConsoleOutput($"client = {client.Name}, paycheck = {JsonConvert.SerializeObject(paycheck)}");
|
||||||
|
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
User u = client.GetUser(dbContext);
|
||||||
|
NAPI.Util.ConsoleOutput("get user");
|
||||||
|
u.BankAccount.Balance += paycheck.Amount;
|
||||||
|
u.Wage = 0;
|
||||||
|
|
||||||
|
u.PaydayTimer = 60;
|
||||||
|
|
||||||
|
NAPI.Util.ConsoleOutput("set sachen");
|
||||||
|
|
||||||
|
var rentals = dbContext.HouseRentals
|
||||||
|
.Include(hR => hR.House)
|
||||||
|
.ThenInclude(h => h.BankAccount)
|
||||||
|
.Where(hR => hR.UserId == u.Id);
|
||||||
|
|
||||||
|
NAPI.Util.ConsoleOutput("get rentals");
|
||||||
|
|
||||||
|
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += (int)(paycheck.HealthInsurance * 0.1);
|
||||||
|
|
||||||
|
if (rentals.Any())
|
||||||
|
{
|
||||||
|
NAPI.Util.ConsoleOutput("hat rentals");
|
||||||
|
foreach (var rental in rentals)
|
||||||
|
{
|
||||||
|
if (rental?.House?.BankAccount != null)
|
||||||
|
{
|
||||||
|
rental.House.BankAccount.Balance += (int)(rental.House.RentalFee * 0.7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
if (paycheck.Amount > 0)
|
||||||
|
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt + $~g~" + paycheck.Amount + "~s~.");
|
||||||
|
else
|
||||||
|
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt - $~r~" + paycheck.Amount + "~s~.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Timer_Elapsed()
|
||||||
|
{
|
||||||
|
using var dbContext = new DatabaseContext();
|
||||||
|
foreach (var player in NAPI.Pools.GetAllPlayers())
|
||||||
|
{
|
||||||
|
User user = player.GetUser(dbContext);
|
||||||
|
if (player.IsLoggedIn())
|
||||||
|
{
|
||||||
|
if (user.PaydayTimer <= 0)
|
||||||
|
{
|
||||||
|
Economy.SetPaycheck(player);
|
||||||
|
user.PaydayTimer = 60;
|
||||||
|
}
|
||||||
|
else if (user.PaydayTimer > 0)
|
||||||
|
{
|
||||||
|
user.PaydayTimer -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,30 +3,30 @@
|
|||||||
namespace ReallifeGamemode.Server.Finance
|
namespace ReallifeGamemode.Server.Finance
|
||||||
{
|
{
|
||||||
public class Paycheck
|
public class Paycheck
|
||||||
{
|
{
|
||||||
[JsonProperty("financialHelp")]
|
[JsonProperty("financialHelp")]
|
||||||
public float FinancialHelp { get; set; } = 0;
|
public float FinancialHelp { get; set; } = 0;
|
||||||
|
|
||||||
[JsonProperty("financialInterest")]
|
[JsonProperty("financialInterest")]
|
||||||
public float FinancialInterest { get; set; } = 0;
|
public float FinancialInterest { get; set; } = 0;
|
||||||
|
|
||||||
[JsonProperty("vehicleTaxation")]
|
[JsonProperty("vehicleTaxation")]
|
||||||
public int VehicleTaxation { get; set; } = 0;
|
public int VehicleTaxation { get; set; } = 0;
|
||||||
|
|
||||||
[JsonProperty("propertyTaxation")]
|
[JsonProperty("propertyTaxation")]
|
||||||
public float PropertyTaxation { get; set; } = 0;
|
public float PropertyTaxation { get; set; } = 0;
|
||||||
|
|
||||||
[JsonProperty("wage")]
|
[JsonProperty("wage")]
|
||||||
public int Wage { get; set; } = 0;
|
public int Wage { get; set; } = 0;
|
||||||
|
|
||||||
[JsonProperty("amount")]
|
[JsonProperty("amount")]
|
||||||
public int Amount { get; set; } = 0;
|
public int Amount { get; set; } = 0;
|
||||||
|
|
||||||
[JsonProperty("rentalFees")]
|
[JsonProperty("rentalFees")]
|
||||||
public int RentalFees { get; set; } = 0;
|
public int RentalFees { get; set; } = 0;
|
||||||
|
|
||||||
[JsonProperty("healthInsurance")]
|
[JsonProperty("healthInsurance")]
|
||||||
public int HealthInsurance { get; set; } = 0;
|
public int HealthInsurance { get; set; } = 0;
|
||||||
|
|
||||||
[JsonProperty("factionMoney")]
|
[JsonProperty("factionMoney")]
|
||||||
public int? FactionMoney { get; set; } = 0;
|
public int? FactionMoney { get; set; } = 0;
|
||||||
@@ -44,4 +44,4 @@ namespace ReallifeGamemode.Server.Finance
|
|||||||
this.FactionMoney = FactionMoney;
|
this.FactionMoney = FactionMoney;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,217 +10,217 @@ using ReallifeGamemode.Server.Services;
|
|||||||
namespace ReallifeGamemode.Server.Gangwar
|
namespace ReallifeGamemode.Server.Gangwar
|
||||||
{
|
{
|
||||||
public class Gangwar : Script
|
public class Gangwar : Script
|
||||||
|
{
|
||||||
|
public static Turf[] _loadedTurfs;
|
||||||
|
private static List<Turfs> turfs;
|
||||||
|
|
||||||
|
public static void loadTurfs()
|
||||||
{
|
{
|
||||||
public static Turf[] _loadedTurfs;
|
_loadedTurfs = null;
|
||||||
private static List<Turfs> turfs;
|
using (var context = new DatabaseContext())
|
||||||
|
{
|
||||||
public static void loadTurfs()
|
turfs = context.Turfs.Select(t => t).ToList();
|
||||||
|
List<Turf> turfing = new List<Turf>();
|
||||||
|
foreach (var t in turfs)
|
||||||
{
|
{
|
||||||
_loadedTurfs = null;
|
Turf newTurf = new Turf(t.Id, t.Name, t.Color, t.Owner, t.Value, t.MaxValue, t.Surplus);
|
||||||
using (var context = new DatabaseContext())
|
turfing.Add(newTurf);
|
||||||
{
|
|
||||||
turfs = context.Turfs.Select(t => t).ToList();
|
|
||||||
List<Turf> turfing = new List<Turf>();
|
|
||||||
foreach (var t in turfs)
|
|
||||||
{
|
|
||||||
Turf newTurf = new Turf(t.Id, t.Name, t.Color, t.Owner, t.Value, t.MaxValue, t.Surplus);
|
|
||||||
turfing.Add(newTurf);
|
|
||||||
}
|
|
||||||
_loadedTurfs = turfing.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadPlayer(Player client)
|
|
||||||
{
|
|
||||||
client.TriggerEvent("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadTurfs_ToAllPlayers()
|
|
||||||
{
|
|
||||||
NAPI.ClientEvent.TriggerClientEventForAll("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray()));
|
|
||||||
foreach (var l in NAPI.Pools.GetAllPlayers())
|
|
||||||
{
|
|
||||||
if (!l.IsLoggedIn() && !l.GetUser().FactionLeader)
|
|
||||||
return;
|
|
||||||
|
|
||||||
l.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void GangwarKill(Player killer, Player victim)
|
|
||||||
{
|
|
||||||
if (killer.HasData("GotInsideOfTurf") && victim.HasData("GotInsideOfTurf"))
|
|
||||||
{
|
|
||||||
foreach (var turf in getTurfs())
|
|
||||||
{
|
|
||||||
if (turf.getId() == victim.GetData<int>("inGangWar"))
|
|
||||||
{
|
|
||||||
turf.setKill(victim.GetUser().Faction.Name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Turf[] getTurfs()
|
|
||||||
{
|
|
||||||
return _loadedTurfs;
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("Gangarea:Enter")]
|
|
||||||
public void RmtEvent_TurfEnter(Player client, string jsonId)
|
|
||||||
{
|
|
||||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
|
||||||
|
|
||||||
foreach (var turf in getTurfs())
|
|
||||||
{
|
|
||||||
if (turf.getId() == id)
|
|
||||||
{
|
|
||||||
turf.enter(client);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("Gangarea:Leave")]
|
|
||||||
public void RmtEvent_TurfLeave(Player client, string jsonId)
|
|
||||||
{
|
|
||||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
|
||||||
|
|
||||||
foreach (var turf in getTurfs())
|
|
||||||
{
|
|
||||||
if (turf.getId() == id)
|
|
||||||
{
|
|
||||||
turf.leave(client);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("SERVER:SetTurf")]
|
|
||||||
public void RmtEvent_SetTurf(Player client, string jsonX, string jsonY, string jsonRot, string jsonRange, string Name)
|
|
||||||
{
|
|
||||||
float pX = JsonConvert.DeserializeObject<float>(jsonX);
|
|
||||||
float pY = (float)JsonConvert.DeserializeObject<float>(jsonY);
|
|
||||||
float Rot = (float)JsonConvert.DeserializeObject<float>(jsonRot);
|
|
||||||
float Range = (float)JsonConvert.DeserializeObject<float>(jsonRange);
|
|
||||||
|
|
||||||
var newTurf = new Turfs
|
|
||||||
{
|
|
||||||
Name = Name,
|
|
||||||
X = pX,
|
|
||||||
Y = pY,
|
|
||||||
Rotation = Rot,
|
|
||||||
Range = Range,
|
|
||||||
Owner = "Neutral",
|
|
||||||
Color = 0,
|
|
||||||
Vector = null
|
|
||||||
};
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
dbContext.Turfs.Add(newTurf);
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
loadTurfs();
|
|
||||||
loadTurfs_ToAllPlayers();
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("SERVER:DeleteTurf")]
|
|
||||||
public void RmtEvent_DeleteTurf(Player client, string jsonId)
|
|
||||||
{
|
|
||||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
|
||||||
if (id == -1)
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(client, "Du befindest dich in keinem Gebiet!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
Turfs dturf = dbContext.Turfs.Where(t => t.Id == id).FirstOrDefault();
|
|
||||||
if (dturf != null)
|
|
||||||
{
|
|
||||||
dbContext.Turfs.Remove(dturf);
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
loadTurfs();
|
|
||||||
loadTurfs_ToAllPlayers();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("SERVER:Turf_SetNewLeaderPoint")]
|
|
||||||
public void RmtEvent_SetNewLeaderPoint(Player client, string vector, string jsonId)
|
|
||||||
{
|
|
||||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
|
||||||
if (id == -1)
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(client, "Du befindest dich in keinem Gebiet");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
Turfs dturf = dbContext.Turfs.Where(t => t.Id == id).FirstOrDefault();
|
|
||||||
if (dturf != null)
|
|
||||||
{
|
|
||||||
dturf.Vector = vector;
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
loadTurfs();
|
|
||||||
loadTurfs_ToAllPlayers();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("SERVER:StartGangwar")]
|
|
||||||
public void RmtEvent_StartGangwar(Player client)
|
|
||||||
{
|
|
||||||
if (!client.GetUser().FactionLeader)
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach (var turf in getTurfs())
|
|
||||||
{
|
|
||||||
if (turf.status == "attack")
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(client, "Du kannst momentan kein Gangwar starten");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (client.GetUser().Faction.Name == "Ballas" || client.GetUser().Faction.Name == "Grove")
|
|
||||||
{
|
|
||||||
foreach (var turf in getTurfs())
|
|
||||||
{
|
|
||||||
foreach (var u in turf.playerInside)
|
|
||||||
{
|
|
||||||
if (u == client)
|
|
||||||
{
|
|
||||||
if (turf.Owner != client.GetUser().Faction.Name)
|
|
||||||
turf.attack(client.GetUser().Faction.Name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Value_TimerElapsed()
|
|
||||||
{
|
|
||||||
List<int> values = new List<int>();
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
foreach (var turf in getTurfs())
|
|
||||||
{
|
|
||||||
if ((turf.getValue() + 5) >= turf.getMaxValue())
|
|
||||||
{
|
|
||||||
turf.setValue(turf.getMaxValue());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
turf.addValue(5);
|
|
||||||
}
|
|
||||||
values.Add(turf.getValue());
|
|
||||||
Turfs _turf = dbContext.Turfs.Where(t => t.Id == turf.getId()).FirstOrDefault();
|
|
||||||
_turf.Value = turf.getValue();
|
|
||||||
}
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:UpdateTurfValue", JsonConvert.SerializeObject(values.ToArray()));
|
|
||||||
}
|
}
|
||||||
|
_loadedTurfs = turfing.ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void loadPlayer(Player client)
|
||||||
|
{
|
||||||
|
client.TriggerEvent("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadTurfs_ToAllPlayers()
|
||||||
|
{
|
||||||
|
NAPI.ClientEvent.TriggerClientEventForAll("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray()));
|
||||||
|
foreach (var l in NAPI.Pools.GetAllPlayers())
|
||||||
|
{
|
||||||
|
if (!l.IsLoggedIn() && !l.GetUser().FactionLeader)
|
||||||
|
return;
|
||||||
|
|
||||||
|
l.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void GangwarKill(Player killer, Player victim)
|
||||||
|
{
|
||||||
|
if (killer.HasData("GotInsideOfTurf") && victim.HasData("GotInsideOfTurf"))
|
||||||
|
{
|
||||||
|
foreach (var turf in getTurfs())
|
||||||
|
{
|
||||||
|
if (turf.getId() == victim.GetData<int>("inGangWar"))
|
||||||
|
{
|
||||||
|
turf.setKill(victim.GetUser().Faction.Name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Turf[] getTurfs()
|
||||||
|
{
|
||||||
|
return _loadedTurfs;
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("Gangarea:Enter")]
|
||||||
|
public void RmtEvent_TurfEnter(Player client, string jsonId)
|
||||||
|
{
|
||||||
|
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
||||||
|
|
||||||
|
foreach (var turf in getTurfs())
|
||||||
|
{
|
||||||
|
if (turf.getId() == id)
|
||||||
|
{
|
||||||
|
turf.enter(client);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("Gangarea:Leave")]
|
||||||
|
public void RmtEvent_TurfLeave(Player client, string jsonId)
|
||||||
|
{
|
||||||
|
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
||||||
|
|
||||||
|
foreach (var turf in getTurfs())
|
||||||
|
{
|
||||||
|
if (turf.getId() == id)
|
||||||
|
{
|
||||||
|
turf.leave(client);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("SERVER:SetTurf")]
|
||||||
|
public void RmtEvent_SetTurf(Player client, string jsonX, string jsonY, string jsonRot, string jsonRange, string Name)
|
||||||
|
{
|
||||||
|
float pX = JsonConvert.DeserializeObject<float>(jsonX);
|
||||||
|
float pY = (float)JsonConvert.DeserializeObject<float>(jsonY);
|
||||||
|
float Rot = (float)JsonConvert.DeserializeObject<float>(jsonRot);
|
||||||
|
float Range = (float)JsonConvert.DeserializeObject<float>(jsonRange);
|
||||||
|
|
||||||
|
var newTurf = new Turfs
|
||||||
|
{
|
||||||
|
Name = Name,
|
||||||
|
X = pX,
|
||||||
|
Y = pY,
|
||||||
|
Rotation = Rot,
|
||||||
|
Range = Range,
|
||||||
|
Owner = "Neutral",
|
||||||
|
Color = 0,
|
||||||
|
Vector = null
|
||||||
|
};
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
dbContext.Turfs.Add(newTurf);
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
loadTurfs();
|
||||||
|
loadTurfs_ToAllPlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("SERVER:DeleteTurf")]
|
||||||
|
public void RmtEvent_DeleteTurf(Player client, string jsonId)
|
||||||
|
{
|
||||||
|
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
||||||
|
if (id == -1)
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(client, "Du befindest dich in keinem Gebiet!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
Turfs dturf = dbContext.Turfs.Where(t => t.Id == id).FirstOrDefault();
|
||||||
|
if (dturf != null)
|
||||||
|
{
|
||||||
|
dbContext.Turfs.Remove(dturf);
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
loadTurfs();
|
||||||
|
loadTurfs_ToAllPlayers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("SERVER:Turf_SetNewLeaderPoint")]
|
||||||
|
public void RmtEvent_SetNewLeaderPoint(Player client, string vector, string jsonId)
|
||||||
|
{
|
||||||
|
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
||||||
|
if (id == -1)
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(client, "Du befindest dich in keinem Gebiet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
Turfs dturf = dbContext.Turfs.Where(t => t.Id == id).FirstOrDefault();
|
||||||
|
if (dturf != null)
|
||||||
|
{
|
||||||
|
dturf.Vector = vector;
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
loadTurfs();
|
||||||
|
loadTurfs_ToAllPlayers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("SERVER:StartGangwar")]
|
||||||
|
public void RmtEvent_StartGangwar(Player client)
|
||||||
|
{
|
||||||
|
if (!client.GetUser().FactionLeader)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var turf in getTurfs())
|
||||||
|
{
|
||||||
|
if (turf.status == "attack")
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(client, "Du kannst momentan kein Gangwar starten");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (client.GetUser().Faction.Name == "Ballas" || client.GetUser().Faction.Name == "Grove")
|
||||||
|
{
|
||||||
|
foreach (var turf in getTurfs())
|
||||||
|
{
|
||||||
|
foreach (var u in turf.playerInside)
|
||||||
|
{
|
||||||
|
if (u == client)
|
||||||
|
{
|
||||||
|
if (turf.Owner != client.GetUser().Faction.Name)
|
||||||
|
turf.attack(client.GetUser().Faction.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Value_TimerElapsed()
|
||||||
|
{
|
||||||
|
List<int> values = new List<int>();
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
foreach (var turf in getTurfs())
|
||||||
|
{
|
||||||
|
if ((turf.getValue() + 5) >= turf.getMaxValue())
|
||||||
|
{
|
||||||
|
turf.setValue(turf.getMaxValue());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
turf.addValue(5);
|
||||||
|
}
|
||||||
|
values.Add(turf.getValue());
|
||||||
|
Turfs _turf = dbContext.Turfs.Where(t => t.Id == turf.getId()).FirstOrDefault();
|
||||||
|
_turf.Value = turf.getValue();
|
||||||
|
}
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:UpdateTurfValue", JsonConvert.SerializeObject(values.ToArray()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,340 +13,340 @@ using ReallifeGamemode.Server.Services;
|
|||||||
namespace ReallifeGamemode.Server.Gangwar
|
namespace ReallifeGamemode.Server.Gangwar
|
||||||
{
|
{
|
||||||
public class Turf
|
public class Turf
|
||||||
|
{
|
||||||
|
public int TurfID { get; set; }
|
||||||
|
public string TurfName { get; set; }
|
||||||
|
public int Color { get; set; }
|
||||||
|
public string Owner { get; set; }
|
||||||
|
public string Attacker { get; set; }
|
||||||
|
public int Att_Score { get; set; }
|
||||||
|
public int Def_Score { get; set; }
|
||||||
|
public string status { get; set; }
|
||||||
|
public int value { get; set; }
|
||||||
|
public int maxValue { get; set; }
|
||||||
|
public bool surplus { get; set; }
|
||||||
|
public List<Player> playerInside { get; set; }
|
||||||
|
public Timer timer { get; set; }
|
||||||
|
public Player[] playerInGangwar { get; set; }
|
||||||
|
public int timerCount;
|
||||||
|
|
||||||
|
public Turf(int TurfID, string TurfName, int color, string Owner, int value, int maxValue, bool surplus)
|
||||||
{
|
{
|
||||||
public int TurfID { get; set; }
|
this.TurfID = TurfID;
|
||||||
public string TurfName { get; set; }
|
this.TurfName = TurfName;
|
||||||
public int Color { get; set; }
|
this.Color = color;
|
||||||
public string Owner { get; set; }
|
this.Owner = Owner;
|
||||||
public string Attacker { get; set; }
|
this.value = value;
|
||||||
public int Att_Score { get; set; }
|
this.maxValue = maxValue;
|
||||||
public int Def_Score { get; set; }
|
this.surplus = surplus;
|
||||||
public string status { get; set; }
|
this.Attacker = null;
|
||||||
public int value { get; set; }
|
this.Att_Score = 50;
|
||||||
public int maxValue { get; set; }
|
this.Def_Score = 50;
|
||||||
public bool surplus { get; set; }
|
this.status = "normal";
|
||||||
public List<Player> playerInside { get; set; }
|
this.timer = null;
|
||||||
public Timer timer { get; set; }
|
this.playerInside = new List<Player>();
|
||||||
public Player[] playerInGangwar { get; set; }
|
this.timerCount = 0;
|
||||||
public int timerCount;
|
|
||||||
|
|
||||||
public Turf(int TurfID, string TurfName, int color, string Owner, int value, int maxValue, bool surplus)
|
|
||||||
{
|
|
||||||
this.TurfID = TurfID;
|
|
||||||
this.TurfName = TurfName;
|
|
||||||
this.Color = color;
|
|
||||||
this.Owner = Owner;
|
|
||||||
this.value = value;
|
|
||||||
this.maxValue = maxValue;
|
|
||||||
this.surplus = surplus;
|
|
||||||
this.Attacker = null;
|
|
||||||
this.Att_Score = 50;
|
|
||||||
this.Def_Score = 50;
|
|
||||||
this.status = "normal";
|
|
||||||
this.timer = null;
|
|
||||||
this.playerInside = new List<Player>();
|
|
||||||
this.timerCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId()
|
|
||||||
{
|
|
||||||
return this.TurfID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getValue()
|
|
||||||
{
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(int value)
|
|
||||||
{
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addValue(int addedValue)
|
|
||||||
{
|
|
||||||
this.value += addedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxValue()
|
|
||||||
{
|
|
||||||
return maxValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool getSurplus()
|
|
||||||
{
|
|
||||||
return surplus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSurplus(bool surplus)
|
|
||||||
{
|
|
||||||
this.surplus = surplus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string getName()
|
|
||||||
{
|
|
||||||
return this.TurfName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getColor()
|
|
||||||
{
|
|
||||||
return this.Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string getOwner()
|
|
||||||
{
|
|
||||||
return this.Owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string getAttacker()
|
|
||||||
{
|
|
||||||
return this.Attacker;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TurfTick()
|
|
||||||
{
|
|
||||||
this.timer = new System.Timers.Timer(1000);
|
|
||||||
|
|
||||||
this.timer.Elapsed += Tick;
|
|
||||||
this.timer.AutoReset = true;
|
|
||||||
this.timer.Enabled = true;
|
|
||||||
this.timerCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Tick(object sender, System.Timers.ElapsedEventArgs e)
|
|
||||||
{
|
|
||||||
if (this.status == "attack")
|
|
||||||
{
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void update()
|
|
||||||
{
|
|
||||||
#region Ticket system
|
|
||||||
|
|
||||||
/*
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Owner).ToArray();
|
|
||||||
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Attacker).ToArray();
|
|
||||||
}catch(NullReferenceException ex)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
foreach(var c in playerInGangwar)
|
|
||||||
{
|
|
||||||
if (!NAPI.Entity.DoesEntityExist(c.Handle))
|
|
||||||
{
|
|
||||||
this.playerInside = this.playerInside.Where(gp => gp != c).ToArray();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (owners.Length > attackers.Length)
|
|
||||||
this.Att_Score -= owners.Length - attackers.Length;
|
|
||||||
if(owners.Length < attackers.Length)
|
|
||||||
this.Def_Score -= attackers.Length - owners.Length;
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endregion Ticket system
|
|
||||||
|
|
||||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
|
||||||
{
|
|
||||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
|
||||||
}
|
|
||||||
if (this.Def_Score <= 0)
|
|
||||||
{
|
|
||||||
this.takeOver(this.Attacker);
|
|
||||||
}
|
|
||||||
else if (this.Att_Score <= 0)
|
|
||||||
{
|
|
||||||
this.takeOver(this.Owner);
|
|
||||||
}
|
|
||||||
timerCount += 1;
|
|
||||||
if (timerCount >= 900) //change to 900 (seconds) before release for testing reasons change to whatever you like
|
|
||||||
{
|
|
||||||
if (this.Def_Score > this.Att_Score)
|
|
||||||
{
|
|
||||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
|
||||||
{
|
|
||||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
|
||||||
}
|
|
||||||
this.takeOver(this.Owner);
|
|
||||||
this.Att_Score = 0;
|
|
||||||
}
|
|
||||||
else if (this.Def_Score < this.Att_Score)
|
|
||||||
{
|
|
||||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
|
||||||
{
|
|
||||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
|
||||||
}
|
|
||||||
this.takeOver(this.Attacker);
|
|
||||||
this.Def_Score = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (this.Def_Score == this.Att_Score)
|
|
||||||
{
|
|
||||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
|
||||||
{
|
|
||||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
|
||||||
}
|
|
||||||
this.takeOver(this.Attacker);
|
|
||||||
this.Def_Score = 0;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enter(Player client)
|
|
||||||
{
|
|
||||||
if (this.status == "attack")
|
|
||||||
{
|
|
||||||
if (client.GetUser().Faction.Name != getOwner() && client.GetUser().Faction.Name != getAttacker())
|
|
||||||
return;
|
|
||||||
Player gPlayer = playerInGangwar.Where(c => c.GetUser().Id == client.GetUser().Id).FirstOrDefault();
|
|
||||||
if (gPlayer == null)
|
|
||||||
{
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~r~" + client.Name + "~w~ ist nicht im Gangwar beteiligt !", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
|
||||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~r~" + client.Name + "~w~ ist nicht im Gangwar beteiligt !", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (playerInside.Find(c => c == client) == null)
|
|
||||||
{
|
|
||||||
playerInside.Add(client);
|
|
||||||
client.SetData("GotInsideOfTurf", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void leave(Player client)
|
|
||||||
{
|
|
||||||
if (playerInside.Find(c => c == client) != null)
|
|
||||||
{
|
|
||||||
this.playerInside = this.playerInside.Where(c => c != client).ToList();
|
|
||||||
if (this.status != "attack")
|
|
||||||
client.ResetData("GotInsideOfTurf");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void takeOver(string FactionName)
|
|
||||||
{
|
|
||||||
this.timer.Stop();
|
|
||||||
this.timer = null;
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
if (getOwner() == FactionName)
|
|
||||||
{
|
|
||||||
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray();
|
|
||||||
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray();
|
|
||||||
foreach (var o in owners)
|
|
||||||
{
|
|
||||||
o.TriggerEvent("CLIENT:win");
|
|
||||||
}
|
|
||||||
foreach (var a in attackers)
|
|
||||||
{
|
|
||||||
a.TriggerEvent("CLIENT:loose");
|
|
||||||
}
|
|
||||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat erfolgreich das Gebiet ~g~" + getName() + "~w~ verteidigt.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
|
||||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat den Angrif auf das Gebiet ~r~" + getName() + "~w~ verloren.", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
|
|
||||||
}
|
|
||||||
else if (getOwner() != FactionName)
|
|
||||||
{
|
|
||||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht verteidigen.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
|
||||||
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray();
|
|
||||||
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray();
|
|
||||||
foreach (var o in owners)
|
|
||||||
{
|
|
||||||
o.TriggerEvent("CLIENT:loose");
|
|
||||||
}
|
|
||||||
foreach (var a in attackers)
|
|
||||||
{
|
|
||||||
a.TriggerEvent("CLIENT:win");
|
|
||||||
}
|
|
||||||
this.Owner = FactionName;
|
|
||||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte erfolgreich das Gebiet ~g~" + getName() + "~w~ erobern.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
|
||||||
Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault();
|
|
||||||
turf.Owner = this.Owner;
|
|
||||||
turf.FactionId = dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault().Id;
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.Attacker = null;
|
|
||||||
foreach (var c in playerInGangwar)
|
|
||||||
{
|
|
||||||
c.TriggerEvent("CLIENT:setAttackBlip", false, TurfID);
|
|
||||||
c.ResetData("inGangWar");
|
|
||||||
c.ResetData("GotInsideOfTurf");
|
|
||||||
}
|
|
||||||
this.playerInGangwar = null;
|
|
||||||
Gangwar.loadTurfs();
|
|
||||||
Gangwar.loadTurfs_ToAllPlayers();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void attack(string attacker)
|
|
||||||
{
|
|
||||||
Player[] usersInGangwar;
|
|
||||||
using (var context = new DatabaseContext())
|
|
||||||
{
|
|
||||||
var onlinePlayers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn()).Select(c => c.Name);
|
|
||||||
|
|
||||||
List<Player> ownersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == getOwner()).Select(u => u.Player).ToList();
|
|
||||||
List<Player> attackersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == attacker).Select(u => u.Player).ToList();
|
|
||||||
|
|
||||||
if (ownersInGangwar.Count < 1 && attackersInGangwar.Count < 1)
|
|
||||||
{
|
|
||||||
List<Player> leaders = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == attacker && u.FactionLeader).Select(u => u.Player).ToList();
|
|
||||||
foreach (var l in leaders)
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(l, "Gangwarstart ist nicht möglich, da die beteiligten Fraktionen nicht genügend Mitglieder aufweisen.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<Player> inGangwar = new List<Player>(ownersInGangwar.Concat(attackersInGangwar));
|
|
||||||
|
|
||||||
usersInGangwar = inGangwar.ToArray();
|
|
||||||
}
|
|
||||||
if (this.status == "normal")
|
|
||||||
{
|
|
||||||
if (this.timer != null)
|
|
||||||
{
|
|
||||||
this.timer.Stop();
|
|
||||||
this.timer = null;
|
|
||||||
}
|
|
||||||
this.Attacker = attacker;
|
|
||||||
this.status = "attack";
|
|
||||||
|
|
||||||
List<Player> clientsInGangwar = new List<Player>();
|
|
||||||
|
|
||||||
foreach (var u in usersInGangwar)
|
|
||||||
{
|
|
||||||
u.TriggerEvent("CLIENT:setAttackBlip", true, TurfID);
|
|
||||||
u.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
|
||||||
u.SetData("inGangWar", getId());
|
|
||||||
ChatService.SendMessage(u, "~y~[GANGWAR]~w~ Die " + getAttacker() + " haben das Gebiet ~y~" + TurfName + "~w~ der " + getOwner() + " angegriffen.");
|
|
||||||
clientsInGangwar.Add(u);
|
|
||||||
}
|
|
||||||
playerInGangwar = clientsInGangwar.ToArray();
|
|
||||||
NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:Turf_Update", JsonConvert.SerializeObject(this.TurfID), JsonConvert.SerializeObject(this.status), JsonConvert.SerializeObject(this.Owner), JsonConvert.SerializeObject(this.Attacker));
|
|
||||||
this.TurfTick();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKill(string FactionName)
|
|
||||||
{
|
|
||||||
if (getOwner() == FactionName)
|
|
||||||
{
|
|
||||||
Def_Score -= 1;
|
|
||||||
}
|
|
||||||
else if (getAttacker() == FactionName)
|
|
||||||
{
|
|
||||||
Att_Score -= 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getId()
|
||||||
|
{
|
||||||
|
return this.TurfID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue()
|
||||||
|
{
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(int value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addValue(int addedValue)
|
||||||
|
{
|
||||||
|
this.value += addedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxValue()
|
||||||
|
{
|
||||||
|
return maxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool getSurplus()
|
||||||
|
{
|
||||||
|
return surplus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSurplus(bool surplus)
|
||||||
|
{
|
||||||
|
this.surplus = surplus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string getName()
|
||||||
|
{
|
||||||
|
return this.TurfName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColor()
|
||||||
|
{
|
||||||
|
return this.Color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string getOwner()
|
||||||
|
{
|
||||||
|
return this.Owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string getAttacker()
|
||||||
|
{
|
||||||
|
return this.Attacker;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TurfTick()
|
||||||
|
{
|
||||||
|
this.timer = new System.Timers.Timer(1000);
|
||||||
|
|
||||||
|
this.timer.Elapsed += Tick;
|
||||||
|
this.timer.AutoReset = true;
|
||||||
|
this.timer.Enabled = true;
|
||||||
|
this.timerCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Tick(object sender, System.Timers.ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this.status == "attack")
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void update()
|
||||||
|
{
|
||||||
|
#region Ticket system
|
||||||
|
|
||||||
|
/*
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Owner).ToArray();
|
||||||
|
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Attacker).ToArray();
|
||||||
|
}catch(NullReferenceException ex)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
foreach(var c in playerInGangwar)
|
||||||
|
{
|
||||||
|
if (!NAPI.Entity.DoesEntityExist(c.Handle))
|
||||||
|
{
|
||||||
|
this.playerInside = this.playerInside.Where(gp => gp != c).ToArray();
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (owners.Length > attackers.Length)
|
||||||
|
this.Att_Score -= owners.Length - attackers.Length;
|
||||||
|
if(owners.Length < attackers.Length)
|
||||||
|
this.Def_Score -= attackers.Length - owners.Length;
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endregion Ticket system
|
||||||
|
|
||||||
|
foreach (Player gangwarPlayer in this.playerInGangwar)
|
||||||
|
{
|
||||||
|
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
||||||
|
}
|
||||||
|
if (this.Def_Score <= 0)
|
||||||
|
{
|
||||||
|
this.takeOver(this.Attacker);
|
||||||
|
}
|
||||||
|
else if (this.Att_Score <= 0)
|
||||||
|
{
|
||||||
|
this.takeOver(this.Owner);
|
||||||
|
}
|
||||||
|
timerCount += 1;
|
||||||
|
if (timerCount >= 900) //change to 900 (seconds) before release for testing reasons change to whatever you like
|
||||||
|
{
|
||||||
|
if (this.Def_Score > this.Att_Score)
|
||||||
|
{
|
||||||
|
foreach (Player gangwarPlayer in this.playerInGangwar)
|
||||||
|
{
|
||||||
|
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
||||||
|
}
|
||||||
|
this.takeOver(this.Owner);
|
||||||
|
this.Att_Score = 0;
|
||||||
|
}
|
||||||
|
else if (this.Def_Score < this.Att_Score)
|
||||||
|
{
|
||||||
|
foreach (Player gangwarPlayer in this.playerInGangwar)
|
||||||
|
{
|
||||||
|
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
||||||
|
}
|
||||||
|
this.takeOver(this.Attacker);
|
||||||
|
this.Def_Score = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (this.Def_Score == this.Att_Score)
|
||||||
|
{
|
||||||
|
foreach (Player gangwarPlayer in this.playerInGangwar)
|
||||||
|
{
|
||||||
|
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
||||||
|
}
|
||||||
|
this.takeOver(this.Attacker);
|
||||||
|
this.Def_Score = 0;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enter(Player client)
|
||||||
|
{
|
||||||
|
if (this.status == "attack")
|
||||||
|
{
|
||||||
|
if (client.GetUser().Faction.Name != getOwner() && client.GetUser().Faction.Name != getAttacker())
|
||||||
|
return;
|
||||||
|
Player gPlayer = playerInGangwar.Where(c => c.GetUser().Id == client.GetUser().Id).FirstOrDefault();
|
||||||
|
if (gPlayer == null)
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
ChatService.BroadcastFaction("~y~[GANGWAR] ~r~" + client.Name + "~w~ ist nicht im Gangwar beteiligt !", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||||
|
ChatService.BroadcastFaction("~y~[GANGWAR] ~r~" + client.Name + "~w~ ist nicht im Gangwar beteiligt !", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playerInside.Find(c => c == client) == null)
|
||||||
|
{
|
||||||
|
playerInside.Add(client);
|
||||||
|
client.SetData("GotInsideOfTurf", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void leave(Player client)
|
||||||
|
{
|
||||||
|
if (playerInside.Find(c => c == client) != null)
|
||||||
|
{
|
||||||
|
this.playerInside = this.playerInside.Where(c => c != client).ToList();
|
||||||
|
if (this.status != "attack")
|
||||||
|
client.ResetData("GotInsideOfTurf");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void takeOver(string FactionName)
|
||||||
|
{
|
||||||
|
this.timer.Stop();
|
||||||
|
this.timer = null;
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
if (getOwner() == FactionName)
|
||||||
|
{
|
||||||
|
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray();
|
||||||
|
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray();
|
||||||
|
foreach (var o in owners)
|
||||||
|
{
|
||||||
|
o.TriggerEvent("CLIENT:win");
|
||||||
|
}
|
||||||
|
foreach (var a in attackers)
|
||||||
|
{
|
||||||
|
a.TriggerEvent("CLIENT:loose");
|
||||||
|
}
|
||||||
|
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat erfolgreich das Gebiet ~g~" + getName() + "~w~ verteidigt.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||||
|
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat den Angrif auf das Gebiet ~r~" + getName() + "~w~ verloren.", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
|
||||||
|
}
|
||||||
|
else if (getOwner() != FactionName)
|
||||||
|
{
|
||||||
|
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht verteidigen.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||||
|
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray();
|
||||||
|
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray();
|
||||||
|
foreach (var o in owners)
|
||||||
|
{
|
||||||
|
o.TriggerEvent("CLIENT:loose");
|
||||||
|
}
|
||||||
|
foreach (var a in attackers)
|
||||||
|
{
|
||||||
|
a.TriggerEvent("CLIENT:win");
|
||||||
|
}
|
||||||
|
this.Owner = FactionName;
|
||||||
|
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte erfolgreich das Gebiet ~g~" + getName() + "~w~ erobern.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||||
|
Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault();
|
||||||
|
turf.Owner = this.Owner;
|
||||||
|
turf.FactionId = dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault().Id;
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.Attacker = null;
|
||||||
|
foreach (var c in playerInGangwar)
|
||||||
|
{
|
||||||
|
c.TriggerEvent("CLIENT:setAttackBlip", false, TurfID);
|
||||||
|
c.ResetData("inGangWar");
|
||||||
|
c.ResetData("GotInsideOfTurf");
|
||||||
|
}
|
||||||
|
this.playerInGangwar = null;
|
||||||
|
Gangwar.loadTurfs();
|
||||||
|
Gangwar.loadTurfs_ToAllPlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void attack(string attacker)
|
||||||
|
{
|
||||||
|
Player[] usersInGangwar;
|
||||||
|
using (var context = new DatabaseContext())
|
||||||
|
{
|
||||||
|
var onlinePlayers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn()).Select(c => c.Name);
|
||||||
|
|
||||||
|
List<Player> ownersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == getOwner()).Select(u => u.Player).ToList();
|
||||||
|
List<Player> attackersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == attacker).Select(u => u.Player).ToList();
|
||||||
|
|
||||||
|
if (ownersInGangwar.Count < 1 && attackersInGangwar.Count < 1)
|
||||||
|
{
|
||||||
|
List<Player> leaders = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == attacker && u.FactionLeader).Select(u => u.Player).ToList();
|
||||||
|
foreach (var l in leaders)
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(l, "Gangwarstart ist nicht möglich, da die beteiligten Fraktionen nicht genügend Mitglieder aufweisen.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<Player> inGangwar = new List<Player>(ownersInGangwar.Concat(attackersInGangwar));
|
||||||
|
|
||||||
|
usersInGangwar = inGangwar.ToArray();
|
||||||
|
}
|
||||||
|
if (this.status == "normal")
|
||||||
|
{
|
||||||
|
if (this.timer != null)
|
||||||
|
{
|
||||||
|
this.timer.Stop();
|
||||||
|
this.timer = null;
|
||||||
|
}
|
||||||
|
this.Attacker = attacker;
|
||||||
|
this.status = "attack";
|
||||||
|
|
||||||
|
List<Player> clientsInGangwar = new List<Player>();
|
||||||
|
|
||||||
|
foreach (var u in usersInGangwar)
|
||||||
|
{
|
||||||
|
u.TriggerEvent("CLIENT:setAttackBlip", true, TurfID);
|
||||||
|
u.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
||||||
|
u.SetData("inGangWar", getId());
|
||||||
|
ChatService.SendMessage(u, "~y~[GANGWAR]~w~ Die " + getAttacker() + " haben das Gebiet ~y~" + TurfName + "~w~ der " + getOwner() + " angegriffen.");
|
||||||
|
clientsInGangwar.Add(u);
|
||||||
|
}
|
||||||
|
playerInGangwar = clientsInGangwar.ToArray();
|
||||||
|
NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:Turf_Update", JsonConvert.SerializeObject(this.TurfID), JsonConvert.SerializeObject(this.status), JsonConvert.SerializeObject(this.Owner), JsonConvert.SerializeObject(this.Attacker));
|
||||||
|
this.TurfTick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKill(string FactionName)
|
||||||
|
{
|
||||||
|
if (getOwner() == FactionName)
|
||||||
|
{
|
||||||
|
Def_Score -= 1;
|
||||||
|
}
|
||||||
|
else if (getAttacker() == FactionName)
|
||||||
|
{
|
||||||
|
Att_Score -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace ReallifeGamemode.Server.Inventory.Interfaces
|
namespace ReallifeGamemode.Server.Inventory.Interfaces
|
||||||
{
|
{
|
||||||
public interface IDroppableItem : IItem
|
public interface IDroppableItem : IItem
|
||||||
{
|
{
|
||||||
uint Object { get; }
|
uint Object { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,12 @@
|
|||||||
namespace ReallifeGamemode.Server.Inventory.Interfaces
|
namespace ReallifeGamemode.Server.Inventory.Interfaces
|
||||||
{
|
{
|
||||||
public interface IItem
|
public interface IItem
|
||||||
{
|
{
|
||||||
int Id { get; }
|
int Id { get; }
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
string Description { get; }
|
string Description { get; }
|
||||||
int Gewicht { get; }
|
int Gewicht { get; }
|
||||||
string Einheit { get; }
|
string Einheit { get; }
|
||||||
int Price { get; }
|
int Price { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
namespace ReallifeGamemode.Server.Inventory.Interfaces
|
namespace ReallifeGamemode.Server.Inventory.Interfaces
|
||||||
{
|
{
|
||||||
public interface IUsableItem : IItem, IDroppableItem
|
public interface IUsableItem : IItem, IDroppableItem
|
||||||
{
|
{
|
||||||
void Use(UserItem uItem);
|
void Use(UserItem uItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using ReallifeGamemode.Database.Entities;
|
|||||||
namespace ReallifeGamemode.Server.Inventory.Interfaces
|
namespace ReallifeGamemode.Server.Inventory.Interfaces
|
||||||
{
|
{
|
||||||
public interface IWeaponDealItem : IItem, IDroppableItem
|
public interface IWeaponDealItem : IItem, IDroppableItem
|
||||||
{
|
{
|
||||||
bool noTransfer(Player client, UserItem uItem, FactionVehicle fVeh);
|
bool noTransfer(Player client, UserItem uItem, FactionVehicle fVeh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,20 +7,20 @@ using ReallifeGamemode.Server.Managers;
|
|||||||
namespace ReallifeGamemode.Server.Inventory.Items
|
namespace ReallifeGamemode.Server.Inventory.Items
|
||||||
{
|
{
|
||||||
public abstract class DropItem : IDroppableItem
|
public abstract class DropItem : IDroppableItem
|
||||||
{
|
{
|
||||||
public abstract int HpAmount { get; }
|
public abstract int HpAmount { get; }
|
||||||
public abstract int Id { get; }
|
public abstract int Id { get; }
|
||||||
public abstract string Name { get; }
|
public abstract string Name { get; }
|
||||||
public abstract string Description { get; }
|
public abstract string Description { get; }
|
||||||
public abstract int Gewicht { get; }
|
public abstract int Gewicht { get; }
|
||||||
public abstract string Einheit { get; }
|
public abstract string Einheit { get; }
|
||||||
public abstract uint Object { get; }
|
public abstract uint Object { get; }
|
||||||
public abstract int Price { get; }
|
public abstract int Price { get; }
|
||||||
|
|
||||||
public void Drop(UserItem uItem, Player player, int amount)
|
public void Drop(UserItem uItem, Player player, int amount)
|
||||||
{
|
{
|
||||||
player.SendNotification("Du hast ~g~" + amount + " ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~weggeworfen.", false);
|
player.SendNotification("Du hast ~g~" + amount + " ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~weggeworfen.", false);
|
||||||
InventoryManager.RemoveUserItem(player.GetUser(), uItem, amount);
|
InventoryManager.RemoveUserItem(player.GetUser(), uItem, amount);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,29 +7,29 @@ using ReallifeGamemode.Server.Managers;
|
|||||||
namespace ReallifeGamemode.Server.Inventory.Items
|
namespace ReallifeGamemode.Server.Inventory.Items
|
||||||
{
|
{
|
||||||
public abstract class FoodItem : IUsableItem
|
public abstract class FoodItem : IUsableItem
|
||||||
|
{
|
||||||
|
public abstract int HpAmount { get; }
|
||||||
|
public abstract int Id { get; }
|
||||||
|
public abstract string Name { get; }
|
||||||
|
public abstract string Description { get; }
|
||||||
|
public abstract int Gewicht { get; }
|
||||||
|
public abstract string Einheit { get; }
|
||||||
|
public abstract uint Object { get; }
|
||||||
|
public abstract int Price { get; }
|
||||||
|
|
||||||
|
public void Use(UserItem uItem)
|
||||||
{
|
{
|
||||||
public abstract int HpAmount { get; }
|
Player player = uItem.GetUser().Player;
|
||||||
public abstract int Id { get; }
|
|
||||||
public abstract string Name { get; }
|
|
||||||
public abstract string Description { get; }
|
|
||||||
public abstract int Gewicht { get; }
|
|
||||||
public abstract string Einheit { get; }
|
|
||||||
public abstract uint Object { get; }
|
|
||||||
public abstract int Price { get; }
|
|
||||||
|
|
||||||
public void Use(UserItem uItem)
|
int amountToAdd = HpAmount;
|
||||||
{
|
if (player.Health + amountToAdd > 100)
|
||||||
Player player = uItem.GetUser().Player;
|
{
|
||||||
|
amountToAdd = 100 - player.Health;
|
||||||
|
}
|
||||||
|
|
||||||
int amountToAdd = HpAmount;
|
player.Health += amountToAdd;
|
||||||
if (player.Health + amountToAdd > 100)
|
player.SendNotification("Du hast ein/einen ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~gegessen.", false);
|
||||||
{
|
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
|
||||||
amountToAdd = 100 - player.Health;
|
|
||||||
}
|
|
||||||
|
|
||||||
player.Health += amountToAdd;
|
|
||||||
player.SendNotification("Du hast ein/einen ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~gegessen.", false);
|
|
||||||
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,23 +6,23 @@ using ReallifeGamemode.Server.Inventory.Interfaces;
|
|||||||
namespace ReallifeGamemode.Server.Inventory.Items
|
namespace ReallifeGamemode.Server.Inventory.Items
|
||||||
{
|
{
|
||||||
public abstract class WeaponDealItem : IWeaponDealItem
|
public abstract class WeaponDealItem : IWeaponDealItem
|
||||||
|
{
|
||||||
|
public abstract int Id { get; }
|
||||||
|
public abstract string Name { get; }
|
||||||
|
public abstract string Description { get; }
|
||||||
|
public abstract int Gewicht { get; }
|
||||||
|
public abstract string Einheit { get; }
|
||||||
|
public abstract uint Object { get; }
|
||||||
|
public abstract int Price { get; }
|
||||||
|
|
||||||
|
public bool noTransfer(Player client, UserItem uItem, FactionVehicle fVeh)
|
||||||
{
|
{
|
||||||
public abstract int Id { get; }
|
if (!fVeh.GetOwners().Contains(client.GetUser().FactionId ?? 0))
|
||||||
public abstract string Name { get; }
|
return false;
|
||||||
public abstract string Description { get; }
|
if (fVeh.Model != VehicleHash.Burrito3)
|
||||||
public abstract int Gewicht { get; }
|
return false;
|
||||||
public abstract string Einheit { get; }
|
|
||||||
public abstract uint Object { get; }
|
|
||||||
public abstract int Price { get; }
|
|
||||||
|
|
||||||
public bool noTransfer(Player client, UserItem uItem, FactionVehicle fVeh)
|
return true;
|
||||||
{
|
|
||||||
if (!fVeh.GetOwners().Contains(client.GetUser().FactionId ?? 0))
|
|
||||||
return false;
|
|
||||||
if (fVeh.Model != VehicleHash.Burrito3)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,59 +8,59 @@ using ReallifeGamemode.Server.Services;
|
|||||||
namespace ReallifeGamemode.Server.Job
|
namespace ReallifeGamemode.Server.Job
|
||||||
{
|
{
|
||||||
public abstract class JobBase : Script
|
public abstract class JobBase : Script
|
||||||
|
{
|
||||||
|
public delegate void JobStartHandler(Player player);
|
||||||
|
|
||||||
|
public delegate void JobStopHandler(Player player);
|
||||||
|
|
||||||
|
public event JobStartHandler JobStart;
|
||||||
|
|
||||||
|
public event JobStopHandler JobStop;
|
||||||
|
|
||||||
|
private readonly List<Player> _inJob = new List<Player>();
|
||||||
|
private static readonly List<Player> jobPlayer = new List<Player>();
|
||||||
|
|
||||||
|
public abstract int Id { get; }
|
||||||
|
|
||||||
|
public abstract string Name { get; }
|
||||||
|
|
||||||
|
public abstract bool NeedVehicleToStart { get; }
|
||||||
|
|
||||||
|
public void StartJob(Player player)
|
||||||
{
|
{
|
||||||
public delegate void JobStartHandler(Player player);
|
if (_inJob.Contains(player)) return;
|
||||||
|
_inJob.Add(player);
|
||||||
|
jobPlayer.Add(player);
|
||||||
|
|
||||||
public delegate void JobStopHandler(Player player);
|
ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ gestartet.");
|
||||||
|
|
||||||
public event JobStartHandler JobStart;
|
JobStart?.Invoke(player);
|
||||||
|
|
||||||
public event JobStopHandler JobStop;
|
|
||||||
|
|
||||||
private readonly List<Player> _inJob = new List<Player>();
|
|
||||||
private static readonly List<Player> jobPlayer = new List<Player>();
|
|
||||||
|
|
||||||
public abstract int Id { get; }
|
|
||||||
|
|
||||||
public abstract string Name { get; }
|
|
||||||
|
|
||||||
public abstract bool NeedVehicleToStart { get; }
|
|
||||||
|
|
||||||
public void StartJob(Player player)
|
|
||||||
{
|
|
||||||
if (_inJob.Contains(player)) return;
|
|
||||||
_inJob.Add(player);
|
|
||||||
jobPlayer.Add(player);
|
|
||||||
|
|
||||||
ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ gestartet.");
|
|
||||||
|
|
||||||
JobStart?.Invoke(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StopJob(Player player, bool quit = false)
|
|
||||||
{
|
|
||||||
if (!_inJob.Contains(player)) return;
|
|
||||||
_inJob.Remove(player);
|
|
||||||
jobPlayer.Remove(player);
|
|
||||||
|
|
||||||
if (quit)
|
|
||||||
{
|
|
||||||
ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ beendet.");
|
|
||||||
}
|
|
||||||
|
|
||||||
JobStop?.Invoke(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<JobVehicle> GetJobVehicles()
|
|
||||||
{
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
return dbContext.JobVehicles.Where(j => j.JobId == Id).ToList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Player> GetPlayerInJob() => jobPlayer;
|
|
||||||
|
|
||||||
public List<Player> GetUsersInJob() => _inJob;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void StopJob(Player player, bool quit = false)
|
||||||
|
{
|
||||||
|
if (!_inJob.Contains(player)) return;
|
||||||
|
_inJob.Remove(player);
|
||||||
|
jobPlayer.Remove(player);
|
||||||
|
|
||||||
|
if (quit)
|
||||||
|
{
|
||||||
|
ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ beendet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
JobStop?.Invoke(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<JobVehicle> GetJobVehicles()
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
return dbContext.JobVehicles.Where(j => j.JobId == Id).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Player> GetPlayerInJob() => jobPlayer;
|
||||||
|
|
||||||
|
public List<Player> GetUsersInJob() => _inJob;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,33 +8,33 @@ using ReallifeGamemode.Server.Services;
|
|||||||
namespace ReallifeGamemode.Server.Job
|
namespace ReallifeGamemode.Server.Job
|
||||||
{
|
{
|
||||||
public class RefuseCollectorJob : JobBase
|
public class RefuseCollectorJob : JobBase
|
||||||
|
{
|
||||||
|
public override int Id => 2;
|
||||||
|
|
||||||
|
public override string Name => "Müllmann";
|
||||||
|
|
||||||
|
public override bool NeedVehicleToStart => false;
|
||||||
|
|
||||||
|
public RefuseCollectorJob()
|
||||||
{
|
{
|
||||||
public override int Id => 2;
|
JobStart += RefuseCollectorJobJobStart;
|
||||||
|
JobStop += RefuseCollectorJobJobStop;
|
||||||
|
}
|
||||||
|
|
||||||
public override string Name => "Müllmann";
|
private void RefuseCollectorJobJobStart(Player player)
|
||||||
|
{
|
||||||
|
//setClothes
|
||||||
|
}
|
||||||
|
|
||||||
public override bool NeedVehicleToStart => false;
|
private void RefuseCollectorJobJobStop(Player player)
|
||||||
|
{
|
||||||
|
//removeClothes and replace with old
|
||||||
|
MuellmannJobBeenden(player);
|
||||||
|
}
|
||||||
|
|
||||||
public RefuseCollectorJob()
|
public static List<MuellmannData> muellmanData = new List<MuellmannData>();
|
||||||
{
|
|
||||||
JobStart += RefuseCollectorJobJobStart;
|
|
||||||
JobStop += RefuseCollectorJobJobStop;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RefuseCollectorJobJobStart(Player player)
|
private readonly IReadOnlyCollection<Vector3> vector3s = new List<Vector3>
|
||||||
{
|
|
||||||
//setClothes
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RefuseCollectorJobJobStop(Player player)
|
|
||||||
{
|
|
||||||
//removeClothes and replace with old
|
|
||||||
MuellmannJobBeenden(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<MuellmannData> muellmanData = new List<MuellmannData>();
|
|
||||||
|
|
||||||
private readonly IReadOnlyCollection<Vector3> vector3s = new List<Vector3>
|
|
||||||
{
|
{
|
||||||
new Vector3(332.9839782714844, -1741.807373046875, 29.73055076599121),
|
new Vector3(332.9839782714844, -1741.807373046875, 29.73055076599121),
|
||||||
new Vector3(321.3463439941406, -1759.986572265625, 29.644014358520508),
|
new Vector3(321.3463439941406, -1759.986572265625, 29.644014358520508),
|
||||||
@@ -153,298 +153,298 @@ namespace ReallifeGamemode.Server.Job
|
|||||||
|
|
||||||
}.AsReadOnly();
|
}.AsReadOnly();
|
||||||
|
|
||||||
[RemoteEvent("CLIENT:MuellmannJobStarten")]
|
[RemoteEvent("CLIENT:MuellmannJobStarten")]
|
||||||
public void MuellmannJobStarten(Player player, Vehicle vehicle)
|
public void MuellmannJobStarten(Player player, Vehicle vehicle)
|
||||||
|
{
|
||||||
|
if (vehicle.Model == (uint)Types.VehicleModel.Trash || vehicle.Model == (uint)Types.VehicleModel.Trash2)
|
||||||
|
{
|
||||||
|
Vehicle veh;
|
||||||
|
foreach (var data in muellmanData)
|
||||||
{
|
{
|
||||||
if (vehicle.Model == (uint)Types.VehicleModel.Trash || vehicle.Model == (uint)Types.VehicleModel.Trash2)
|
if (data.getDataFromClient(player) == null) continue;
|
||||||
{
|
veh = data.vehicle;
|
||||||
Vehicle veh;
|
ChatService.SendMessage((Player)player, "~g~Du hast den Müllmann-Job gestartet!");
|
||||||
foreach (var data in muellmanData)
|
player.TriggerEvent("SERVER:MuellmannStatusTrue");
|
||||||
{
|
player.TriggerEvent("SERVER:MuellmannBCSErstellen", JsonConvert.SerializeObject(vector3s.ToArray()), veh);
|
||||||
if (data.getDataFromClient(player) == null) continue;
|
return;
|
||||||
veh = data.vehicle;
|
|
||||||
ChatService.SendMessage((Player)player, "~g~Du hast den Müllmann-Job gestartet!");
|
|
||||||
player.TriggerEvent("SERVER:MuellmannStatusTrue");
|
|
||||||
player.TriggerEvent("SERVER:MuellmannBCSErstellen", JsonConvert.SerializeObject(vector3s.ToArray()), veh);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void MuellmannJobBeenden(Player player)
|
|
||||||
{
|
|
||||||
ChatService.SendMessage((Player)player, "~g~Du hast den Müllmann-Job beendet!");
|
|
||||||
player.TriggerEvent("SERVER:MuellmannStatusFalse");
|
|
||||||
player.TriggerEvent("SERVER:MuellmannBCSEntfernen");
|
|
||||||
|
|
||||||
foreach (var data in muellmanData)
|
|
||||||
{
|
|
||||||
if (data.getDataFromClient(player) == null) continue;
|
|
||||||
|
|
||||||
if (data.hasFreePlace())
|
|
||||||
{
|
|
||||||
muellmanData.Remove(data);
|
|
||||||
//müllwagen respawnen
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data.removeClientFromData(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("CLIENT:MuellmannImShape")]
|
|
||||||
public void MuellmannImShape(Player player, int colshapeIndex)
|
|
||||||
{
|
|
||||||
foreach (var data in muellmanData)
|
|
||||||
{
|
|
||||||
if (data.getDataFromClient(player) == null) continue;
|
|
||||||
Player target = data.getPartnerClient(player);
|
|
||||||
if (target != null) target.TriggerEvent("MuellmannUpdateColshape", colshapeIndex);
|
|
||||||
ChatService.SendMessage((Player)player, "Du hast den Müllsack in der Hand. Bringe ihm zum Müllwagen hinten.");
|
|
||||||
player.AddAttachment("binbag", false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("CLIENT:MuellmannAddSack")]
|
|
||||||
public void MuellmannAddSack(Player player)
|
|
||||||
{
|
|
||||||
foreach (var data in muellmanData)
|
|
||||||
{
|
|
||||||
if (data.getDataFromClient(player) == null) continue;
|
|
||||||
|
|
||||||
data.setTrashCount(data.getTrashCount() + 1);
|
|
||||||
|
|
||||||
Player target = data.getPartnerClient(player);
|
|
||||||
player.AddAttachment("binbag", true);
|
|
||||||
if (data.getTrashCount() >= 20)
|
|
||||||
{
|
|
||||||
ChatService.SendMessage((Player)player, "Auto ist voll fahre nun zu Base.");
|
|
||||||
if (target != null) { ChatService.SendMessage((Player)target, "Auto ist voll fahre nun zu Base."); target.TriggerEvent("SERVER:MuellmannZuBase"); }
|
|
||||||
player.TriggerEvent("SERVER:MuellmannZuBase");
|
|
||||||
}
|
|
||||||
//bonus pro sack
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("CLIENT:MuellmannBaseSack")]
|
|
||||||
public void MuellmannBaseSack(Player player)
|
|
||||||
{
|
|
||||||
if (player.VehicleSeat != 0) return;
|
|
||||||
|
|
||||||
foreach (var data in muellmanData)
|
|
||||||
{
|
|
||||||
if (data.getDataFromClient(player) == null) continue;
|
|
||||||
|
|
||||||
Player target = data.getPartnerClient(player);
|
|
||||||
if (target != null) ChatService.SendMessage((Player)target, $"Fahrzeug wurde entleert. Säcke: {data.getTrashCount()}");
|
|
||||||
ChatService.SendMessage((Player)player, $"Fahrzeug wurde entleert. Säcke: {data.getTrashCount()}");
|
|
||||||
//bonus pro sack
|
|
||||||
|
|
||||||
data.setTrashCount(0);
|
|
||||||
Console.WriteLine($"[DATA DEBUG] vehicle: {data.vehicle.DisplayName} | Players: {data.getClientsFromData().Count} | Säcke: {data.getTrashCount()}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region zweiSpeieler
|
|
||||||
|
|
||||||
public void MuellmannOnPlayerDc(Player player)
|
|
||||||
{
|
|
||||||
foreach (var data in muellmanData)
|
|
||||||
{
|
|
||||||
if (data.getDataFromClient(player) == null) continue;
|
|
||||||
|
|
||||||
if (data.hasFreePlace())
|
|
||||||
{
|
|
||||||
muellmanData.Remove(data);
|
|
||||||
//müllwagen respawnen
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data.removeClientFromData(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MuellmannOnPlayerDeath(Player player)
|
|
||||||
{
|
|
||||||
foreach (var data in muellmanData)
|
|
||||||
{
|
|
||||||
if (data.getDataFromClient(player) == null) continue;
|
|
||||||
|
|
||||||
if (data.hasFreePlace())
|
|
||||||
{
|
|
||||||
muellmanData.Remove(data);
|
|
||||||
//müllwagen respawnen
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data.removeClientFromData(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[ServerEvent(Event.VehicleDeath)]
|
|
||||||
private void MuellmannOnVehicle(Vehicle veh)
|
|
||||||
{
|
|
||||||
if (veh.Model != (uint)Types.VehicleModel.Trash && veh.Model != (uint)Types.VehicleModel.Trash2) return;
|
|
||||||
foreach (var data in muellmanData)
|
|
||||||
{
|
|
||||||
if (data.vehicle == veh)
|
|
||||||
{
|
|
||||||
//müllfahrzeug respawnen
|
|
||||||
|
|
||||||
List<Player> clients = data.getClientsFromData();
|
|
||||||
foreach (var c in clients) { RefuseCollectorJobJobStop(c); }
|
|
||||||
|
|
||||||
muellmanData.Remove(data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MuellmannOnPlayerEnterVehicle(Player player, Vehicle vehicle, sbyte seat)
|
|
||||||
{
|
|
||||||
Player target;
|
|
||||||
if (vehicle.Model == (uint)Types.VehicleModel.Trash || vehicle.Model == (uint)Types.VehicleModel.Trash2)
|
|
||||||
{
|
|
||||||
foreach (var data in muellmanData)
|
|
||||||
{
|
|
||||||
if (data.vehicle == vehicle)
|
|
||||||
{
|
|
||||||
if (data.getDataFromClient(player) != null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!data.hasFreePlace())
|
|
||||||
{
|
|
||||||
player.StopAnimation();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CheckDataForDuplicatePlayer(player, data);
|
|
||||||
data.setClientToData(player);
|
|
||||||
//destroy veh
|
|
||||||
MuellmannJobStarten(player, vehicle);
|
|
||||||
|
|
||||||
target = data.getPartnerClient(player);
|
|
||||||
if (target == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ChatService.SendMessage((Player)player, $"Dein Partner ist {target.Name} !");
|
|
||||||
ChatService.SendMessage((Player)target, $"Dein Partner ist {player.Name} !");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MuellmannData newData = new MuellmannData(vehicle);
|
|
||||||
muellmanData.Add(newData);
|
|
||||||
CheckDataForDuplicatePlayer(player, newData);
|
|
||||||
newData.setClientToData(player);
|
|
||||||
|
|
||||||
MuellmannJobStarten(player, vehicle);
|
|
||||||
|
|
||||||
target = newData.getPartnerClient(player);
|
|
||||||
if (target == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ChatService.SendMessage((Player)player, $"Dein Partner ist {target.Name} !");
|
|
||||||
ChatService.SendMessage((Player)target, $"Dein Partner ist {player.Name} !");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CheckDataForDuplicatePlayer(Player player, MuellmannData data)
|
|
||||||
{
|
|
||||||
foreach (var d in muellmanData)
|
|
||||||
{
|
|
||||||
if (d == data) continue;
|
|
||||||
|
|
||||||
MuellmannData temp = d.getDataFromClient(player);
|
|
||||||
if (temp == null) continue;
|
|
||||||
|
|
||||||
temp.removeClientFromData(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion zweiSpeieler
|
|
||||||
|
|
||||||
#region Data
|
|
||||||
|
|
||||||
public class MuellmannData
|
|
||||||
{
|
|
||||||
private Player client1;
|
|
||||||
private Player client2;
|
|
||||||
public Vehicle vehicle;
|
|
||||||
private static int trashCount = 0;
|
|
||||||
|
|
||||||
public MuellmannData(Vehicle vehicle)
|
|
||||||
{
|
|
||||||
this.vehicle = vehicle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClientToData(Player player)
|
|
||||||
{
|
|
||||||
if (client1 == player || client2 == player)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Spieler schon gespeichert");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (client1 == null) { client1 = player; return; }
|
|
||||||
else if (client2 == null) { client2 = player; return; }
|
|
||||||
else if (client1 != null && client2 != null) { Console.WriteLine("kein Platz"); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeClientFromData(Player player)
|
|
||||||
{
|
|
||||||
if (client1 == player) { client1 = null; }
|
|
||||||
if (client2 == player) { client2 = null; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTrashCount()
|
|
||||||
{
|
|
||||||
return trashCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTrashCount(int i)
|
|
||||||
{
|
|
||||||
trashCount = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Player> getClientsFromData()
|
|
||||||
{
|
|
||||||
List<Player> tempList = new List<Player>();
|
|
||||||
if (client1 != null) { tempList.Add(client1); }
|
|
||||||
if (client2 != null) { tempList.Add(client2); }
|
|
||||||
return tempList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MuellmannData getDataFromClient(Player player)
|
|
||||||
{
|
|
||||||
if (client1 != player && client2 != player)
|
|
||||||
return null;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool hasFreePlace()
|
|
||||||
{
|
|
||||||
if (client1 != null && client2 != null)
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Player getPartnerClient(Player player)
|
|
||||||
{
|
|
||||||
if (client1 != player && client2 != player)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (client1 == player) { return client2; }
|
|
||||||
if (client2 == player) { return client1; }
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Data
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void MuellmannJobBeenden(Player player)
|
||||||
|
{
|
||||||
|
ChatService.SendMessage((Player)player, "~g~Du hast den Müllmann-Job beendet!");
|
||||||
|
player.TriggerEvent("SERVER:MuellmannStatusFalse");
|
||||||
|
player.TriggerEvent("SERVER:MuellmannBCSEntfernen");
|
||||||
|
|
||||||
|
foreach (var data in muellmanData)
|
||||||
|
{
|
||||||
|
if (data.getDataFromClient(player) == null) continue;
|
||||||
|
|
||||||
|
if (data.hasFreePlace())
|
||||||
|
{
|
||||||
|
muellmanData.Remove(data);
|
||||||
|
//müllwagen respawnen
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data.removeClientFromData(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:MuellmannImShape")]
|
||||||
|
public void MuellmannImShape(Player player, int colshapeIndex)
|
||||||
|
{
|
||||||
|
foreach (var data in muellmanData)
|
||||||
|
{
|
||||||
|
if (data.getDataFromClient(player) == null) continue;
|
||||||
|
Player target = data.getPartnerClient(player);
|
||||||
|
if (target != null) target.TriggerEvent("MuellmannUpdateColshape", colshapeIndex);
|
||||||
|
ChatService.SendMessage((Player)player, "Du hast den Müllsack in der Hand. Bringe ihm zum Müllwagen hinten.");
|
||||||
|
player.AddAttachment("binbag", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:MuellmannAddSack")]
|
||||||
|
public void MuellmannAddSack(Player player)
|
||||||
|
{
|
||||||
|
foreach (var data in muellmanData)
|
||||||
|
{
|
||||||
|
if (data.getDataFromClient(player) == null) continue;
|
||||||
|
|
||||||
|
data.setTrashCount(data.getTrashCount() + 1);
|
||||||
|
|
||||||
|
Player target = data.getPartnerClient(player);
|
||||||
|
player.AddAttachment("binbag", true);
|
||||||
|
if (data.getTrashCount() >= 20)
|
||||||
|
{
|
||||||
|
ChatService.SendMessage((Player)player, "Auto ist voll fahre nun zu Base.");
|
||||||
|
if (target != null) { ChatService.SendMessage((Player)target, "Auto ist voll fahre nun zu Base."); target.TriggerEvent("SERVER:MuellmannZuBase"); }
|
||||||
|
player.TriggerEvent("SERVER:MuellmannZuBase");
|
||||||
|
}
|
||||||
|
//bonus pro sack
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:MuellmannBaseSack")]
|
||||||
|
public void MuellmannBaseSack(Player player)
|
||||||
|
{
|
||||||
|
if (player.VehicleSeat != 0) return;
|
||||||
|
|
||||||
|
foreach (var data in muellmanData)
|
||||||
|
{
|
||||||
|
if (data.getDataFromClient(player) == null) continue;
|
||||||
|
|
||||||
|
Player target = data.getPartnerClient(player);
|
||||||
|
if (target != null) ChatService.SendMessage((Player)target, $"Fahrzeug wurde entleert. Säcke: {data.getTrashCount()}");
|
||||||
|
ChatService.SendMessage((Player)player, $"Fahrzeug wurde entleert. Säcke: {data.getTrashCount()}");
|
||||||
|
//bonus pro sack
|
||||||
|
|
||||||
|
data.setTrashCount(0);
|
||||||
|
Console.WriteLine($"[DATA DEBUG] vehicle: {data.vehicle.DisplayName} | Players: {data.getClientsFromData().Count} | Säcke: {data.getTrashCount()}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region zweiSpeieler
|
||||||
|
|
||||||
|
public void MuellmannOnPlayerDc(Player player)
|
||||||
|
{
|
||||||
|
foreach (var data in muellmanData)
|
||||||
|
{
|
||||||
|
if (data.getDataFromClient(player) == null) continue;
|
||||||
|
|
||||||
|
if (data.hasFreePlace())
|
||||||
|
{
|
||||||
|
muellmanData.Remove(data);
|
||||||
|
//müllwagen respawnen
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data.removeClientFromData(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MuellmannOnPlayerDeath(Player player)
|
||||||
|
{
|
||||||
|
foreach (var data in muellmanData)
|
||||||
|
{
|
||||||
|
if (data.getDataFromClient(player) == null) continue;
|
||||||
|
|
||||||
|
if (data.hasFreePlace())
|
||||||
|
{
|
||||||
|
muellmanData.Remove(data);
|
||||||
|
//müllwagen respawnen
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data.removeClientFromData(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[ServerEvent(Event.VehicleDeath)]
|
||||||
|
private void MuellmannOnVehicle(Vehicle veh)
|
||||||
|
{
|
||||||
|
if (veh.Model != (uint)Types.VehicleModel.Trash && veh.Model != (uint)Types.VehicleModel.Trash2) return;
|
||||||
|
foreach (var data in muellmanData)
|
||||||
|
{
|
||||||
|
if (data.vehicle == veh)
|
||||||
|
{
|
||||||
|
//müllfahrzeug respawnen
|
||||||
|
|
||||||
|
List<Player> clients = data.getClientsFromData();
|
||||||
|
foreach (var c in clients) { RefuseCollectorJobJobStop(c); }
|
||||||
|
|
||||||
|
muellmanData.Remove(data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MuellmannOnPlayerEnterVehicle(Player player, Vehicle vehicle, sbyte seat)
|
||||||
|
{
|
||||||
|
Player target;
|
||||||
|
if (vehicle.Model == (uint)Types.VehicleModel.Trash || vehicle.Model == (uint)Types.VehicleModel.Trash2)
|
||||||
|
{
|
||||||
|
foreach (var data in muellmanData)
|
||||||
|
{
|
||||||
|
if (data.vehicle == vehicle)
|
||||||
|
{
|
||||||
|
if (data.getDataFromClient(player) != null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!data.hasFreePlace())
|
||||||
|
{
|
||||||
|
player.StopAnimation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CheckDataForDuplicatePlayer(player, data);
|
||||||
|
data.setClientToData(player);
|
||||||
|
//destroy veh
|
||||||
|
MuellmannJobStarten(player, vehicle);
|
||||||
|
|
||||||
|
target = data.getPartnerClient(player);
|
||||||
|
if (target == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ChatService.SendMessage((Player)player, $"Dein Partner ist {target.Name} !");
|
||||||
|
ChatService.SendMessage((Player)target, $"Dein Partner ist {player.Name} !");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MuellmannData newData = new MuellmannData(vehicle);
|
||||||
|
muellmanData.Add(newData);
|
||||||
|
CheckDataForDuplicatePlayer(player, newData);
|
||||||
|
newData.setClientToData(player);
|
||||||
|
|
||||||
|
MuellmannJobStarten(player, vehicle);
|
||||||
|
|
||||||
|
target = newData.getPartnerClient(player);
|
||||||
|
if (target == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ChatService.SendMessage((Player)player, $"Dein Partner ist {target.Name} !");
|
||||||
|
ChatService.SendMessage((Player)target, $"Dein Partner ist {player.Name} !");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CheckDataForDuplicatePlayer(Player player, MuellmannData data)
|
||||||
|
{
|
||||||
|
foreach (var d in muellmanData)
|
||||||
|
{
|
||||||
|
if (d == data) continue;
|
||||||
|
|
||||||
|
MuellmannData temp = d.getDataFromClient(player);
|
||||||
|
if (temp == null) continue;
|
||||||
|
|
||||||
|
temp.removeClientFromData(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion zweiSpeieler
|
||||||
|
|
||||||
|
#region Data
|
||||||
|
|
||||||
|
public class MuellmannData
|
||||||
|
{
|
||||||
|
private Player client1;
|
||||||
|
private Player client2;
|
||||||
|
public Vehicle vehicle;
|
||||||
|
private static int trashCount = 0;
|
||||||
|
|
||||||
|
public MuellmannData(Vehicle vehicle)
|
||||||
|
{
|
||||||
|
this.vehicle = vehicle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClientToData(Player player)
|
||||||
|
{
|
||||||
|
if (client1 == player || client2 == player)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Spieler schon gespeichert");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (client1 == null) { client1 = player; return; }
|
||||||
|
else if (client2 == null) { client2 = player; return; }
|
||||||
|
else if (client1 != null && client2 != null) { Console.WriteLine("kein Platz"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeClientFromData(Player player)
|
||||||
|
{
|
||||||
|
if (client1 == player) { client1 = null; }
|
||||||
|
if (client2 == player) { client2 = null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTrashCount()
|
||||||
|
{
|
||||||
|
return trashCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrashCount(int i)
|
||||||
|
{
|
||||||
|
trashCount = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Player> getClientsFromData()
|
||||||
|
{
|
||||||
|
List<Player> tempList = new List<Player>();
|
||||||
|
if (client1 != null) { tempList.Add(client1); }
|
||||||
|
if (client2 != null) { tempList.Add(client2); }
|
||||||
|
return tempList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MuellmannData getDataFromClient(Player player)
|
||||||
|
{
|
||||||
|
if (client1 != player && client2 != player)
|
||||||
|
return null;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool hasFreePlace()
|
||||||
|
{
|
||||||
|
if (client1 != null && client2 != null)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPartnerClient(Player player)
|
||||||
|
{
|
||||||
|
if (client1 != player && client2 != player)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (client1 == player) { return client2; }
|
||||||
|
if (client2 == player) { return client1; }
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Data
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,93 +25,93 @@ using ReallifeGamemode.Services;
|
|||||||
namespace ReallifeGamemode.Server
|
namespace ReallifeGamemode.Server
|
||||||
{
|
{
|
||||||
public class Main : Script
|
public class Main : Script
|
||||||
|
{
|
||||||
|
public static readonly Vector3 DEFAULT_SPAWN_POSITION = new Vector3(-427.5189, 1116.453, 326.7829);
|
||||||
|
public static readonly float DEFAULT_SPAWN_HEADING = 340.8f;
|
||||||
|
|
||||||
|
public static readonly CultureInfo SERVER_CULTURE = new CultureInfo("de-DE");
|
||||||
|
|
||||||
|
private EventHandler eventHandler;
|
||||||
|
|
||||||
|
[ServerEvent(Event.ResourceStart)]
|
||||||
|
public void OnResourceStart()
|
||||||
{
|
{
|
||||||
public static readonly Vector3 DEFAULT_SPAWN_POSITION = new Vector3(-427.5189, 1116.453, 326.7829);
|
var methods = Assembly.GetExecutingAssembly()
|
||||||
public static readonly float DEFAULT_SPAWN_HEADING = 340.8f;
|
.GetTypes()
|
||||||
|
.SelectMany(t => t.GetMethods())
|
||||||
|
.Where(m => m.GetCustomAttributes(typeof(CommandAttribute), false).Length > 0)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
public static readonly CultureInfo SERVER_CULTURE = new CultureInfo("de-DE");
|
var cmdAttributes = methods.Select(c => c.GetCustomAttribute<CommandAttribute>()).ToList();
|
||||||
|
|
||||||
private EventHandler eventHandler;
|
var registeredCommands = cmdAttributes.Select(c => c.CommandString).ToList();
|
||||||
|
cmdAttributes.Where(c => c.Alias?.Any() ?? false).ToList().ForEach(a =>
|
||||||
|
{
|
||||||
|
registeredCommands.AddRange(a.Alias.Split(','));
|
||||||
|
});
|
||||||
|
|
||||||
[ServerEvent(Event.ResourceStart)]
|
IAPI apiInstance = new RageAPI();
|
||||||
public void OnResourceStart()
|
eventHandler = new EventHandler(apiInstance);
|
||||||
|
|
||||||
|
new Core.Main(apiInstance, eventHandler, registeredCommands.ToArray());
|
||||||
|
|
||||||
|
NAPI.Server.SetGlobalServerChat(false);
|
||||||
|
|
||||||
|
NAPI.Server.SetCommandErrorMessage("~r~[FEHLER]~s~ Dieser Command existiert nicht.");
|
||||||
|
NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING);
|
||||||
|
NAPI.Server.SetAutoSpawnOnConnect(false);
|
||||||
|
NAPI.Server.SetAutoRespawnAfterDeath(false);
|
||||||
|
NAPI.Data.SetWorldData("playerCreatorDimension", 0);
|
||||||
|
|
||||||
|
JsonConvert.DefaultSettings = () =>
|
||||||
|
{
|
||||||
|
return new JsonSerializerSettings()
|
||||||
{
|
{
|
||||||
var methods = Assembly.GetExecutingAssembly()
|
NullValueHandling = NullValueHandling.Ignore
|
||||||
.GetTypes()
|
};
|
||||||
.SelectMany(t => t.GetMethods())
|
};
|
||||||
.Where(m => m.GetCustomAttributes(typeof(CommandAttribute), false).Length > 0)
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
var cmdAttributes = methods.Select(c => c.GetCustomAttribute<CommandAttribute>()).ToList();
|
InventoryManager.LoadItems();
|
||||||
|
ShopManager.LoadClotheShops();
|
||||||
|
ShopManager.LoadItemShops();
|
||||||
|
TuningManager.LoadTuningGarages();
|
||||||
|
|
||||||
var registeredCommands = cmdAttributes.Select(c => c.CommandString).ToList();
|
TimeManager.StartTimeManager();
|
||||||
cmdAttributes.Where(c => c.Alias?.Any() ?? false).ToList().ForEach(a =>
|
VehicleManager.CheckEnabledMods();
|
||||||
{
|
|
||||||
registeredCommands.AddRange(a.Alias.Split(','));
|
|
||||||
});
|
|
||||||
|
|
||||||
IAPI apiInstance = new RageAPI();
|
DatabaseHelper.InitDatabaseFirstTime();
|
||||||
eventHandler = new EventHandler(apiInstance);
|
|
||||||
|
|
||||||
new Core.Main(apiInstance, eventHandler, registeredCommands.ToArray());
|
FactionHelper.CheckFactionBankAccounts();
|
||||||
|
BusinessManager.LoadBusinesses();
|
||||||
|
//InteriorManager.LoadInteriors();
|
||||||
|
DoorManager.LoadDoors();
|
||||||
|
ATMManager.InitATMs();
|
||||||
|
CityHallManager.LoadCityHall();
|
||||||
|
JobManager.LoadJobs();
|
||||||
|
//TaxiDriverJob.StartTaxiTimer(); Obselete
|
||||||
|
//HouseManager.LoadHouses();
|
||||||
|
DrivingSchool.DrivingSchool.Setup();
|
||||||
|
PlaneSchool.Setup();
|
||||||
|
Gangwar.Gangwar.loadTurfs();
|
||||||
|
|
||||||
NAPI.Server.SetGlobalServerChat(false);
|
TempBlip tempBlip = new TempBlip()
|
||||||
|
{
|
||||||
|
Color = 1,
|
||||||
|
Name = "",
|
||||||
|
Transparency = 0,
|
||||||
|
ShortRange = true,
|
||||||
|
Sprite = 1,
|
||||||
|
Scale = 1,
|
||||||
|
};
|
||||||
|
|
||||||
NAPI.Server.SetCommandErrorMessage("~r~[FEHLER]~s~ Dieser Command existiert nicht.");
|
NAPI.Data.SetWorldData("blipTemplate", tempBlip);
|
||||||
NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING);
|
|
||||||
NAPI.Server.SetAutoSpawnOnConnect(false);
|
|
||||||
NAPI.Server.SetAutoRespawnAfterDeath(false);
|
|
||||||
NAPI.Data.SetWorldData("playerCreatorDimension", 0);
|
|
||||||
|
|
||||||
JsonConvert.DefaultSettings = () =>
|
//WantedEscapeTimer.WantedTimer(); Obselete
|
||||||
{
|
//Jail.JailTimer(); Obselete
|
||||||
return new JsonSerializerSettings()
|
//Economy.PaydayTimer(); Obselete
|
||||||
{
|
// WeaponDealManager.WeaponDealTimer(); Obselete
|
||||||
NullValueHandling = NullValueHandling.Ignore
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
InventoryManager.LoadItems();
|
ThreadTimers.StartAllTimers();
|
||||||
ShopManager.LoadClotheShops();
|
|
||||||
ShopManager.LoadItemShops();
|
|
||||||
TuningManager.LoadTuningGarages();
|
|
||||||
|
|
||||||
TimeManager.StartTimeManager();
|
|
||||||
VehicleManager.CheckEnabledMods();
|
|
||||||
|
|
||||||
DatabaseHelper.InitDatabaseFirstTime();
|
|
||||||
|
|
||||||
FactionHelper.CheckFactionBankAccounts();
|
|
||||||
BusinessManager.LoadBusinesses();
|
|
||||||
//InteriorManager.LoadInteriors();
|
|
||||||
DoorManager.LoadDoors();
|
|
||||||
ATMManager.InitATMs();
|
|
||||||
CityHallManager.LoadCityHall();
|
|
||||||
JobManager.LoadJobs();
|
|
||||||
//TaxiDriverJob.StartTaxiTimer(); Obselete
|
|
||||||
//HouseManager.LoadHouses();
|
|
||||||
DrivingSchool.DrivingSchool.Setup();
|
|
||||||
PlaneSchool.Setup();
|
|
||||||
Gangwar.Gangwar.loadTurfs();
|
|
||||||
|
|
||||||
TempBlip tempBlip = new TempBlip()
|
|
||||||
{
|
|
||||||
Color = 1,
|
|
||||||
Name = "",
|
|
||||||
Transparency = 0,
|
|
||||||
ShortRange = true,
|
|
||||||
Sprite = 1,
|
|
||||||
Scale = 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
NAPI.Data.SetWorldData("blipTemplate", tempBlip);
|
|
||||||
|
|
||||||
//WantedEscapeTimer.WantedTimer(); Obselete
|
|
||||||
//Jail.JailTimer(); Obselete
|
|
||||||
//Economy.PaydayTimer(); Obselete
|
|
||||||
// WeaponDealManager.WeaponDealTimer(); Obselete
|
|
||||||
|
|
||||||
ThreadTimers.StartAllTimers();
|
|
||||||
|
|
||||||
UserBankAccount.BalanceChanged += (account) =>
|
UserBankAccount.BalanceChanged += (account) =>
|
||||||
{
|
{
|
||||||
@@ -129,11 +129,11 @@ namespace ReallifeGamemode.Server
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[RemoteEvent("CLIENT:Event")]
|
[RemoteEvent("CLIENT:Event")]
|
||||||
public void OnClientEvent(Player player, string dataStr)
|
public void OnClientEvent(Player player, string dataStr)
|
||||||
{
|
{
|
||||||
var data = dataStr.DeserializeJson<List<object>>();
|
var data = dataStr.DeserializeJson<List<object>>();
|
||||||
eventHandler.HandleEvent(new RagePlayer(player), data);
|
eventHandler.HandleEvent(new RagePlayer(player), data);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,140 +14,140 @@ using ReallifeGamemode.Server.Extensions;
|
|||||||
namespace ReallifeGamemode.Server.Managers
|
namespace ReallifeGamemode.Server.Managers
|
||||||
{
|
{
|
||||||
public class ATMManager : Script
|
public class ATMManager : Script
|
||||||
|
{
|
||||||
|
public static List<ColShape> ATMColShapes = new List<ColShape>();
|
||||||
|
|
||||||
|
public static void InitATMs()
|
||||||
{
|
{
|
||||||
public static List<ColShape> ATMColShapes = new List<ColShape>();
|
var addedATMs = 0;
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
public static void InitATMs()
|
{
|
||||||
|
foreach (var currentATM in dbContext.Blips)
|
||||||
{
|
{
|
||||||
var addedATMs = 0;
|
if (currentATM.Sprite == 500)
|
||||||
using (var dbContext = new DatabaseContext())
|
{
|
||||||
|
if (dbContext.ATMs.FirstOrDefault(a => a.Id == currentATM.Id) == null)
|
||||||
{
|
{
|
||||||
foreach (var currentATM in dbContext.Blips)
|
var dataSet = new ATM
|
||||||
{
|
{
|
||||||
if (currentATM.Sprite == 500)
|
Id = currentATM.Id,
|
||||||
{
|
X = currentATM.PositionX,
|
||||||
if (dbContext.ATMs.FirstOrDefault(a => a.Id == currentATM.Id) == null)
|
Y = currentATM.PositionY,
|
||||||
{
|
Z = currentATM.PositionZ
|
||||||
var dataSet = new ATM
|
};
|
||||||
{
|
dbContext.Add(dataSet);
|
||||||
Id = currentATM.Id,
|
addedATMs++;
|
||||||
X = currentATM.PositionX,
|
|
||||||
Y = currentATM.PositionY,
|
|
||||||
Z = currentATM.PositionZ
|
|
||||||
};
|
|
||||||
dbContext.Add(dataSet);
|
|
||||||
addedATMs++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (addedATMs > 0)
|
|
||||||
{
|
|
||||||
NAPI.Util.ConsoleOutput(addedATMs + " Geldautomaten hinzugefügt");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NAPI.Util.ConsoleOutput("Keine Geldautomaten hinzugefügt");
|
|
||||||
}
|
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
LoadATMs();
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
public static void LoadATMs()
|
|
||||||
{
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
{
|
||||||
foreach (var currentATM in dbContext.ATMs)
|
continue;
|
||||||
{
|
|
||||||
var currentColShape = NAPI.ColShape.CreateCylinderColShape(new Vector3(currentATM.X, currentATM.Y, currentATM.Z), 2.5f, 3, 0);
|
|
||||||
currentColShape.OnEntityEnterColShape += EnterATMRange;
|
|
||||||
currentColShape.OnEntityExitColShape += ExitATMRange;
|
|
||||||
ATMColShapes.Add(currentColShape);
|
|
||||||
currentColShape.SetData("id", currentATM.Id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (addedATMs > 0)
|
||||||
public static void EnterATMRange(ColShape colShape, Player client)
|
|
||||||
{
|
{
|
||||||
client.SetData("nearATM", colShape.GetData<int>("id"));
|
NAPI.Util.ConsoleOutput(addedATMs + " Geldautomaten hinzugefügt");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
public static void ExitATMRange(ColShape colShape, Player client)
|
|
||||||
{
|
{
|
||||||
client.ResetData("nearATM");
|
NAPI.Util.ConsoleOutput("Keine Geldautomaten hinzugefügt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ShowAtmUi(Player player, int atmId)
|
dbContext.SaveChanges();
|
||||||
{
|
LoadATMs();
|
||||||
player.TriggerEvent("SERVER:ShowAtmUi", atmId);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("CLIENT:ATM_MANAGER:ATM_ACTION")]
|
|
||||||
public void AtmAction(Player client, int site, int inputField1, int inputField2)
|
|
||||||
{
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
var user = client.GetUser(dbContext);
|
|
||||||
int nearATM = client.GetData<int>("nearATM");
|
|
||||||
//SITE //0 Geld einzahlen //1 Geld auszahlen //2 Geld überweisen
|
|
||||||
switch (site)
|
|
||||||
{
|
|
||||||
//GELD EINZAHLEN in1
|
|
||||||
case 0:
|
|
||||||
|
|
||||||
if (user.Handmoney < inputField1)
|
|
||||||
{
|
|
||||||
//TODO im CEFBrowser anzeigen
|
|
||||||
//client.TriggerEvent("SERVER:WORLD_INTERACTION:ATM_ERROR", 0, checkATM.Balance);
|
|
||||||
client.SendNotification("~r~Nicht genügend Geld auf der Hand!");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var updateBankMoneyIn = user.BankAccount;
|
|
||||||
var updateATMBalanceIn = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
|
||||||
user.Handmoney -= inputField1;
|
|
||||||
updateBankMoneyIn.Balance += inputField1;
|
|
||||||
updateATMBalanceIn.Balance += inputField1;
|
|
||||||
client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
//GELD AUSZAHLEN in1
|
|
||||||
case 1:
|
|
||||||
var checkATM = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
|
||||||
|
|
||||||
if (user.BankAccount.Balance < inputField1)
|
|
||||||
{
|
|
||||||
client.SendNotification("~r~Nicht genügend Geld auf dem Bankkonto!"); //TODO Im Automaten anzeigen lassen
|
|
||||||
}
|
|
||||||
else if (checkATM.Balance < inputField1)
|
|
||||||
{
|
|
||||||
client.SendNotification("~r~Nicht genügend Geld im Automaten vorhanden!"); //TODO Im Automaten anzeigen lassen |||| oder OUT OF ORDER anzeigen wenn leer
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var updateHandMoneyOut = dbContext.Users.FirstOrDefault(u => u.Id == user.Id);
|
|
||||||
var updateATMBalanceOut = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
|
||||||
updateHandMoneyOut.Handmoney += inputField1;
|
|
||||||
user.BankAccount.Balance -= inputField1;
|
|
||||||
updateATMBalanceOut.Balance -= inputField1;
|
|
||||||
client.TriggerEvent("SERVER:SET_HANDMONEY", updateHandMoneyOut.Handmoney);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
//GELD ÜBERWEISEN in1 = Kontonr // in2 = Betrag
|
|
||||||
case 2:
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void LoadATMs()
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
foreach (var currentATM in dbContext.ATMs)
|
||||||
|
{
|
||||||
|
var currentColShape = NAPI.ColShape.CreateCylinderColShape(new Vector3(currentATM.X, currentATM.Y, currentATM.Z), 2.5f, 3, 0);
|
||||||
|
currentColShape.OnEntityEnterColShape += EnterATMRange;
|
||||||
|
currentColShape.OnEntityExitColShape += ExitATMRange;
|
||||||
|
ATMColShapes.Add(currentColShape);
|
||||||
|
currentColShape.SetData("id", currentATM.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void EnterATMRange(ColShape colShape, Player client)
|
||||||
|
{
|
||||||
|
client.SetData("nearATM", colShape.GetData<int>("id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ExitATMRange(ColShape colShape, Player client)
|
||||||
|
{
|
||||||
|
client.ResetData("nearATM");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ShowAtmUi(Player player, int atmId)
|
||||||
|
{
|
||||||
|
player.TriggerEvent("SERVER:ShowAtmUi", atmId);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:ATM_MANAGER:ATM_ACTION")]
|
||||||
|
public void AtmAction(Player client, int site, int inputField1, int inputField2)
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
var user = client.GetUser(dbContext);
|
||||||
|
int nearATM = client.GetData<int>("nearATM");
|
||||||
|
//SITE //0 Geld einzahlen //1 Geld auszahlen //2 Geld überweisen
|
||||||
|
switch (site)
|
||||||
|
{
|
||||||
|
//GELD EINZAHLEN in1
|
||||||
|
case 0:
|
||||||
|
|
||||||
|
if (user.Handmoney < inputField1)
|
||||||
|
{
|
||||||
|
//TODO im CEFBrowser anzeigen
|
||||||
|
//client.TriggerEvent("SERVER:WORLD_INTERACTION:ATM_ERROR", 0, checkATM.Balance);
|
||||||
|
client.SendNotification("~r~Nicht genügend Geld auf der Hand!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var updateBankMoneyIn = user.BankAccount;
|
||||||
|
var updateATMBalanceIn = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||||
|
user.Handmoney -= inputField1;
|
||||||
|
updateBankMoneyIn.Balance += inputField1;
|
||||||
|
updateATMBalanceIn.Balance += inputField1;
|
||||||
|
client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
//GELD AUSZAHLEN in1
|
||||||
|
case 1:
|
||||||
|
var checkATM = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||||
|
|
||||||
|
if (user.BankAccount.Balance < inputField1)
|
||||||
|
{
|
||||||
|
client.SendNotification("~r~Nicht genügend Geld auf dem Bankkonto!"); //TODO Im Automaten anzeigen lassen
|
||||||
|
}
|
||||||
|
else if (checkATM.Balance < inputField1)
|
||||||
|
{
|
||||||
|
client.SendNotification("~r~Nicht genügend Geld im Automaten vorhanden!"); //TODO Im Automaten anzeigen lassen |||| oder OUT OF ORDER anzeigen wenn leer
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var updateHandMoneyOut = dbContext.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||||
|
var updateATMBalanceOut = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||||
|
updateHandMoneyOut.Handmoney += inputField1;
|
||||||
|
user.BankAccount.Balance -= inputField1;
|
||||||
|
updateATMBalanceOut.Balance -= inputField1;
|
||||||
|
client.TriggerEvent("SERVER:SET_HANDMONEY", updateHandMoneyOut.Handmoney);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
//GELD ÜBERWEISEN in1 = Kontonr // in2 = Betrag
|
||||||
|
case 2:
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,98 +15,98 @@ using ReallifeGamemode.Server.Util;
|
|||||||
namespace ReallifeGamemode.Server.Managers
|
namespace ReallifeGamemode.Server.Managers
|
||||||
{
|
{
|
||||||
public class BankManager
|
public class BankManager
|
||||||
|
{
|
||||||
|
public static TransactionResult SetMoney(Player admin, IBankAccountOwner owner, int amount, string reason = "Von Admin gesetzt")
|
||||||
{
|
{
|
||||||
public static TransactionResult SetMoney(Player admin, IBankAccountOwner owner, int amount, string reason = "Von Admin gesetzt")
|
using (var transferMoney = new DatabaseContext())
|
||||||
|
{
|
||||||
|
if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT;
|
||||||
|
|
||||||
|
IBankAccount account = owner.GetBankAccount(transferMoney);
|
||||||
|
|
||||||
|
if (account == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT;
|
||||||
|
|
||||||
|
var transactionLog = new BankAccountTransactionHistory
|
||||||
{
|
{
|
||||||
using (var transferMoney = new DatabaseContext())
|
Sender = "ADMIN: " + admin.Name,
|
||||||
{
|
SenderBalance = 0,
|
||||||
if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT;
|
Receiver = owner.Name,
|
||||||
|
ReceiverBalance = amount,
|
||||||
|
NewReceiverBalance = amount,
|
||||||
|
NewSenderBalance = 0,
|
||||||
|
MoneySent = amount,
|
||||||
|
Fee = 0,
|
||||||
|
Origin = reason
|
||||||
|
};
|
||||||
|
|
||||||
IBankAccount account = owner.GetBankAccount(transferMoney);
|
// add log
|
||||||
|
transferMoney.BankAccountTransactionLogs.Add(transactionLog);
|
||||||
|
|
||||||
if (account == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT;
|
account.Balance = amount;
|
||||||
|
|
||||||
var transactionLog = new BankAccountTransactionHistory
|
transferMoney.SaveChanges();
|
||||||
{
|
|
||||||
Sender = "ADMIN: " + admin.Name,
|
|
||||||
SenderBalance = 0,
|
|
||||||
Receiver = owner.Name,
|
|
||||||
ReceiverBalance = amount,
|
|
||||||
NewReceiverBalance = amount,
|
|
||||||
NewSenderBalance = 0,
|
|
||||||
MoneySent = amount,
|
|
||||||
Fee = 0,
|
|
||||||
Origin = reason
|
|
||||||
};
|
|
||||||
|
|
||||||
// add log
|
return TransactionResult.SUCCESS;
|
||||||
transferMoney.BankAccountTransactionLogs.Add(transactionLog);
|
}
|
||||||
|
|
||||||
account.Balance = amount;
|
|
||||||
|
|
||||||
transferMoney.SaveChanges();
|
|
||||||
|
|
||||||
return TransactionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TransactionResult TransferMoney<TSender, TReceiver>(
|
|
||||||
BankAccountHolder<TSender> sender,
|
|
||||||
BankAccountHolder<TReceiver> receiver,
|
|
||||||
int amount,
|
|
||||||
string origin,
|
|
||||||
DatabaseContext dbContext) where TSender : class, IBankAccount, new() where TReceiver : class, IBankAccount, new()
|
|
||||||
{
|
|
||||||
if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT;
|
|
||||||
|
|
||||||
IBankAccount senderAccount;
|
|
||||||
IBankAccount receiverAccount;
|
|
||||||
|
|
||||||
if (sender is BankAccountHolder<BusinessBankAccount> businessSender)
|
|
||||||
{
|
|
||||||
senderAccount = dbContext.BusinessBankAccounts.Where(b => b.Id == businessSender.BankAccountId).First();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
senderAccount = sender.BankAccount;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (receiver is BankAccountHolder<BusinessBankAccount> businessReceiver)
|
|
||||||
{
|
|
||||||
receiverAccount = dbContext.BusinessBankAccounts.Where(b => b.Id == businessReceiver.BankAccountId).First();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
receiverAccount = receiver.BankAccount;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (senderAccount == null) return TransactionResult.SENDER_NO_BANKACCOUNT;
|
|
||||||
if (receiverAccount == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT;
|
|
||||||
|
|
||||||
if (senderAccount.Balance < amount) return TransactionResult.SENDER_NOT_ENOUGH_MONEY;
|
|
||||||
|
|
||||||
var transactionLog = new BankAccountTransactionHistory
|
|
||||||
{
|
|
||||||
Sender = sender.BankAccountName,
|
|
||||||
SenderBalance = senderAccount.Balance,
|
|
||||||
Receiver = receiver.BankAccountName,
|
|
||||||
ReceiverBalance = receiverAccount.Balance,
|
|
||||||
NewReceiverBalance = receiverAccount.Balance + amount,
|
|
||||||
NewSenderBalance = senderAccount.Balance - amount,
|
|
||||||
MoneySent = amount,
|
|
||||||
Fee = 0,
|
|
||||||
Origin = origin
|
|
||||||
};
|
|
||||||
|
|
||||||
// add log
|
|
||||||
dbContext.BankAccountTransactionLogs.Add(transactionLog);
|
|
||||||
|
|
||||||
senderAccount.Balance -= amount;
|
|
||||||
receiverAccount.Balance += amount;
|
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
|
|
||||||
return TransactionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TransactionResult TransferMoney<TSender, TReceiver>(
|
||||||
|
BankAccountHolder<TSender> sender,
|
||||||
|
BankAccountHolder<TReceiver> receiver,
|
||||||
|
int amount,
|
||||||
|
string origin,
|
||||||
|
DatabaseContext dbContext) where TSender : class, IBankAccount, new() where TReceiver : class, IBankAccount, new()
|
||||||
|
{
|
||||||
|
if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT;
|
||||||
|
|
||||||
|
IBankAccount senderAccount;
|
||||||
|
IBankAccount receiverAccount;
|
||||||
|
|
||||||
|
if (sender is BankAccountHolder<BusinessBankAccount> businessSender)
|
||||||
|
{
|
||||||
|
senderAccount = dbContext.BusinessBankAccounts.Where(b => b.Id == businessSender.BankAccountId).First();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
senderAccount = sender.BankAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (receiver is BankAccountHolder<BusinessBankAccount> businessReceiver)
|
||||||
|
{
|
||||||
|
receiverAccount = dbContext.BusinessBankAccounts.Where(b => b.Id == businessReceiver.BankAccountId).First();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
receiverAccount = receiver.BankAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (senderAccount == null) return TransactionResult.SENDER_NO_BANKACCOUNT;
|
||||||
|
if (receiverAccount == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT;
|
||||||
|
|
||||||
|
if (senderAccount.Balance < amount) return TransactionResult.SENDER_NOT_ENOUGH_MONEY;
|
||||||
|
|
||||||
|
var transactionLog = new BankAccountTransactionHistory
|
||||||
|
{
|
||||||
|
Sender = sender.BankAccountName,
|
||||||
|
SenderBalance = senderAccount.Balance,
|
||||||
|
Receiver = receiver.BankAccountName,
|
||||||
|
ReceiverBalance = receiverAccount.Balance,
|
||||||
|
NewReceiverBalance = receiverAccount.Balance + amount,
|
||||||
|
NewSenderBalance = senderAccount.Balance - amount,
|
||||||
|
MoneySent = amount,
|
||||||
|
Fee = 0,
|
||||||
|
Origin = origin
|
||||||
|
};
|
||||||
|
|
||||||
|
// add log
|
||||||
|
dbContext.BankAccountTransactionLogs.Add(transactionLog);
|
||||||
|
|
||||||
|
senderAccount.Balance -= amount;
|
||||||
|
receiverAccount.Balance += amount;
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
return TransactionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,326 +7,326 @@ using ReallifeGamemode.Server.Extensions;
|
|||||||
namespace ReallifeGamemode.Server.Managers
|
namespace ReallifeGamemode.Server.Managers
|
||||||
{
|
{
|
||||||
public class CharacterCreator : Script
|
public class CharacterCreator : Script
|
||||||
|
{
|
||||||
|
[RemoteEvent("creator_GenderChange")]
|
||||||
|
public void changeGender(Player player, int gender)
|
||||||
{
|
{
|
||||||
[RemoteEvent("creator_GenderChange")]
|
if (gender == 0) player.SetSkin(PedHash.FreemodeMale01);
|
||||||
public void changeGender(Player player, int gender)
|
else player.SetSkin(PedHash.FreemodeFemale01);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("creatorSave")]
|
||||||
|
public void CreatorSave(Player player, bool gender, string parentData, string featureData, string appearanceData, string hairAndColorData)
|
||||||
|
{
|
||||||
|
var jParentData = JObject.Parse(parentData);
|
||||||
|
var jFeatureData = JArray.Parse(featureData);
|
||||||
|
var jAppearanceData = JArray.Parse(appearanceData);
|
||||||
|
var jHairAndColorData = JArray.Parse(hairAndColorData);
|
||||||
|
|
||||||
|
byte father = jParentData.Value<byte>("Father");
|
||||||
|
byte mother = jParentData.Value<byte>("Mother");
|
||||||
|
float similarity = jParentData.Value<float>("Similarity");
|
||||||
|
float skinSimilarity = jParentData.Value<float>("SkinSimilarity");
|
||||||
|
|
||||||
|
float noseWidth = jFeatureData.Value<float>(0);
|
||||||
|
float noseBottomHeight = jFeatureData.Value<float>(1);
|
||||||
|
float noseTipLength = jFeatureData.Value<float>(2);
|
||||||
|
float noseBridgeDepth = jFeatureData.Value<float>(3);
|
||||||
|
float noseTipHeight = jFeatureData.Value<float>(4);
|
||||||
|
float noseBroken = jFeatureData.Value<float>(5);
|
||||||
|
float browHeight = jFeatureData.Value<float>(6);
|
||||||
|
float browDepth = jFeatureData.Value<float>(7);
|
||||||
|
float cheekboneHeight = jFeatureData.Value<float>(8);
|
||||||
|
float cheekboneWidth = jFeatureData.Value<float>(9);
|
||||||
|
float cheekDepth = jFeatureData.Value<float>(10);
|
||||||
|
float eyeSize = jFeatureData.Value<float>(11);
|
||||||
|
float lipThickness = jFeatureData.Value<float>(12);
|
||||||
|
float jawWidth = jFeatureData.Value<float>(13);
|
||||||
|
float jawShape = jFeatureData.Value<float>(14);
|
||||||
|
float chinHeight = jFeatureData.Value<float>(15);
|
||||||
|
float chinDepth = jFeatureData.Value<float>(16);
|
||||||
|
float chinWidth = jFeatureData.Value<float>(17);
|
||||||
|
float chinIndent = jFeatureData.Value<float>(18);
|
||||||
|
float neckWidth = jFeatureData.Value<float>(19);
|
||||||
|
|
||||||
|
byte blemishes = jAppearanceData[0].Value<byte>("Value");
|
||||||
|
float blemishesOpacity = jAppearanceData[0].Value<byte>("Opacity");
|
||||||
|
byte facialHair = jAppearanceData[1].Value<byte>("Value");
|
||||||
|
float facialHairOpacity = jAppearanceData[1].Value<byte>("Opacity");
|
||||||
|
byte eyebrows = jAppearanceData[2].Value<byte>("Value");
|
||||||
|
float eyebrowsOpacity = jAppearanceData[2].Value<byte>("Opacity");
|
||||||
|
byte ageing = jAppearanceData[3].Value<byte>("Value");
|
||||||
|
float ageingOpacity = jAppearanceData[3].Value<byte>("Opacity");
|
||||||
|
byte makeup = jAppearanceData[4].Value<byte>("Value");
|
||||||
|
float makeupOpacity = jAppearanceData[4].Value<byte>("Opacity");
|
||||||
|
byte blush = jAppearanceData[5].Value<byte>("Value");
|
||||||
|
float blushOpacity = jAppearanceData[5].Value<byte>("Opacity");
|
||||||
|
byte complexion = jAppearanceData[6].Value<byte>("Value");
|
||||||
|
float complexionOpacity = jAppearanceData[6].Value<byte>("Opacity");
|
||||||
|
byte sunDamage = jAppearanceData[7].Value<byte>("Value");
|
||||||
|
float sunDamageOpacity = jAppearanceData[7].Value<byte>("Opacity");
|
||||||
|
byte lipstick = jAppearanceData[8].Value<byte>("Value");
|
||||||
|
float lipstickOpacity = jAppearanceData[8].Value<byte>("Opacity");
|
||||||
|
byte freckles = jAppearanceData[9].Value<byte>("Value");
|
||||||
|
float frecklesOpacity = jAppearanceData[9].Value<byte>("Opacity");
|
||||||
|
byte chestHair = jAppearanceData[10].Value<byte>("Value");
|
||||||
|
float chestHairOpacity = jAppearanceData[10].Value<byte>("Opacity");
|
||||||
|
|
||||||
|
byte hair = jHairAndColorData.Value<byte>(0);
|
||||||
|
byte hairColor = jHairAndColorData.Value<byte>(1);
|
||||||
|
byte hairHighlightColor = jHairAndColorData.Value<byte>(2);
|
||||||
|
byte eyebrowColor = jHairAndColorData.Value<byte>(3);
|
||||||
|
byte beardColor = jHairAndColorData.Value<byte>(4);
|
||||||
|
byte eyeColor = jHairAndColorData.Value<byte>(5);
|
||||||
|
byte blushColor = jHairAndColorData.Value<byte>(6);
|
||||||
|
byte lipstickColor = jHairAndColorData.Value<byte>(7);
|
||||||
|
byte chestHairColor = jHairAndColorData.Value<byte>(8);
|
||||||
|
|
||||||
|
using (var saveCharacter = new DatabaseContext())
|
||||||
|
{
|
||||||
|
var character = new Database.Entities.Character
|
||||||
{
|
{
|
||||||
if (gender == 0) player.SetSkin(PedHash.FreemodeMale01);
|
UserId = player.GetUser().Id,
|
||||||
else player.SetSkin(PedHash.FreemodeFemale01);
|
Gender = gender,
|
||||||
|
Father = father,
|
||||||
|
Mother = mother,
|
||||||
|
Similarity = similarity,
|
||||||
|
SkinSimilarity = skinSimilarity,
|
||||||
|
|
||||||
|
NoseWidth = noseWidth,
|
||||||
|
NoseBottomHeight = noseBottomHeight,
|
||||||
|
NoseTipLength = noseTipLength,
|
||||||
|
NoseBridgeDepth = noseBridgeDepth,
|
||||||
|
NoseTipHeight = noseTipHeight,
|
||||||
|
NoseBroken = noseBroken,
|
||||||
|
BrowHeight = browHeight,
|
||||||
|
BrowDepth = browDepth,
|
||||||
|
CheekboneHeight = cheekboneHeight,
|
||||||
|
CheekboneWidth = cheekboneWidth,
|
||||||
|
CheekDepth = cheekDepth,
|
||||||
|
EyeSize = eyeSize,
|
||||||
|
LipThickness = lipThickness,
|
||||||
|
JawWidth = jawWidth,
|
||||||
|
JawShape = jawShape,
|
||||||
|
ChinHeight = chinHeight,
|
||||||
|
ChinDepth = chinDepth,
|
||||||
|
ChinWidth = chinWidth,
|
||||||
|
ChinIndent = chinIndent,
|
||||||
|
NeckWidth = neckWidth,
|
||||||
|
|
||||||
|
Blemishes = blemishes,
|
||||||
|
BlemishesOpacity = blemishesOpacity,
|
||||||
|
FacialHair = facialHair,
|
||||||
|
FacialHairOpacity = facialHairOpacity,
|
||||||
|
Eyebrows = eyebrows,
|
||||||
|
EyebrowsOpacity = eyebrowsOpacity,
|
||||||
|
Ageing = ageing,
|
||||||
|
AgeingOpacity = ageingOpacity,
|
||||||
|
Makeup = makeup,
|
||||||
|
MakeupOpacity = makeupOpacity,
|
||||||
|
Blush = blush,
|
||||||
|
BlushOpacity = blushOpacity,
|
||||||
|
Complexion = complexion,
|
||||||
|
ComplexionOpacity = complexionOpacity,
|
||||||
|
SunDamage = sunDamage,
|
||||||
|
SunDamageOpacity = sunDamageOpacity,
|
||||||
|
Lipstick = lipstick,
|
||||||
|
LipstickOpacity = lipstickOpacity,
|
||||||
|
Freckles = freckles,
|
||||||
|
FrecklesOpacity = frecklesOpacity,
|
||||||
|
ChestHair = chestHair,
|
||||||
|
ChestHairOpacity = chestHairOpacity,
|
||||||
|
|
||||||
|
Hair = hair,
|
||||||
|
HairColor = hairColor,
|
||||||
|
HairHighlightColor = hairHighlightColor,
|
||||||
|
EyebrowColor = eyebrowColor,
|
||||||
|
BeardColor = beardColor,
|
||||||
|
EyeColor = eyeColor,
|
||||||
|
BlushColor = blushColor,
|
||||||
|
LipstickColor = lipstickColor,
|
||||||
|
ChestHairColor = chestHairColor
|
||||||
|
};
|
||||||
|
|
||||||
|
saveCharacter.Characters.Add(character);
|
||||||
|
saveCharacter.SaveChanges();
|
||||||
|
|
||||||
|
var userId = player.GetUser().Id;
|
||||||
|
var user = saveCharacter.Users.SingleOrDefault(u => u.Id == userId);
|
||||||
|
|
||||||
|
user.CharacterId = character.Id;
|
||||||
|
saveCharacter.SaveChanges();
|
||||||
|
}
|
||||||
|
//HeadOverlay makeupHo = new HeadOverlay()
|
||||||
|
//{
|
||||||
|
// Index = 0,
|
||||||
|
// Opacity = 0.0f,
|
||||||
|
// Color = 0,
|
||||||
|
// SecondaryColor = 0
|
||||||
|
//};
|
||||||
|
//HeadOverlay blushHo = new HeadOverlay()
|
||||||
|
//{
|
||||||
|
// Index = 0,
|
||||||
|
// Opacity = 0.0f,
|
||||||
|
// Color = 0,
|
||||||
|
// SecondaryColor = 0
|
||||||
|
//};
|
||||||
|
//player.SetHeadOverlay(4, makeupHo);
|
||||||
|
//player.SetHeadOverlay(5, blushHo);
|
||||||
|
NAPI.Player.SpawnPlayer(player, Main.DEFAULT_SPAWN_POSITION, Main.DEFAULT_SPAWN_HEADING);
|
||||||
|
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||||
|
player.Dimension = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wendet den Character eines Spielers auf diesen an
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="player">Der Player, dessen Aussehen man setzen will</param>
|
||||||
|
public static void ApplyCharacter(Player player)
|
||||||
|
{
|
||||||
|
var user = player.GetUser();
|
||||||
|
using (var loadCharacter = new DatabaseContext())
|
||||||
|
{
|
||||||
|
var character = loadCharacter.Characters.SingleOrDefault(c => c.Id == user.CharacterId);
|
||||||
|
|
||||||
|
if (character == null) return;
|
||||||
|
|
||||||
|
//Männlich / Weiblich
|
||||||
|
if (character.Gender == false)
|
||||||
|
{
|
||||||
|
player.SetSkin(PedHash.FreemodeMale01);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.SetSkin(PedHash.FreemodeFemale01);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RemoteEvent("creatorSave")]
|
//Gesichtszüge
|
||||||
public void CreatorSave(Player player, bool gender, string parentData, string featureData, string appearanceData, string hairAndColorData)
|
float[] faceFeatures = new float[] { character.NoseWidth, character.NoseBottomHeight, character.NoseTipLength, character.NoseBridgeDepth, character.NoseTipHeight,
|
||||||
{
|
|
||||||
var jParentData = JObject.Parse(parentData);
|
|
||||||
var jFeatureData = JArray.Parse(featureData);
|
|
||||||
var jAppearanceData = JArray.Parse(appearanceData);
|
|
||||||
var jHairAndColorData = JArray.Parse(hairAndColorData);
|
|
||||||
|
|
||||||
byte father = jParentData.Value<byte>("Father");
|
|
||||||
byte mother = jParentData.Value<byte>("Mother");
|
|
||||||
float similarity = jParentData.Value<float>("Similarity");
|
|
||||||
float skinSimilarity = jParentData.Value<float>("SkinSimilarity");
|
|
||||||
|
|
||||||
float noseWidth = jFeatureData.Value<float>(0);
|
|
||||||
float noseBottomHeight = jFeatureData.Value<float>(1);
|
|
||||||
float noseTipLength = jFeatureData.Value<float>(2);
|
|
||||||
float noseBridgeDepth = jFeatureData.Value<float>(3);
|
|
||||||
float noseTipHeight = jFeatureData.Value<float>(4);
|
|
||||||
float noseBroken = jFeatureData.Value<float>(5);
|
|
||||||
float browHeight = jFeatureData.Value<float>(6);
|
|
||||||
float browDepth = jFeatureData.Value<float>(7);
|
|
||||||
float cheekboneHeight = jFeatureData.Value<float>(8);
|
|
||||||
float cheekboneWidth = jFeatureData.Value<float>(9);
|
|
||||||
float cheekDepth = jFeatureData.Value<float>(10);
|
|
||||||
float eyeSize = jFeatureData.Value<float>(11);
|
|
||||||
float lipThickness = jFeatureData.Value<float>(12);
|
|
||||||
float jawWidth = jFeatureData.Value<float>(13);
|
|
||||||
float jawShape = jFeatureData.Value<float>(14);
|
|
||||||
float chinHeight = jFeatureData.Value<float>(15);
|
|
||||||
float chinDepth = jFeatureData.Value<float>(16);
|
|
||||||
float chinWidth = jFeatureData.Value<float>(17);
|
|
||||||
float chinIndent = jFeatureData.Value<float>(18);
|
|
||||||
float neckWidth = jFeatureData.Value<float>(19);
|
|
||||||
|
|
||||||
byte blemishes = jAppearanceData[0].Value<byte>("Value");
|
|
||||||
float blemishesOpacity = jAppearanceData[0].Value<byte>("Opacity");
|
|
||||||
byte facialHair = jAppearanceData[1].Value<byte>("Value");
|
|
||||||
float facialHairOpacity = jAppearanceData[1].Value<byte>("Opacity");
|
|
||||||
byte eyebrows = jAppearanceData[2].Value<byte>("Value");
|
|
||||||
float eyebrowsOpacity = jAppearanceData[2].Value<byte>("Opacity");
|
|
||||||
byte ageing = jAppearanceData[3].Value<byte>("Value");
|
|
||||||
float ageingOpacity = jAppearanceData[3].Value<byte>("Opacity");
|
|
||||||
byte makeup = jAppearanceData[4].Value<byte>("Value");
|
|
||||||
float makeupOpacity = jAppearanceData[4].Value<byte>("Opacity");
|
|
||||||
byte blush = jAppearanceData[5].Value<byte>("Value");
|
|
||||||
float blushOpacity = jAppearanceData[5].Value<byte>("Opacity");
|
|
||||||
byte complexion = jAppearanceData[6].Value<byte>("Value");
|
|
||||||
float complexionOpacity = jAppearanceData[6].Value<byte>("Opacity");
|
|
||||||
byte sunDamage = jAppearanceData[7].Value<byte>("Value");
|
|
||||||
float sunDamageOpacity = jAppearanceData[7].Value<byte>("Opacity");
|
|
||||||
byte lipstick = jAppearanceData[8].Value<byte>("Value");
|
|
||||||
float lipstickOpacity = jAppearanceData[8].Value<byte>("Opacity");
|
|
||||||
byte freckles = jAppearanceData[9].Value<byte>("Value");
|
|
||||||
float frecklesOpacity = jAppearanceData[9].Value<byte>("Opacity");
|
|
||||||
byte chestHair = jAppearanceData[10].Value<byte>("Value");
|
|
||||||
float chestHairOpacity = jAppearanceData[10].Value<byte>("Opacity");
|
|
||||||
|
|
||||||
byte hair = jHairAndColorData.Value<byte>(0);
|
|
||||||
byte hairColor = jHairAndColorData.Value<byte>(1);
|
|
||||||
byte hairHighlightColor = jHairAndColorData.Value<byte>(2);
|
|
||||||
byte eyebrowColor = jHairAndColorData.Value<byte>(3);
|
|
||||||
byte beardColor = jHairAndColorData.Value<byte>(4);
|
|
||||||
byte eyeColor = jHairAndColorData.Value<byte>(5);
|
|
||||||
byte blushColor = jHairAndColorData.Value<byte>(6);
|
|
||||||
byte lipstickColor = jHairAndColorData.Value<byte>(7);
|
|
||||||
byte chestHairColor = jHairAndColorData.Value<byte>(8);
|
|
||||||
|
|
||||||
using (var saveCharacter = new DatabaseContext())
|
|
||||||
{
|
|
||||||
var character = new Database.Entities.Character
|
|
||||||
{
|
|
||||||
UserId = player.GetUser().Id,
|
|
||||||
Gender = gender,
|
|
||||||
Father = father,
|
|
||||||
Mother = mother,
|
|
||||||
Similarity = similarity,
|
|
||||||
SkinSimilarity = skinSimilarity,
|
|
||||||
|
|
||||||
NoseWidth = noseWidth,
|
|
||||||
NoseBottomHeight = noseBottomHeight,
|
|
||||||
NoseTipLength = noseTipLength,
|
|
||||||
NoseBridgeDepth = noseBridgeDepth,
|
|
||||||
NoseTipHeight = noseTipHeight,
|
|
||||||
NoseBroken = noseBroken,
|
|
||||||
BrowHeight = browHeight,
|
|
||||||
BrowDepth = browDepth,
|
|
||||||
CheekboneHeight = cheekboneHeight,
|
|
||||||
CheekboneWidth = cheekboneWidth,
|
|
||||||
CheekDepth = cheekDepth,
|
|
||||||
EyeSize = eyeSize,
|
|
||||||
LipThickness = lipThickness,
|
|
||||||
JawWidth = jawWidth,
|
|
||||||
JawShape = jawShape,
|
|
||||||
ChinHeight = chinHeight,
|
|
||||||
ChinDepth = chinDepth,
|
|
||||||
ChinWidth = chinWidth,
|
|
||||||
ChinIndent = chinIndent,
|
|
||||||
NeckWidth = neckWidth,
|
|
||||||
|
|
||||||
Blemishes = blemishes,
|
|
||||||
BlemishesOpacity = blemishesOpacity,
|
|
||||||
FacialHair = facialHair,
|
|
||||||
FacialHairOpacity = facialHairOpacity,
|
|
||||||
Eyebrows = eyebrows,
|
|
||||||
EyebrowsOpacity = eyebrowsOpacity,
|
|
||||||
Ageing = ageing,
|
|
||||||
AgeingOpacity = ageingOpacity,
|
|
||||||
Makeup = makeup,
|
|
||||||
MakeupOpacity = makeupOpacity,
|
|
||||||
Blush = blush,
|
|
||||||
BlushOpacity = blushOpacity,
|
|
||||||
Complexion = complexion,
|
|
||||||
ComplexionOpacity = complexionOpacity,
|
|
||||||
SunDamage = sunDamage,
|
|
||||||
SunDamageOpacity = sunDamageOpacity,
|
|
||||||
Lipstick = lipstick,
|
|
||||||
LipstickOpacity = lipstickOpacity,
|
|
||||||
Freckles = freckles,
|
|
||||||
FrecklesOpacity = frecklesOpacity,
|
|
||||||
ChestHair = chestHair,
|
|
||||||
ChestHairOpacity = chestHairOpacity,
|
|
||||||
|
|
||||||
Hair = hair,
|
|
||||||
HairColor = hairColor,
|
|
||||||
HairHighlightColor = hairHighlightColor,
|
|
||||||
EyebrowColor = eyebrowColor,
|
|
||||||
BeardColor = beardColor,
|
|
||||||
EyeColor = eyeColor,
|
|
||||||
BlushColor = blushColor,
|
|
||||||
LipstickColor = lipstickColor,
|
|
||||||
ChestHairColor = chestHairColor
|
|
||||||
};
|
|
||||||
|
|
||||||
saveCharacter.Characters.Add(character);
|
|
||||||
saveCharacter.SaveChanges();
|
|
||||||
|
|
||||||
var userId = player.GetUser().Id;
|
|
||||||
var user = saveCharacter.Users.SingleOrDefault(u => u.Id == userId);
|
|
||||||
|
|
||||||
user.CharacterId = character.Id;
|
|
||||||
saveCharacter.SaveChanges();
|
|
||||||
}
|
|
||||||
//HeadOverlay makeupHo = new HeadOverlay()
|
|
||||||
//{
|
|
||||||
// Index = 0,
|
|
||||||
// Opacity = 0.0f,
|
|
||||||
// Color = 0,
|
|
||||||
// SecondaryColor = 0
|
|
||||||
//};
|
|
||||||
//HeadOverlay blushHo = new HeadOverlay()
|
|
||||||
//{
|
|
||||||
// Index = 0,
|
|
||||||
// Opacity = 0.0f,
|
|
||||||
// Color = 0,
|
|
||||||
// SecondaryColor = 0
|
|
||||||
//};
|
|
||||||
//player.SetHeadOverlay(4, makeupHo);
|
|
||||||
//player.SetHeadOverlay(5, blushHo);
|
|
||||||
NAPI.Player.SpawnPlayer(player, Main.DEFAULT_SPAWN_POSITION, Main.DEFAULT_SPAWN_HEADING);
|
|
||||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
|
||||||
player.Dimension = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Wendet den Character eines Spielers auf diesen an
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="player">Der Player, dessen Aussehen man setzen will</param>
|
|
||||||
public static void ApplyCharacter(Player player)
|
|
||||||
{
|
|
||||||
var user = player.GetUser();
|
|
||||||
using (var loadCharacter = new DatabaseContext())
|
|
||||||
{
|
|
||||||
var character = loadCharacter.Characters.SingleOrDefault(c => c.Id == user.CharacterId);
|
|
||||||
|
|
||||||
if (character == null) return;
|
|
||||||
|
|
||||||
//Männlich / Weiblich
|
|
||||||
if (character.Gender == false)
|
|
||||||
{
|
|
||||||
player.SetSkin(PedHash.FreemodeMale01);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.SetSkin(PedHash.FreemodeFemale01);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Gesichtszüge
|
|
||||||
float[] faceFeatures = new float[] { character.NoseWidth, character.NoseBottomHeight, character.NoseTipLength, character.NoseBridgeDepth, character.NoseTipHeight,
|
|
||||||
character.NoseBroken, character.BrowHeight, character.BrowDepth, character.CheekboneHeight, character.CheekboneWidth,
|
character.NoseBroken, character.BrowHeight, character.BrowDepth, character.CheekboneHeight, character.CheekboneWidth,
|
||||||
character.CheekboneWidth, character.CheekDepth, character.EyeSize, character.LipThickness, character.JawWidth,
|
character.CheekboneWidth, character.CheekDepth, character.EyeSize, character.LipThickness, character.JawWidth,
|
||||||
character.JawShape, character.ChinHeight, character.ChinDepth, character.ChinWidth, character.ChinIndent, character.NeckWidth };
|
character.JawShape, character.ChinHeight, character.ChinDepth, character.ChinWidth, character.ChinIndent, character.NeckWidth };
|
||||||
|
|
||||||
for (var i = 0; i < faceFeatures.Length; i++)
|
for (var i = 0; i < faceFeatures.Length; i++)
|
||||||
{
|
{
|
||||||
player.SetFaceFeature(i, faceFeatures[i]);
|
player.SetFaceFeature(i, faceFeatures[i]);
|
||||||
}
|
|
||||||
|
|
||||||
//Gesichtsmerkmale
|
|
||||||
HeadOverlay blemishes = new HeadOverlay()
|
|
||||||
{
|
|
||||||
Index = character.Blemishes,
|
|
||||||
Opacity = character.BlemishesOpacity,
|
|
||||||
Color = 255,
|
|
||||||
SecondaryColor = 255
|
|
||||||
};
|
|
||||||
HeadOverlay facialHair = new HeadOverlay()
|
|
||||||
{
|
|
||||||
Index = character.FacialHair,
|
|
||||||
Opacity = character.FacialHairOpacity,
|
|
||||||
Color = character.BeardColor,
|
|
||||||
SecondaryColor = 255
|
|
||||||
};
|
|
||||||
HeadOverlay eyebrows = new HeadOverlay()
|
|
||||||
{
|
|
||||||
Index = character.Eyebrows,
|
|
||||||
Opacity = character.EyebrowsOpacity,
|
|
||||||
Color = character.EyebrowColor,
|
|
||||||
SecondaryColor = 255
|
|
||||||
};
|
|
||||||
HeadOverlay ageing = new HeadOverlay()
|
|
||||||
{
|
|
||||||
Index = character.Ageing,
|
|
||||||
Opacity = character.AgeingOpacity,
|
|
||||||
Color = 255,
|
|
||||||
SecondaryColor = 255
|
|
||||||
};
|
|
||||||
HeadOverlay makeup = new HeadOverlay()
|
|
||||||
{
|
|
||||||
Index = character.Makeup,
|
|
||||||
Opacity = character.MakeupOpacity,
|
|
||||||
Color = 255,
|
|
||||||
SecondaryColor = 255
|
|
||||||
};
|
|
||||||
HeadOverlay blush = new HeadOverlay()
|
|
||||||
{
|
|
||||||
Index = character.Blush,
|
|
||||||
Opacity = character.BlushOpacity,
|
|
||||||
Color = character.BlushColor,
|
|
||||||
SecondaryColor = 255
|
|
||||||
};
|
|
||||||
HeadOverlay complexion = new HeadOverlay()
|
|
||||||
{
|
|
||||||
Index = character.Complexion,
|
|
||||||
Opacity = character.ComplexionOpacity,
|
|
||||||
Color = 255,
|
|
||||||
SecondaryColor = 255
|
|
||||||
};
|
|
||||||
HeadOverlay sunDamage = new HeadOverlay()
|
|
||||||
{
|
|
||||||
Index = character.SunDamage,
|
|
||||||
Opacity = character.SunDamageOpacity,
|
|
||||||
Color = 255,
|
|
||||||
SecondaryColor = 255
|
|
||||||
};
|
|
||||||
HeadOverlay lipstick = new HeadOverlay()
|
|
||||||
{
|
|
||||||
Index = character.Lipstick,
|
|
||||||
Opacity = character.LipstickOpacity,
|
|
||||||
Color = character.LipstickColor,
|
|
||||||
SecondaryColor = 255
|
|
||||||
};
|
|
||||||
HeadOverlay freckles = new HeadOverlay()
|
|
||||||
{
|
|
||||||
Index = character.Freckles,
|
|
||||||
Opacity = character.FrecklesOpacity,
|
|
||||||
Color = 255,
|
|
||||||
SecondaryColor = 255
|
|
||||||
};
|
|
||||||
HeadOverlay chestHair = new HeadOverlay()
|
|
||||||
{
|
|
||||||
Index = character.ChestHair,
|
|
||||||
Opacity = character.ChestHairOpacity,
|
|
||||||
Color = character.ChestHairColor,
|
|
||||||
SecondaryColor = 255
|
|
||||||
};
|
|
||||||
|
|
||||||
player.SetHeadOverlay(0, blemishes);
|
|
||||||
player.SetHeadOverlay(1, facialHair);
|
|
||||||
player.SetHeadOverlay(2, eyebrows);
|
|
||||||
player.SetHeadOverlay(3, ageing);
|
|
||||||
player.SetHeadOverlay(4, makeup);
|
|
||||||
player.SetHeadOverlay(5, blush);
|
|
||||||
player.SetHeadOverlay(6, complexion);
|
|
||||||
player.SetHeadOverlay(7, sunDamage);
|
|
||||||
player.SetHeadOverlay(8, lipstick);
|
|
||||||
player.SetHeadOverlay(9, freckles);
|
|
||||||
player.SetHeadOverlay(10, chestHair);
|
|
||||||
player.SetHeadOverlay(11, blemishes);
|
|
||||||
player.SetHeadOverlay(12, blemishes);
|
|
||||||
|
|
||||||
//Gesicht (Vererbung durch Mutter / Vater)
|
|
||||||
HeadBlend headBlend = new HeadBlend()
|
|
||||||
{
|
|
||||||
ShapeFirst = character.Mother,
|
|
||||||
ShapeSecond = character.Father,
|
|
||||||
ShapeThird = 0,
|
|
||||||
SkinFirst = character.Mother,
|
|
||||||
SkinSecond = character.Father,
|
|
||||||
SkinThird = 0,
|
|
||||||
ShapeMix = character.Similarity,
|
|
||||||
SkinMix = character.SkinSimilarity,
|
|
||||||
ThirdMix = 0.0f
|
|
||||||
};
|
|
||||||
NAPI.Player.SetPlayerHeadBlend(player, headBlend);
|
|
||||||
|
|
||||||
//Haare und Haarfarbe
|
|
||||||
player.SetClothes(2, character.Hair, 0);
|
|
||||||
NAPI.Player.SetPlayerHairColor(player, character.HairColor, character.HairHighlightColor);
|
|
||||||
|
|
||||||
//Augenfarbe
|
|
||||||
NAPI.Player.SetPlayerEyeColor(player, character.EyeColor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Gesichtsmerkmale
|
||||||
|
HeadOverlay blemishes = new HeadOverlay()
|
||||||
|
{
|
||||||
|
Index = character.Blemishes,
|
||||||
|
Opacity = character.BlemishesOpacity,
|
||||||
|
Color = 255,
|
||||||
|
SecondaryColor = 255
|
||||||
|
};
|
||||||
|
HeadOverlay facialHair = new HeadOverlay()
|
||||||
|
{
|
||||||
|
Index = character.FacialHair,
|
||||||
|
Opacity = character.FacialHairOpacity,
|
||||||
|
Color = character.BeardColor,
|
||||||
|
SecondaryColor = 255
|
||||||
|
};
|
||||||
|
HeadOverlay eyebrows = new HeadOverlay()
|
||||||
|
{
|
||||||
|
Index = character.Eyebrows,
|
||||||
|
Opacity = character.EyebrowsOpacity,
|
||||||
|
Color = character.EyebrowColor,
|
||||||
|
SecondaryColor = 255
|
||||||
|
};
|
||||||
|
HeadOverlay ageing = new HeadOverlay()
|
||||||
|
{
|
||||||
|
Index = character.Ageing,
|
||||||
|
Opacity = character.AgeingOpacity,
|
||||||
|
Color = 255,
|
||||||
|
SecondaryColor = 255
|
||||||
|
};
|
||||||
|
HeadOverlay makeup = new HeadOverlay()
|
||||||
|
{
|
||||||
|
Index = character.Makeup,
|
||||||
|
Opacity = character.MakeupOpacity,
|
||||||
|
Color = 255,
|
||||||
|
SecondaryColor = 255
|
||||||
|
};
|
||||||
|
HeadOverlay blush = new HeadOverlay()
|
||||||
|
{
|
||||||
|
Index = character.Blush,
|
||||||
|
Opacity = character.BlushOpacity,
|
||||||
|
Color = character.BlushColor,
|
||||||
|
SecondaryColor = 255
|
||||||
|
};
|
||||||
|
HeadOverlay complexion = new HeadOverlay()
|
||||||
|
{
|
||||||
|
Index = character.Complexion,
|
||||||
|
Opacity = character.ComplexionOpacity,
|
||||||
|
Color = 255,
|
||||||
|
SecondaryColor = 255
|
||||||
|
};
|
||||||
|
HeadOverlay sunDamage = new HeadOverlay()
|
||||||
|
{
|
||||||
|
Index = character.SunDamage,
|
||||||
|
Opacity = character.SunDamageOpacity,
|
||||||
|
Color = 255,
|
||||||
|
SecondaryColor = 255
|
||||||
|
};
|
||||||
|
HeadOverlay lipstick = new HeadOverlay()
|
||||||
|
{
|
||||||
|
Index = character.Lipstick,
|
||||||
|
Opacity = character.LipstickOpacity,
|
||||||
|
Color = character.LipstickColor,
|
||||||
|
SecondaryColor = 255
|
||||||
|
};
|
||||||
|
HeadOverlay freckles = new HeadOverlay()
|
||||||
|
{
|
||||||
|
Index = character.Freckles,
|
||||||
|
Opacity = character.FrecklesOpacity,
|
||||||
|
Color = 255,
|
||||||
|
SecondaryColor = 255
|
||||||
|
};
|
||||||
|
HeadOverlay chestHair = new HeadOverlay()
|
||||||
|
{
|
||||||
|
Index = character.ChestHair,
|
||||||
|
Opacity = character.ChestHairOpacity,
|
||||||
|
Color = character.ChestHairColor,
|
||||||
|
SecondaryColor = 255
|
||||||
|
};
|
||||||
|
|
||||||
|
player.SetHeadOverlay(0, blemishes);
|
||||||
|
player.SetHeadOverlay(1, facialHair);
|
||||||
|
player.SetHeadOverlay(2, eyebrows);
|
||||||
|
player.SetHeadOverlay(3, ageing);
|
||||||
|
player.SetHeadOverlay(4, makeup);
|
||||||
|
player.SetHeadOverlay(5, blush);
|
||||||
|
player.SetHeadOverlay(6, complexion);
|
||||||
|
player.SetHeadOverlay(7, sunDamage);
|
||||||
|
player.SetHeadOverlay(8, lipstick);
|
||||||
|
player.SetHeadOverlay(9, freckles);
|
||||||
|
player.SetHeadOverlay(10, chestHair);
|
||||||
|
player.SetHeadOverlay(11, blemishes);
|
||||||
|
player.SetHeadOverlay(12, blemishes);
|
||||||
|
|
||||||
|
//Gesicht (Vererbung durch Mutter / Vater)
|
||||||
|
HeadBlend headBlend = new HeadBlend()
|
||||||
|
{
|
||||||
|
ShapeFirst = character.Mother,
|
||||||
|
ShapeSecond = character.Father,
|
||||||
|
ShapeThird = 0,
|
||||||
|
SkinFirst = character.Mother,
|
||||||
|
SkinSecond = character.Father,
|
||||||
|
SkinThird = 0,
|
||||||
|
ShapeMix = character.Similarity,
|
||||||
|
SkinMix = character.SkinSimilarity,
|
||||||
|
ThirdMix = 0.0f
|
||||||
|
};
|
||||||
|
NAPI.Player.SetPlayerHeadBlend(player, headBlend);
|
||||||
|
|
||||||
|
//Haare und Haarfarbe
|
||||||
|
player.SetClothes(2, character.Hair, 0);
|
||||||
|
NAPI.Player.SetPlayerHairColor(player, character.HairColor, character.HairHighlightColor);
|
||||||
|
|
||||||
|
//Augenfarbe
|
||||||
|
NAPI.Player.SetPlayerEyeColor(player, character.EyeColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,71 +15,71 @@ using ReallifeGamemode.Server.Types;
|
|||||||
namespace ReallifeGamemode.Server.Managers
|
namespace ReallifeGamemode.Server.Managers
|
||||||
{
|
{
|
||||||
public class DoorManager : Script
|
public class DoorManager : Script
|
||||||
|
{
|
||||||
|
private static Dictionary<int, NetHandle> _doorColShapes = new Dictionary<int, NetHandle>();
|
||||||
|
|
||||||
|
public static void LoadDoors()
|
||||||
{
|
{
|
||||||
private static Dictionary<int, NetHandle> _doorColShapes = new Dictionary<int, NetHandle>();
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
public static void LoadDoors()
|
foreach (Door door in dbContext.Doors)
|
||||||
{
|
{
|
||||||
using (var dbContext = new DatabaseContext())
|
_doorColShapes[door.Id] = NAPI.ColShape.CreateSphereColShape(door.Position, 30f);
|
||||||
{
|
|
||||||
foreach (Door door in dbContext.Doors)
|
|
||||||
{
|
|
||||||
_doorColShapes[door.Id] = NAPI.ColShape.CreateSphereColShape(door.Position, 30f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ReloadDoors()
|
|
||||||
{
|
|
||||||
foreach (var doorPair in _doorColShapes)
|
|
||||||
{
|
|
||||||
doorPair.Value.Entity<ColShape>().Delete();
|
|
||||||
}
|
|
||||||
_doorColShapes.Clear();
|
|
||||||
LoadDoors();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ChangeDoorState(Player player)
|
|
||||||
{
|
|
||||||
var user = player.GetUser();
|
|
||||||
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
IQueryable<Door> NearDoors = dbContext.Doors.Where(d => d.Position.DistanceTo(player.Position) <= d.Radius);
|
|
||||||
foreach (Door d in NearDoors)
|
|
||||||
{
|
|
||||||
if (!user.IsAdmin(AdminLevel.ADMIN) && (d.FactionId != user.FactionId || d.FactionId == null))
|
|
||||||
{
|
|
||||||
string lockState = "~r~Du hast kein Recht diese T\u00fcr " + (d.Locked == true ? "auf" : "ab") + "zuschlie\u00dfen!";
|
|
||||||
player.SendNotification(lockState, true);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
d.Locked = !d.Locked;
|
|
||||||
|
|
||||||
string notStr = d.Name + " " + (d.Locked == false ? "~g~auf" : "~r~ab") + "geschlossen";
|
|
||||||
|
|
||||||
player.SendNotification(notStr, true);
|
|
||||||
|
|
||||||
NAPI.Pools.GetAllPlayers().ForEach(p => p.TriggerEvent("changeDoorState", d.Model, d.X, d.Y, d.Z, (d.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f));
|
|
||||||
}
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[ServerEvent(Event.PlayerEnterColshape)]
|
|
||||||
public void DoorManagerPlayerEnterColShapeEvent(ColShape colShape, Player player)
|
|
||||||
{
|
|
||||||
if (_doorColShapes.ContainsValue(colShape.Handle))
|
|
||||||
{
|
|
||||||
int doorId = _doorColShapes.Where(d => d.Value.Value == colShape.Handle.Value).FirstOrDefault().Key;
|
|
||||||
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
Door door = dbContext.Doors.Where(d => d.Id == doorId).First();
|
|
||||||
player.TriggerEvent("changeDoorState", door.Model, door.X, door.Y, door.Z, (door.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ReloadDoors()
|
||||||
|
{
|
||||||
|
foreach (var doorPair in _doorColShapes)
|
||||||
|
{
|
||||||
|
doorPair.Value.Entity<ColShape>().Delete();
|
||||||
|
}
|
||||||
|
_doorColShapes.Clear();
|
||||||
|
LoadDoors();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ChangeDoorState(Player player)
|
||||||
|
{
|
||||||
|
var user = player.GetUser();
|
||||||
|
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
IQueryable<Door> NearDoors = dbContext.Doors.Where(d => d.Position.DistanceTo(player.Position) <= d.Radius);
|
||||||
|
foreach (Door d in NearDoors)
|
||||||
|
{
|
||||||
|
if (!user.IsAdmin(AdminLevel.ADMIN) && (d.FactionId != user.FactionId || d.FactionId == null))
|
||||||
|
{
|
||||||
|
string lockState = "~r~Du hast kein Recht diese T\u00fcr " + (d.Locked == true ? "auf" : "ab") + "zuschlie\u00dfen!";
|
||||||
|
player.SendNotification(lockState, true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
d.Locked = !d.Locked;
|
||||||
|
|
||||||
|
string notStr = d.Name + " " + (d.Locked == false ? "~g~auf" : "~r~ab") + "geschlossen";
|
||||||
|
|
||||||
|
player.SendNotification(notStr, true);
|
||||||
|
|
||||||
|
NAPI.Pools.GetAllPlayers().ForEach(p => p.TriggerEvent("changeDoorState", d.Model, d.X, d.Y, d.Z, (d.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f));
|
||||||
|
}
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[ServerEvent(Event.PlayerEnterColshape)]
|
||||||
|
public void DoorManagerPlayerEnterColShapeEvent(ColShape colShape, Player player)
|
||||||
|
{
|
||||||
|
if (_doorColShapes.ContainsValue(colShape.Handle))
|
||||||
|
{
|
||||||
|
int doorId = _doorColShapes.Where(d => d.Value.Value == colShape.Handle.Value).FirstOrDefault().Key;
|
||||||
|
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
Door door = dbContext.Doors.Where(d => d.Id == doorId).First();
|
||||||
|
player.TriggerEvent("changeDoorState", door.Model, door.X, door.Y, door.Z, (door.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,320 +15,320 @@ using ReallifeGamemode.Services;
|
|||||||
namespace ReallifeGamemode.Server.Managers
|
namespace ReallifeGamemode.Server.Managers
|
||||||
{
|
{
|
||||||
public class JobManager : Script
|
public class JobManager : Script
|
||||||
|
{
|
||||||
|
private static List<JobBase> _jobs = new List<JobBase>();
|
||||||
|
|
||||||
|
public static void LoadJobs()
|
||||||
{
|
{
|
||||||
private static List<JobBase> _jobs = new List<JobBase>();
|
IEnumerable<Type> jobTypes = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsSubclassOf(typeof(JobBase)) && !t.IsAbstract);
|
||||||
|
|
||||||
public static void LoadJobs()
|
foreach (var type in jobTypes)
|
||||||
|
{
|
||||||
|
var instance = Activator.CreateInstance(type) as JobBase;
|
||||||
|
if (GetJob(instance.Id) != null)
|
||||||
{
|
{
|
||||||
IEnumerable<Type> jobTypes = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsSubclassOf(typeof(JobBase)) && !t.IsAbstract);
|
throw new InvalidOperationException($"Double Job ID found: {instance.Id} | {instance.Name}");
|
||||||
|
|
||||||
foreach (var type in jobTypes)
|
|
||||||
{
|
|
||||||
var instance = Activator.CreateInstance(type) as JobBase;
|
|
||||||
if (GetJob(instance.Id) != null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"Double Job ID found: {instance.Id} | {instance.Name}");
|
|
||||||
}
|
|
||||||
_jobs.Add(instance);
|
|
||||||
NAPI.Util.ConsoleOutput($"Loading job {instance.Name}");
|
|
||||||
}
|
|
||||||
NAPI.Util.ConsoleOutput($"Loaded {_jobs.Count} jobs");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JobBase GetJob(int id) => _jobs.Where(j => j.Id == id).FirstOrDefault();
|
|
||||||
|
|
||||||
public static T GetJob<T>() where T : JobBase
|
|
||||||
{
|
|
||||||
return _jobs.Where(j => j.GetType() == typeof(T)).FirstOrDefault() as T;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<JobBase> GetJobs() => _jobs.OrderBy(j => j.Id).ToList();
|
|
||||||
|
|
||||||
[RemoteEvent("CLIENT:JobCenter_CancelJob")]
|
|
||||||
public void CancelJobEvent(Player player)
|
|
||||||
{
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
User u = player.GetUser(dbContext);
|
|
||||||
|
|
||||||
if (u == null) return;
|
|
||||||
|
|
||||||
if (u.JobId == null)
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(player, "Du hast momentan keinen Job, den du kündigen könntest.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
u.JobId = null;
|
|
||||||
|
|
||||||
ChatService.SendMessage(player, "~y~[JOBCENTER]~s~ Du hast deinen Job erfolgreich gekündigt.");
|
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("CLIENT:JobCenter_AcceptJob")]
|
|
||||||
public void AcceptJobEvent(Player player, int jobId)
|
|
||||||
{
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
User u = player.GetUser(dbContext);
|
|
||||||
|
|
||||||
if (u == null) return;
|
|
||||||
|
|
||||||
if (u.JobId != null)
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(player, "Du musst deinen alten Job kündigen, bevor du einen neuen ausüben kannst");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
JobBase job = JobManager.GetJob(jobId);
|
|
||||||
|
|
||||||
if (job == null)
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(player, "Bei der Job-Annahme ist ein Fehler aufgetretet: Dieser Job wurde nicht gefunden");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatService.SendMessage(player, $"~y~[JOBCENTER]~s~ Du hast erfolgreich deinen neuen Job: ~o~{job.Name}~s~ angenommen.");
|
|
||||||
|
|
||||||
u.JobId = jobId;
|
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("CLIENT:JobManager_ShowJobMenu")]
|
|
||||||
public void ShowJobMenuEvent(Player player)
|
|
||||||
{
|
|
||||||
User u = player.GetUser();
|
|
||||||
|
|
||||||
if (u.JobId == null) return;
|
|
||||||
|
|
||||||
JobBase job = GetJob(u.JobId.Value);
|
|
||||||
|
|
||||||
dynamic data = null;
|
|
||||||
|
|
||||||
if (job.Id == 1 && job.GetUsersInJob().Contains(player))
|
|
||||||
{
|
|
||||||
var taxiCalls = JobManager.GetJob<TaxiDriverJob>().TaxiContracts;
|
|
||||||
if (!taxiCalls.Any(t => t.Driver?.Handle == player.Handle)) // Spieler in keiner aktiven Fahrt
|
|
||||||
{
|
|
||||||
data = new
|
|
||||||
{
|
|
||||||
job.Id,
|
|
||||||
Status = 0,
|
|
||||||
JobData = new
|
|
||||||
{
|
|
||||||
TaxiCalls = taxiCalls
|
|
||||||
.Where(t => t.Driver == null)
|
|
||||||
.Select(t => new
|
|
||||||
{
|
|
||||||
t.Name,
|
|
||||||
Distance = Math.Round(t.Position.DistanceTo(player.Position), 0)
|
|
||||||
})
|
|
||||||
.OrderBy(t => t.Distance)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else // Spieler in aktiver Fahrt
|
|
||||||
{
|
|
||||||
data = new
|
|
||||||
{
|
|
||||||
job.Id,
|
|
||||||
Status = 1,
|
|
||||||
JobData = new
|
|
||||||
{
|
|
||||||
taxiCalls.Where(t => t.Driver.Handle == player.Handle).First().Name
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
JobPoint nearJobPoint = PositionManager.jobPoints.Find(p => p.Position.DistanceTo(player.Position) <= 2);
|
|
||||||
if (nearJobPoint == null && u.JobId == 2) return;
|
|
||||||
|
|
||||||
var json = JsonConvert.SerializeObject(data);
|
|
||||||
|
|
||||||
player.TriggerEvent("SERVER:Job_ShowJobMenu", job.Name, json);
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("CLIENT:Job_StartJob")]
|
|
||||||
public void StartJobEvent(Player player)
|
|
||||||
{
|
|
||||||
User u = player.GetUser();
|
|
||||||
|
|
||||||
if (u.JobId == null) return;
|
|
||||||
|
|
||||||
JobBase job = GetJob(u.JobId.Value);
|
|
||||||
|
|
||||||
if (job.GetUsersInJob().Contains(player))
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(player, "Du bist schon in deinem Job aktiv");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (job.NeedVehicleToStart && !job.GetJobVehicles().Any(v => v.GetVehicle().Handle.Value == player.Vehicle?.Handle.Value))
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(player, "Zum Start dieses Jobs musst du in einem Jobfahrzeug sein");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
job.StartJob(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("CLIENT:Job_StopJob")]
|
|
||||||
public void StopJob(Player player)
|
|
||||||
{
|
|
||||||
User u = player.GetUser();
|
|
||||||
|
|
||||||
if (u.JobId == null) return;
|
|
||||||
|
|
||||||
JobBase job = GetJob(u.JobId.Value);
|
|
||||||
|
|
||||||
if (!job.GetUsersInJob().Contains(player))
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(player, "Du führst deinen Job momentan nicht aus");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (job.NeedVehicleToStart && player.Vehicle != null)
|
|
||||||
{
|
|
||||||
VehicleStreaming.SetEngineState(player.Vehicle, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
job.StopJob(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
[ServerEvent(Event.PlayerExitVehicle)]
|
|
||||||
public void JobManagerPlayerExitVehicle(Player player, Vehicle veh)
|
|
||||||
{
|
|
||||||
User u = player.GetUser();
|
|
||||||
|
|
||||||
if (u.JobId == null) return;
|
|
||||||
|
|
||||||
JobBase job = GetJob(u.JobId.Value);
|
|
||||||
|
|
||||||
if (job.GetUsersInJob().Contains(player) && job.NeedVehicleToStart)
|
|
||||||
{
|
|
||||||
job.StopJob(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[ServerEvent(Event.PlayerEnterVehicle)]
|
|
||||||
public void JobManagerPlayerEnterVehicle(Player player, Vehicle veh, sbyte seat)
|
|
||||||
{
|
|
||||||
if (seat == 0) return;
|
|
||||||
ServerVehicle sVeh = veh.GetServerVehicle();
|
|
||||||
if (sVeh == null) return;
|
|
||||||
if (sVeh is JobVehicle jV && jV.JobId == 1) // Spieler steigt in Taxi ein
|
|
||||||
{
|
|
||||||
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
|
||||||
|
|
||||||
Player driver = veh.GetDriver();
|
|
||||||
if (!driver.HasData("DriverPrice")) return;
|
|
||||||
int taxiPrice = driver.GetData<int>("DriverPrice");
|
|
||||||
float km = 0;
|
|
||||||
if (!driver.HasData("FareKm")) { driver.SetData<float>("FareKm", km); }
|
|
||||||
km = driver.GetData<float>("FareKm");
|
|
||||||
if (driver.HasData("Passager")) return;
|
|
||||||
driver.SetData<int>("Passager", player.GetUser().Id);
|
|
||||||
driver.SetData<bool>("hasPassager", true);
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
User contractUser = player.GetUser(dbContext);
|
|
||||||
contractUser.Handmoney -= (int)Math.Round(km * taxiPrice);
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
contractUser.Player.TriggerEvent("SERVER:SET_HANDMONEY", contractUser.Handmoney);
|
|
||||||
}
|
|
||||||
player.TriggerEvent("CLIENT:startCustomerFare", taxiPrice, km);
|
|
||||||
|
|
||||||
var taxiContracts = taxiJob.TaxiContracts.Where(t => t.Name == player.Name);
|
|
||||||
if (taxiContracts.Count() == 0) return;
|
|
||||||
|
|
||||||
var contract = taxiContracts.First();
|
|
||||||
taxiJob.TaxiContracts.Remove(contract);
|
|
||||||
|
|
||||||
if (driver != null && contract.Driver != null && contract.Driver.Handle != veh.GetDriver().Handle)
|
|
||||||
{
|
|
||||||
ChatService.SendMessage(contract.Driver, $"!{{02FCFF}}{player.Name} ist in ein Taxi eingestiegen, der Auftrag wurde beendet.");
|
|
||||||
ChatService.SendMessage(player, $"!{{02FCFF}}Du bist in ein Taxi eingestiegen, der Auftrag wurde beendet.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[ServerEvent(Event.PlayerEnterVehicleAttempt)]
|
|
||||||
private void JobManagerEnterVehicleAttempt(Player player, Vehicle vehicle, sbyte seat)
|
|
||||||
{
|
|
||||||
if (JobManager.GetJob<RefuseCollectorJob>().GetUsersInJob().Contains(player)) { JobManager.GetJob<RefuseCollectorJob>().MuellmannOnPlayerEnterVehicle(player, vehicle, seat); }
|
|
||||||
}
|
|
||||||
|
|
||||||
[ServerEvent(Event.PlayerDeath)]
|
|
||||||
private void JobManagerOnPlayerDeath(Player player, Player killer, uint reason)
|
|
||||||
{
|
|
||||||
if (JobManager.GetJob<RefuseCollectorJob>().GetUsersInJob().Contains(player)) { JobManager.GetJob<RefuseCollectorJob>().MuellmannOnPlayerDeath(player); }
|
|
||||||
}
|
|
||||||
|
|
||||||
[ServerEvent(Event.PlayerDisconnected)]
|
|
||||||
private void JobManagerOnPlayerDisconnect(Player player, DisconnectionType type, string reason)
|
|
||||||
{
|
|
||||||
if (JobManager.GetJob<RefuseCollectorJob>().GetUsersInJob().Contains(player)) { JobManager.GetJob<RefuseCollectorJob>().MuellmannOnPlayerDc(player); }
|
|
||||||
}
|
|
||||||
|
|
||||||
[ServerEvent(Event.PlayerExitVehicle)]
|
|
||||||
public void JobManagerPlayerEnterVehicle(Player player, Vehicle veh)
|
|
||||||
{
|
|
||||||
ServerVehicle sVeh = veh.GetServerVehicle();
|
|
||||||
if (sVeh == null) return;
|
|
||||||
if (sVeh is JobVehicle jV && jV.JobId == 1) // Spieler steigt vom Taxi aus
|
|
||||||
{
|
|
||||||
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
|
||||||
if (veh.Occupants.Count == 0) return;
|
|
||||||
Player driver = veh.GetDriver();
|
|
||||||
if (driver == null) return;
|
|
||||||
if (player.GetUser().Id != driver.GetData<int>("Passager")) { player.TriggerEvent("CLIENT:cancelFare"); return; }
|
|
||||||
player.TriggerEvent("CLIENT:cancelFareCustomer");
|
|
||||||
driver.TriggerEvent("CLIENT:resetFareClock");
|
|
||||||
driver.ResetData("Passager");
|
|
||||||
driver.ResetData("hasPassager");
|
|
||||||
driver.SetData<float>("FareKm", 0);
|
|
||||||
foreach (Player occupant in veh.Occupants)
|
|
||||||
{
|
|
||||||
if (occupant == driver) continue;
|
|
||||||
occupant.WarpOutOfVehicle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("CLIENT:JobManager_TaxiJob_AcceptCall")]
|
|
||||||
public void TaxiJobAcceptCall(Player player, string name)
|
|
||||||
{
|
|
||||||
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
|
||||||
|
|
||||||
if (!taxiJob.TaxiContracts.Any(t => t.Name == name))
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(player, "Dieser Spieler hat kein Taxi gerufen oder der Auftrag ist nicht mehr aktuell");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var job = taxiJob.TaxiContracts.Where(t => t.Name == name).First();
|
|
||||||
|
|
||||||
var target = PlayerService.GetPlayerByNameOrId(name);
|
|
||||||
if (target == null)
|
|
||||||
{
|
|
||||||
taxiJob.TaxiContracts.Remove(job);
|
|
||||||
ChatService.ErrorMessage(player, "Dieser Spieler ist nicht mehr online");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
job.Driver = player;
|
|
||||||
|
|
||||||
player.TriggerEvent("SERVER:Util_setWaypoint", target.Position.X, target.Position.Y);
|
|
||||||
player.SetData<bool>("hasPassager", true);
|
|
||||||
|
|
||||||
ChatService.SendMessage(target, $"!{{02FCFF}}Dein Auftrag wurde von {player.Name} angenommen. Warte an deiner aktuellen Position.");
|
|
||||||
ChatService.SendMessage(target, $"!{{02FCFF}}Für die Anfahrt fallen zusätzlich Kosten auf.");
|
|
||||||
ChatService.SendMessage(player, $"!{{02FCFF}}Du hast den Auftrag von {name} angenommen. Hole ihn nun ab.");
|
|
||||||
}
|
}
|
||||||
|
_jobs.Add(instance);
|
||||||
|
NAPI.Util.ConsoleOutput($"Loading job {instance.Name}");
|
||||||
|
}
|
||||||
|
NAPI.Util.ConsoleOutput($"Loaded {_jobs.Count} jobs");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static JobBase GetJob(int id) => _jobs.Where(j => j.Id == id).FirstOrDefault();
|
||||||
|
|
||||||
|
public static T GetJob<T>() where T : JobBase
|
||||||
|
{
|
||||||
|
return _jobs.Where(j => j.GetType() == typeof(T)).FirstOrDefault() as T;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<JobBase> GetJobs() => _jobs.OrderBy(j => j.Id).ToList();
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:JobCenter_CancelJob")]
|
||||||
|
public void CancelJobEvent(Player player)
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
User u = player.GetUser(dbContext);
|
||||||
|
|
||||||
|
if (u == null) return;
|
||||||
|
|
||||||
|
if (u.JobId == null)
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(player, "Du hast momentan keinen Job, den du kündigen könntest.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
u.JobId = null;
|
||||||
|
|
||||||
|
ChatService.SendMessage(player, "~y~[JOBCENTER]~s~ Du hast deinen Job erfolgreich gekündigt.");
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:JobCenter_AcceptJob")]
|
||||||
|
public void AcceptJobEvent(Player player, int jobId)
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
User u = player.GetUser(dbContext);
|
||||||
|
|
||||||
|
if (u == null) return;
|
||||||
|
|
||||||
|
if (u.JobId != null)
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(player, "Du musst deinen alten Job kündigen, bevor du einen neuen ausüben kannst");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
JobBase job = JobManager.GetJob(jobId);
|
||||||
|
|
||||||
|
if (job == null)
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(player, "Bei der Job-Annahme ist ein Fehler aufgetretet: Dieser Job wurde nicht gefunden");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChatService.SendMessage(player, $"~y~[JOBCENTER]~s~ Du hast erfolgreich deinen neuen Job: ~o~{job.Name}~s~ angenommen.");
|
||||||
|
|
||||||
|
u.JobId = jobId;
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:JobManager_ShowJobMenu")]
|
||||||
|
public void ShowJobMenuEvent(Player player)
|
||||||
|
{
|
||||||
|
User u = player.GetUser();
|
||||||
|
|
||||||
|
if (u.JobId == null) return;
|
||||||
|
|
||||||
|
JobBase job = GetJob(u.JobId.Value);
|
||||||
|
|
||||||
|
dynamic data = null;
|
||||||
|
|
||||||
|
if (job.Id == 1 && job.GetUsersInJob().Contains(player))
|
||||||
|
{
|
||||||
|
var taxiCalls = JobManager.GetJob<TaxiDriverJob>().TaxiContracts;
|
||||||
|
if (!taxiCalls.Any(t => t.Driver?.Handle == player.Handle)) // Spieler in keiner aktiven Fahrt
|
||||||
|
{
|
||||||
|
data = new
|
||||||
|
{
|
||||||
|
job.Id,
|
||||||
|
Status = 0,
|
||||||
|
JobData = new
|
||||||
|
{
|
||||||
|
TaxiCalls = taxiCalls
|
||||||
|
.Where(t => t.Driver == null)
|
||||||
|
.Select(t => new
|
||||||
|
{
|
||||||
|
t.Name,
|
||||||
|
Distance = Math.Round(t.Position.DistanceTo(player.Position), 0)
|
||||||
|
})
|
||||||
|
.OrderBy(t => t.Distance)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else // Spieler in aktiver Fahrt
|
||||||
|
{
|
||||||
|
data = new
|
||||||
|
{
|
||||||
|
job.Id,
|
||||||
|
Status = 1,
|
||||||
|
JobData = new
|
||||||
|
{
|
||||||
|
taxiCalls.Where(t => t.Driver.Handle == player.Handle).First().Name
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JobPoint nearJobPoint = PositionManager.jobPoints.Find(p => p.Position.DistanceTo(player.Position) <= 2);
|
||||||
|
if (nearJobPoint == null && u.JobId == 2) return;
|
||||||
|
|
||||||
|
var json = JsonConvert.SerializeObject(data);
|
||||||
|
|
||||||
|
player.TriggerEvent("SERVER:Job_ShowJobMenu", job.Name, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:Job_StartJob")]
|
||||||
|
public void StartJobEvent(Player player)
|
||||||
|
{
|
||||||
|
User u = player.GetUser();
|
||||||
|
|
||||||
|
if (u.JobId == null) return;
|
||||||
|
|
||||||
|
JobBase job = GetJob(u.JobId.Value);
|
||||||
|
|
||||||
|
if (job.GetUsersInJob().Contains(player))
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(player, "Du bist schon in deinem Job aktiv");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (job.NeedVehicleToStart && !job.GetJobVehicles().Any(v => v.GetVehicle().Handle.Value == player.Vehicle?.Handle.Value))
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(player, "Zum Start dieses Jobs musst du in einem Jobfahrzeug sein");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
job.StartJob(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:Job_StopJob")]
|
||||||
|
public void StopJob(Player player)
|
||||||
|
{
|
||||||
|
User u = player.GetUser();
|
||||||
|
|
||||||
|
if (u.JobId == null) return;
|
||||||
|
|
||||||
|
JobBase job = GetJob(u.JobId.Value);
|
||||||
|
|
||||||
|
if (!job.GetUsersInJob().Contains(player))
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(player, "Du führst deinen Job momentan nicht aus");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (job.NeedVehicleToStart && player.Vehicle != null)
|
||||||
|
{
|
||||||
|
VehicleStreaming.SetEngineState(player.Vehicle, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
job.StopJob(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
[ServerEvent(Event.PlayerExitVehicle)]
|
||||||
|
public void JobManagerPlayerExitVehicle(Player player, Vehicle veh)
|
||||||
|
{
|
||||||
|
User u = player.GetUser();
|
||||||
|
|
||||||
|
if (u.JobId == null) return;
|
||||||
|
|
||||||
|
JobBase job = GetJob(u.JobId.Value);
|
||||||
|
|
||||||
|
if (job.GetUsersInJob().Contains(player) && job.NeedVehicleToStart)
|
||||||
|
{
|
||||||
|
job.StopJob(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[ServerEvent(Event.PlayerEnterVehicle)]
|
||||||
|
public void JobManagerPlayerEnterVehicle(Player player, Vehicle veh, sbyte seat)
|
||||||
|
{
|
||||||
|
if (seat == 0) return;
|
||||||
|
ServerVehicle sVeh = veh.GetServerVehicle();
|
||||||
|
if (sVeh == null) return;
|
||||||
|
if (sVeh is JobVehicle jV && jV.JobId == 1) // Spieler steigt in Taxi ein
|
||||||
|
{
|
||||||
|
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
||||||
|
|
||||||
|
Player driver = veh.GetDriver();
|
||||||
|
if (!driver.HasData("DriverPrice")) return;
|
||||||
|
int taxiPrice = driver.GetData<int>("DriverPrice");
|
||||||
|
float km = 0;
|
||||||
|
if (!driver.HasData("FareKm")) { driver.SetData<float>("FareKm", km); }
|
||||||
|
km = driver.GetData<float>("FareKm");
|
||||||
|
if (driver.HasData("Passager")) return;
|
||||||
|
driver.SetData<int>("Passager", player.GetUser().Id);
|
||||||
|
driver.SetData<bool>("hasPassager", true);
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
User contractUser = player.GetUser(dbContext);
|
||||||
|
contractUser.Handmoney -= (int)Math.Round(km * taxiPrice);
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
contractUser.Player.TriggerEvent("SERVER:SET_HANDMONEY", contractUser.Handmoney);
|
||||||
|
}
|
||||||
|
player.TriggerEvent("CLIENT:startCustomerFare", taxiPrice, km);
|
||||||
|
|
||||||
|
var taxiContracts = taxiJob.TaxiContracts.Where(t => t.Name == player.Name);
|
||||||
|
if (taxiContracts.Count() == 0) return;
|
||||||
|
|
||||||
|
var contract = taxiContracts.First();
|
||||||
|
taxiJob.TaxiContracts.Remove(contract);
|
||||||
|
|
||||||
|
if (driver != null && contract.Driver != null && contract.Driver.Handle != veh.GetDriver().Handle)
|
||||||
|
{
|
||||||
|
ChatService.SendMessage(contract.Driver, $"!{{02FCFF}}{player.Name} ist in ein Taxi eingestiegen, der Auftrag wurde beendet.");
|
||||||
|
ChatService.SendMessage(player, $"!{{02FCFF}}Du bist in ein Taxi eingestiegen, der Auftrag wurde beendet.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[ServerEvent(Event.PlayerEnterVehicleAttempt)]
|
||||||
|
private void JobManagerEnterVehicleAttempt(Player player, Vehicle vehicle, sbyte seat)
|
||||||
|
{
|
||||||
|
if (JobManager.GetJob<RefuseCollectorJob>().GetUsersInJob().Contains(player)) { JobManager.GetJob<RefuseCollectorJob>().MuellmannOnPlayerEnterVehicle(player, vehicle, seat); }
|
||||||
|
}
|
||||||
|
|
||||||
|
[ServerEvent(Event.PlayerDeath)]
|
||||||
|
private void JobManagerOnPlayerDeath(Player player, Player killer, uint reason)
|
||||||
|
{
|
||||||
|
if (JobManager.GetJob<RefuseCollectorJob>().GetUsersInJob().Contains(player)) { JobManager.GetJob<RefuseCollectorJob>().MuellmannOnPlayerDeath(player); }
|
||||||
|
}
|
||||||
|
|
||||||
|
[ServerEvent(Event.PlayerDisconnected)]
|
||||||
|
private void JobManagerOnPlayerDisconnect(Player player, DisconnectionType type, string reason)
|
||||||
|
{
|
||||||
|
if (JobManager.GetJob<RefuseCollectorJob>().GetUsersInJob().Contains(player)) { JobManager.GetJob<RefuseCollectorJob>().MuellmannOnPlayerDc(player); }
|
||||||
|
}
|
||||||
|
|
||||||
|
[ServerEvent(Event.PlayerExitVehicle)]
|
||||||
|
public void JobManagerPlayerEnterVehicle(Player player, Vehicle veh)
|
||||||
|
{
|
||||||
|
ServerVehicle sVeh = veh.GetServerVehicle();
|
||||||
|
if (sVeh == null) return;
|
||||||
|
if (sVeh is JobVehicle jV && jV.JobId == 1) // Spieler steigt vom Taxi aus
|
||||||
|
{
|
||||||
|
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
||||||
|
if (veh.Occupants.Count == 0) return;
|
||||||
|
Player driver = veh.GetDriver();
|
||||||
|
if (driver == null) return;
|
||||||
|
if (player.GetUser().Id != driver.GetData<int>("Passager")) { player.TriggerEvent("CLIENT:cancelFare"); return; }
|
||||||
|
player.TriggerEvent("CLIENT:cancelFareCustomer");
|
||||||
|
driver.TriggerEvent("CLIENT:resetFareClock");
|
||||||
|
driver.ResetData("Passager");
|
||||||
|
driver.ResetData("hasPassager");
|
||||||
|
driver.SetData<float>("FareKm", 0);
|
||||||
|
foreach (Player occupant in veh.Occupants)
|
||||||
|
{
|
||||||
|
if (occupant == driver) continue;
|
||||||
|
occupant.WarpOutOfVehicle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:JobManager_TaxiJob_AcceptCall")]
|
||||||
|
public void TaxiJobAcceptCall(Player player, string name)
|
||||||
|
{
|
||||||
|
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
||||||
|
|
||||||
|
if (!taxiJob.TaxiContracts.Any(t => t.Name == name))
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(player, "Dieser Spieler hat kein Taxi gerufen oder der Auftrag ist nicht mehr aktuell");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var job = taxiJob.TaxiContracts.Where(t => t.Name == name).First();
|
||||||
|
|
||||||
|
var target = PlayerService.GetPlayerByNameOrId(name);
|
||||||
|
if (target == null)
|
||||||
|
{
|
||||||
|
taxiJob.TaxiContracts.Remove(job);
|
||||||
|
ChatService.ErrorMessage(player, "Dieser Spieler ist nicht mehr online");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
job.Driver = player;
|
||||||
|
|
||||||
|
player.TriggerEvent("SERVER:Util_setWaypoint", target.Position.X, target.Position.Y);
|
||||||
|
player.SetData<bool>("hasPassager", true);
|
||||||
|
|
||||||
|
ChatService.SendMessage(target, $"!{{02FCFF}}Dein Auftrag wurde von {player.Name} angenommen. Warte an deiner aktuellen Position.");
|
||||||
|
ChatService.SendMessage(target, $"!{{02FCFF}}Für die Anfahrt fallen zusätzlich Kosten auf.");
|
||||||
|
ChatService.SendMessage(player, $"!{{02FCFF}}Du hast den Auftrag von {name} angenommen. Hole ihn nun ab.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,29 +13,29 @@ using ReallifeGamemode.Server.Extensions;
|
|||||||
namespace ReallifeGamemode.Server.Managers
|
namespace ReallifeGamemode.Server.Managers
|
||||||
{
|
{
|
||||||
public class LoadManager : Script
|
public class LoadManager : Script
|
||||||
|
{
|
||||||
|
[ServerEvent(Event.ResourceStart)]
|
||||||
|
public void OnResourceStart()
|
||||||
{
|
{
|
||||||
[ServerEvent(Event.ResourceStart)]
|
using (var dbContext = new DatabaseContext())
|
||||||
public void OnResourceStart()
|
{
|
||||||
|
foreach (SavedBlip b in dbContext.Blips)
|
||||||
{
|
{
|
||||||
using (var dbContext = new DatabaseContext())
|
if (b.Active == true)
|
||||||
{
|
{
|
||||||
foreach (SavedBlip b in dbContext.Blips)
|
NAPI.Blip.CreateBlip((uint)b.Sprite, new Vector3(b.PositionX, b.PositionY, b.PositionZ), b.Scale,
|
||||||
{
|
b.Color, b.Name, b.Alpha, b.DrawDistance, b.ShortRange, (short)b.Rotation, b.Dimension);
|
||||||
if (b.Active == true)
|
}
|
||||||
{
|
|
||||||
NAPI.Blip.CreateBlip((uint)b.Sprite, new Vector3(b.PositionX, b.PositionY, b.PositionZ), b.Scale,
|
|
||||||
b.Color, b.Name, b.Alpha, b.DrawDistance, b.ShortRange, (short)b.Rotation, b.Dimension);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (ServerVehicle veh in dbContext.ServerVehicles)
|
|
||||||
{
|
|
||||||
if (!veh.Active) continue;
|
|
||||||
|
|
||||||
Vehicle current = veh.Spawn();
|
|
||||||
TuningManager.ApplyTuningToServerVehicle(veh);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (ServerVehicle veh in dbContext.ServerVehicles)
|
||||||
|
{
|
||||||
|
if (!veh.Active) continue;
|
||||||
|
|
||||||
|
Vehicle current = veh.Spawn();
|
||||||
|
TuningManager.ApplyTuningToServerVehicle(veh);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
{
|
{
|
||||||
public class PedManager : Script
|
public class PedManager : Script
|
||||||
{
|
{
|
||||||
private List<PedData> pedDatas = new List<PedData>();
|
private List<PedData> pedDatas = new List<PedData>();
|
||||||
public static List<SavedPed> serverPeds = new List<SavedPed>();
|
public static List<SavedPed> serverPeds = new List<SavedPed>();
|
||||||
private static Dictionary<Player, List<PedData>> dataDict = new Dictionary<Player, List<PedData>>();
|
private static Dictionary<Player, List<PedData>> dataDict = new Dictionary<Player, List<PedData>>();
|
||||||
private void GetPedsFromDatabase()
|
private void GetPedsFromDatabase()
|
||||||
@@ -42,7 +42,7 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
if (!s.Active) continue;
|
if (!s.Active) continue;
|
||||||
Vector3 vector3 = new Vector3(s.PositionX, s.PositionY, s.PositionZ);
|
Vector3 vector3 = new Vector3(s.PositionX, s.PositionY, s.PositionZ);
|
||||||
pedDatas.Add(new PedData(player, (DataType)s.Type, vector3, s.Heading, s.HashModel));
|
pedDatas.Add(new PedData(player, (DataType)s.Type, vector3, s.Heading, s.HashModel));
|
||||||
|
|
||||||
vector3s.Add(vector3);
|
vector3s.Add(vector3);
|
||||||
headings.Add(s.Heading);
|
headings.Add(s.Heading);
|
||||||
hashes.Add(s.HashModel);
|
hashes.Add(s.HashModel);
|
||||||
|
|||||||
@@ -10,195 +10,195 @@ using ReallifeGamemode.Server.Extensions;
|
|||||||
namespace ReallifeGamemode.Server.Managers
|
namespace ReallifeGamemode.Server.Managers
|
||||||
{
|
{
|
||||||
public class SaveManager : Script
|
public class SaveManager : Script
|
||||||
|
{
|
||||||
|
[RemoteEvent("OnSaveBlipData")]
|
||||||
|
public static void OnSaveBlipData(Player player, string blipSprite, string blipName, string blipScale, string blipColor,
|
||||||
|
string blipAlpha, string blipDrawDistance, string blipShortRange, string blipRotation, string blipDimension)
|
||||||
{
|
{
|
||||||
[RemoteEvent("OnSaveBlipData")]
|
float x = player.Position.X;
|
||||||
public static void OnSaveBlipData(Player player, string blipSprite, string blipName, string blipScale, string blipColor,
|
float y = player.Position.Y;
|
||||||
string blipAlpha, string blipDrawDistance, string blipShortRange, string blipRotation, string blipDimension)
|
float z = player.Position.Z;
|
||||||
|
short sprite = short.Parse(blipSprite);
|
||||||
|
string name = blipName;
|
||||||
|
float scale = float.Parse(blipScale);
|
||||||
|
byte color = Convert.ToByte(blipColor);
|
||||||
|
byte alpha = Convert.ToByte(blipAlpha);
|
||||||
|
float drawDistance = float.Parse(blipDrawDistance);
|
||||||
|
bool shortRange = bool.Parse(blipShortRange);
|
||||||
|
float rotation = float.Parse(blipRotation);
|
||||||
|
byte dimension = Convert.ToByte(blipDimension);
|
||||||
|
|
||||||
|
NAPI.Blip.CreateBlip(uint.Parse(blipSprite), new Vector3(x, y, z), scale, color, name, alpha, drawDistance, shortRange, short.Parse(blipRotation), dimension);
|
||||||
|
|
||||||
|
using (var saveData = new DatabaseContext())
|
||||||
|
{
|
||||||
|
var dataSet = new SavedBlip
|
||||||
{
|
{
|
||||||
float x = player.Position.X;
|
Sprite = sprite,
|
||||||
float y = player.Position.Y;
|
PositionX = x,
|
||||||
float z = player.Position.Z;
|
PositionY = y,
|
||||||
short sprite = short.Parse(blipSprite);
|
PositionZ = z,
|
||||||
string name = blipName;
|
Name = blipName,
|
||||||
float scale = float.Parse(blipScale);
|
Scale = scale,
|
||||||
byte color = Convert.ToByte(blipColor);
|
Color = color,
|
||||||
byte alpha = Convert.ToByte(blipAlpha);
|
Alpha = alpha,
|
||||||
float drawDistance = float.Parse(blipDrawDistance);
|
DrawDistance = drawDistance,
|
||||||
bool shortRange = bool.Parse(blipShortRange);
|
ShortRange = shortRange,
|
||||||
float rotation = float.Parse(blipRotation);
|
Rotation = rotation,
|
||||||
byte dimension = Convert.ToByte(blipDimension);
|
Dimension = dimension,
|
||||||
|
Active = true
|
||||||
|
};
|
||||||
|
saveData.Blips.Add(dataSet);
|
||||||
|
saveData.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NAPI.Blip.CreateBlip(uint.Parse(blipSprite), new Vector3(x, y, z), scale, color, name, alpha, drawDistance, shortRange, short.Parse(blipRotation), dimension);
|
public static Vehicle SaveVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
||||||
|
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked)
|
||||||
using (var saveData = new DatabaseContext())
|
{
|
||||||
{
|
using (var saveData = new DatabaseContext())
|
||||||
var dataSet = new SavedBlip
|
{
|
||||||
{
|
var dataSet = new SavedVehicle
|
||||||
Sprite = sprite,
|
|
||||||
PositionX = x,
|
|
||||||
PositionY = y,
|
|
||||||
PositionZ = z,
|
|
||||||
Name = blipName,
|
|
||||||
Scale = scale,
|
|
||||||
Color = color,
|
|
||||||
Alpha = alpha,
|
|
||||||
DrawDistance = drawDistance,
|
|
||||||
ShortRange = shortRange,
|
|
||||||
Rotation = rotation,
|
|
||||||
Dimension = dimension,
|
|
||||||
Active = true
|
|
||||||
};
|
|
||||||
saveData.Blips.Add(dataSet);
|
|
||||||
saveData.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vehicle SaveVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
|
||||||
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked)
|
|
||||||
{
|
{
|
||||||
using (var saveData = new DatabaseContext())
|
Model = vehicleModel,
|
||||||
{
|
PositionX = vehiclePosition.X,
|
||||||
var dataSet = new SavedVehicle
|
PositionY = vehiclePosition.Y,
|
||||||
{
|
PositionZ = vehiclePosition.Z,
|
||||||
Model = vehicleModel,
|
Heading = vehicleHeading,
|
||||||
PositionX = vehiclePosition.X,
|
NumberPlate = vehicleNumberPlate,
|
||||||
PositionY = vehiclePosition.Y,
|
PrimaryColor = vehiclePrimaryColor,
|
||||||
PositionZ = vehiclePosition.Z,
|
SecondaryColor = vehicleSecondaryColor,
|
||||||
Heading = vehicleHeading,
|
Locked = vehicleLocked,
|
||||||
NumberPlate = vehicleNumberPlate,
|
Active = true
|
||||||
PrimaryColor = vehiclePrimaryColor,
|
};
|
||||||
SecondaryColor = vehicleSecondaryColor,
|
saveData.Vehicles.Add(dataSet);
|
||||||
Locked = vehicleLocked,
|
saveData.SaveChanges();
|
||||||
Active = true
|
|
||||||
};
|
|
||||||
saveData.Vehicles.Add(dataSet);
|
|
||||||
saveData.SaveChanges();
|
|
||||||
|
|
||||||
return dataSet.Spawn(veh);
|
return dataSet.Spawn(veh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vehicle SaveJobVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
public static Vehicle SaveJobVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
||||||
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int jobId)
|
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int jobId)
|
||||||
|
{
|
||||||
|
using (var saveData = new DatabaseContext())
|
||||||
|
{
|
||||||
|
var dataSet = new JobVehicle
|
||||||
{
|
{
|
||||||
using (var saveData = new DatabaseContext())
|
Model = vehicleModel,
|
||||||
{
|
JobId = jobId,
|
||||||
var dataSet = new JobVehicle
|
PositionX = vehiclePosition.X,
|
||||||
{
|
PositionY = vehiclePosition.Y,
|
||||||
Model = vehicleModel,
|
PositionZ = vehiclePosition.Z,
|
||||||
JobId = jobId,
|
Heading = vehicleHeading,
|
||||||
PositionX = vehiclePosition.X,
|
NumberPlate = vehicleNumberPlate,
|
||||||
PositionY = vehiclePosition.Y,
|
PrimaryColor = vehiclePrimaryColor,
|
||||||
PositionZ = vehiclePosition.Z,
|
SecondaryColor = vehicleSecondaryColor,
|
||||||
Heading = vehicleHeading,
|
Locked = vehicleLocked,
|
||||||
NumberPlate = vehicleNumberPlate,
|
Active = true
|
||||||
PrimaryColor = vehiclePrimaryColor,
|
};
|
||||||
SecondaryColor = vehicleSecondaryColor,
|
saveData.JobVehicles.Add(dataSet);
|
||||||
Locked = vehicleLocked,
|
saveData.SaveChanges();
|
||||||
Active = true
|
|
||||||
};
|
|
||||||
saveData.JobVehicles.Add(dataSet);
|
|
||||||
saveData.SaveChanges();
|
|
||||||
|
|
||||||
return dataSet.Spawn(veh);
|
return dataSet.Spawn(veh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vehicle SaveSchoolVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
public static Vehicle SaveSchoolVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
||||||
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int schoolId)
|
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int schoolId)
|
||||||
|
{
|
||||||
|
using (var saveData = new DatabaseContext())
|
||||||
|
{
|
||||||
|
var dataSet = new SchoolVehicle
|
||||||
{
|
{
|
||||||
using (var saveData = new DatabaseContext())
|
Model = vehicleModel,
|
||||||
{
|
SchoolId = schoolId,
|
||||||
var dataSet = new SchoolVehicle
|
PositionX = vehiclePosition.X,
|
||||||
{
|
PositionY = vehiclePosition.Y,
|
||||||
Model = vehicleModel,
|
PositionZ = vehiclePosition.Z,
|
||||||
SchoolId = schoolId,
|
Heading = vehicleHeading,
|
||||||
PositionX = vehiclePosition.X,
|
NumberPlate = vehicleNumberPlate,
|
||||||
PositionY = vehiclePosition.Y,
|
PrimaryColor = vehiclePrimaryColor,
|
||||||
PositionZ = vehiclePosition.Z,
|
SecondaryColor = vehicleSecondaryColor,
|
||||||
Heading = vehicleHeading,
|
Locked = vehicleLocked,
|
||||||
NumberPlate = vehicleNumberPlate,
|
Active = true
|
||||||
PrimaryColor = vehiclePrimaryColor,
|
};
|
||||||
SecondaryColor = vehicleSecondaryColor,
|
saveData.SchoolVehicles.Add(dataSet);
|
||||||
Locked = vehicleLocked,
|
saveData.SaveChanges();
|
||||||
Active = true
|
|
||||||
};
|
|
||||||
saveData.SchoolVehicles.Add(dataSet);
|
|
||||||
saveData.SaveChanges();
|
|
||||||
|
|
||||||
return dataSet.Spawn(veh);
|
return dataSet.Spawn(veh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vehicle SaveFactionVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
public static Vehicle SaveFactionVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
||||||
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int[] factionId, int livery)
|
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int[] factionId, int livery)
|
||||||
|
{
|
||||||
|
using (var saveData = new DatabaseContext())
|
||||||
|
{
|
||||||
|
var dataSet = new FactionVehicle
|
||||||
{
|
{
|
||||||
using (var saveData = new DatabaseContext())
|
Model = vehicleModel,
|
||||||
{
|
Owners = JsonConvert.SerializeObject(factionId),
|
||||||
var dataSet = new FactionVehicle
|
PositionX = vehiclePosition.X,
|
||||||
{
|
PositionY = vehiclePosition.Y,
|
||||||
Model = vehicleModel,
|
PositionZ = vehiclePosition.Z,
|
||||||
Owners = JsonConvert.SerializeObject(factionId),
|
Heading = vehicleHeading,
|
||||||
PositionX = vehiclePosition.X,
|
NumberPlate = vehicleNumberPlate,
|
||||||
PositionY = vehiclePosition.Y,
|
PrimaryColor = vehiclePrimaryColor,
|
||||||
PositionZ = vehiclePosition.Z,
|
SecondaryColor = vehicleSecondaryColor,
|
||||||
Heading = vehicleHeading,
|
Locked = vehicleLocked,
|
||||||
NumberPlate = vehicleNumberPlate,
|
Active = true,
|
||||||
PrimaryColor = vehiclePrimaryColor,
|
Livery = livery
|
||||||
SecondaryColor = vehicleSecondaryColor,
|
};
|
||||||
Locked = vehicleLocked,
|
saveData.FactionVehicles.Add(dataSet);
|
||||||
Active = true,
|
saveData.SaveChanges();
|
||||||
Livery = livery
|
|
||||||
};
|
|
||||||
saveData.FactionVehicles.Add(dataSet);
|
|
||||||
saveData.SaveChanges();
|
|
||||||
|
|
||||||
return dataSet.Spawn(veh);
|
return dataSet.Spawn(veh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vehicle SaveShopVehicleData(Vehicle veh, VehicleHash vehicleModel, string vehicleModelName, Vector3 vehiclePosition, float vehicleHeading,
|
public static Vehicle SaveShopVehicleData(Vehicle veh, VehicleHash vehicleModel, string vehicleModelName, Vector3 vehiclePosition, float vehicleHeading,
|
||||||
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, BusinessBase business, int price)
|
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, BusinessBase business, int price)
|
||||||
|
{
|
||||||
|
using (var saveData = new DatabaseContext())
|
||||||
|
{
|
||||||
|
var dataSet = new ShopVehicle
|
||||||
{
|
{
|
||||||
using (var saveData = new DatabaseContext())
|
Model = vehicleModel,
|
||||||
{
|
PositionX = vehiclePosition.X,
|
||||||
var dataSet = new ShopVehicle
|
PositionY = vehiclePosition.Y,
|
||||||
{
|
PositionZ = vehiclePosition.Z,
|
||||||
Model = vehicleModel,
|
Heading = vehicleHeading,
|
||||||
PositionX = vehiclePosition.X,
|
NumberPlate = vehicleNumberPlate,
|
||||||
PositionY = vehiclePosition.Y,
|
PrimaryColor = vehiclePrimaryColor,
|
||||||
PositionZ = vehiclePosition.Z,
|
SecondaryColor = vehicleSecondaryColor,
|
||||||
Heading = vehicleHeading,
|
Active = true,
|
||||||
NumberPlate = vehicleNumberPlate,
|
BusinessId = business.Id,
|
||||||
PrimaryColor = vehiclePrimaryColor,
|
Price = price
|
||||||
SecondaryColor = vehicleSecondaryColor,
|
};
|
||||||
Active = true,
|
saveData.ShopVehicles.Add(dataSet);
|
||||||
BusinessId = business.Id,
|
saveData.SaveChanges();
|
||||||
Price = price
|
|
||||||
};
|
|
||||||
saveData.ShopVehicles.Add(dataSet);
|
|
||||||
saveData.SaveChanges();
|
|
||||||
|
|
||||||
return dataSet.Spawn(veh);
|
return dataSet.Spawn(veh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SaveGotoPoint(Player player, string description)
|
public static void SaveGotoPoint(Player player, string description)
|
||||||
|
{
|
||||||
|
using (var saveData = new DatabaseContext())
|
||||||
|
{
|
||||||
|
var dataSet = new GotoPoint
|
||||||
{
|
{
|
||||||
using (var saveData = new DatabaseContext())
|
Description = description,
|
||||||
{
|
X = player.Position.X,
|
||||||
var dataSet = new GotoPoint
|
Y = player.Position.Y,
|
||||||
{
|
Z = player.Position.Z,
|
||||||
Description = description,
|
Active = true
|
||||||
X = player.Position.X,
|
};
|
||||||
Y = player.Position.Y,
|
saveData.GotoPoints.Add(dataSet);
|
||||||
Z = player.Position.Z,
|
saveData.SaveChanges();
|
||||||
Active = true
|
}
|
||||||
};
|
}
|
||||||
saveData.GotoPoints.Add(dataSet);
|
|
||||||
saveData.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SaveAllOnSave()
|
public static void SaveAllOnSave()
|
||||||
{
|
{
|
||||||
@@ -219,8 +219,8 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
user.PositionZ = pos.Z;
|
user.PositionZ = pos.Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveAll.SaveChanges();
|
saveAll.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,57 +9,57 @@ using ReallifeGamemode.Server.Shop.SevenEleven;
|
|||||||
namespace ReallifeGamemode.Server.Managers
|
namespace ReallifeGamemode.Server.Managers
|
||||||
{
|
{
|
||||||
public class ShopManager
|
public class ShopManager
|
||||||
|
{
|
||||||
|
public static List<ClotheShop> clotheStores = new List<ClotheShop>();
|
||||||
|
public static List<ItemShop> itemShops = new List<ItemShop>();
|
||||||
|
|
||||||
|
public static void LoadClotheShops()
|
||||||
{
|
{
|
||||||
public static List<ClotheShop> clotheStores = new List<ClotheShop>();
|
using (var dbContext = new DatabaseContext())
|
||||||
public static List<ItemShop> itemShops = new List<ItemShop>();
|
{
|
||||||
|
List<SavedBlip> discount = dbContext.Blips.ToList().FindAll(s => s.Name == "Binco" || s.Name == "Discount Store");
|
||||||
|
List<SavedBlip> midclass = dbContext.Blips.ToList().FindAll(s => s.Name == "Suburban");
|
||||||
|
List<SavedBlip> luxury = dbContext.Blips.ToList().FindAll(s => s.Name == "Ponsonbys");
|
||||||
|
|
||||||
public static void LoadClotheShops()
|
foreach (var store in discount)
|
||||||
{
|
{
|
||||||
using (var dbContext = new DatabaseContext())
|
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||||
{
|
ClotheShop newShop = new ClotheShop(1, pos);
|
||||||
List<SavedBlip> discount = dbContext.Blips.ToList().FindAll(s => s.Name == "Binco" || s.Name == "Discount Store");
|
clotheStores.Add(newShop);
|
||||||
List<SavedBlip> midclass = dbContext.Blips.ToList().FindAll(s => s.Name == "Suburban");
|
NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}");
|
||||||
List<SavedBlip> luxury = dbContext.Blips.ToList().FindAll(s => s.Name == "Ponsonbys");
|
|
||||||
|
|
||||||
foreach (var store in discount)
|
|
||||||
{
|
|
||||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
|
||||||
ClotheShop newShop = new ClotheShop(1, pos);
|
|
||||||
clotheStores.Add(newShop);
|
|
||||||
NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}");
|
|
||||||
}
|
|
||||||
foreach (var store in midclass)
|
|
||||||
{
|
|
||||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
|
||||||
ClotheShop newShop = new ClotheShop(2, pos);
|
|
||||||
clotheStores.Add(newShop);
|
|
||||||
NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}");
|
|
||||||
}
|
|
||||||
foreach (var store in luxury)
|
|
||||||
{
|
|
||||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
|
||||||
ClotheShop newShop = new ClotheShop(3, pos);
|
|
||||||
clotheStores.Add(newShop);
|
|
||||||
NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
foreach (var store in midclass)
|
||||||
public static void LoadItemShops()
|
|
||||||
{
|
{
|
||||||
using (var dbContext = new DatabaseContext())
|
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||||
{
|
ClotheShop newShop = new ClotheShop(2, pos);
|
||||||
int id = 0;
|
clotheStores.Add(newShop);
|
||||||
List<SavedBlip> shops = dbContext.Blips.ToList().FindAll(s => s.Name == "24/7");
|
NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}");
|
||||||
foreach (var store in shops)
|
|
||||||
{
|
|
||||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
|
||||||
ItemShop newShop = new ItemShop(pos, id);
|
|
||||||
itemShops.Add(newShop);
|
|
||||||
id++;
|
|
||||||
}
|
|
||||||
NAPI.Util.ConsoleOutput($"Loaded {itemShops.Count}x 24/7");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
foreach (var store in luxury)
|
||||||
|
{
|
||||||
|
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||||
|
ClotheShop newShop = new ClotheShop(3, pos);
|
||||||
|
clotheStores.Add(newShop);
|
||||||
|
NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void LoadItemShops()
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
List<SavedBlip> shops = dbContext.Blips.ToList().FindAll(s => s.Name == "24/7");
|
||||||
|
foreach (var store in shops)
|
||||||
|
{
|
||||||
|
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||||
|
ItemShop newShop = new ItemShop(pos, id);
|
||||||
|
itemShops.Add(newShop);
|
||||||
|
id++;
|
||||||
|
}
|
||||||
|
NAPI.Util.ConsoleOutput($"Loaded {itemShops.Count}x 24/7");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,29 +5,29 @@ using GTANetworkAPI;
|
|||||||
namespace ReallifeGamemode.Server.Managers
|
namespace ReallifeGamemode.Server.Managers
|
||||||
{
|
{
|
||||||
public class TimeManager
|
public class TimeManager
|
||||||
|
{
|
||||||
|
private static Timer realTimeTimer;
|
||||||
|
|
||||||
|
public static void StartTimeManager()
|
||||||
{
|
{
|
||||||
private static Timer realTimeTimer;
|
if (realTimeTimer == null)
|
||||||
|
{
|
||||||
|
realTimeTimer = new Timer(1000);
|
||||||
|
realTimeTimer.Elapsed += SetTime;
|
||||||
|
}
|
||||||
|
|
||||||
public static void StartTimeManager()
|
realTimeTimer.Start();
|
||||||
{
|
|
||||||
if (realTimeTimer == null)
|
|
||||||
{
|
|
||||||
realTimeTimer = new Timer(1000);
|
|
||||||
realTimeTimer.Elapsed += SetTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
realTimeTimer.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void PauseTimeManager()
|
|
||||||
{
|
|
||||||
realTimeTimer.Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void SetTime(object sender, ElapsedEventArgs args)
|
|
||||||
{
|
|
||||||
DateTime now = DateTime.Now;
|
|
||||||
NAPI.World.SetTime(now.Hour, now.Minute, now.Second);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void PauseTimeManager()
|
||||||
|
{
|
||||||
|
realTimeTimer.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetTime(object sender, ElapsedEventArgs args)
|
||||||
|
{
|
||||||
|
DateTime now = DateTime.Now;
|
||||||
|
NAPI.World.SetTime(now.Hour, now.Minute, now.Second);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -3,21 +3,21 @@
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class VehicleDistanceDriven : Migration
|
public partial class VehicleDistanceDriven : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<float>(
|
||||||
{
|
name: "DistanceDriven",
|
||||||
migrationBuilder.AddColumn<float>(
|
table: "ServerVehicles",
|
||||||
name: "DistanceDriven",
|
nullable: false,
|
||||||
table: "ServerVehicles",
|
defaultValue: 0f);
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "DistanceDriven",
|
|
||||||
table: "ServerVehicles");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "DistanceDriven",
|
||||||
|
table: "ServerVehicles");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,21 @@
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class VehicleTank : Migration
|
public partial class VehicleTank : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<float>(
|
||||||
{
|
name: "TankAmount",
|
||||||
migrationBuilder.AddColumn<float>(
|
table: "ServerVehicles",
|
||||||
name: "TankAmount",
|
nullable: false,
|
||||||
table: "ServerVehicles",
|
defaultValue: 0f);
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "TankAmount",
|
|
||||||
table: "ServerVehicles");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "TankAmount",
|
||||||
|
table: "ServerVehicles");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,32 +4,32 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class ATM : Migration
|
public partial class ATM : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.CreateTable(
|
||||||
{
|
name: "ATMs",
|
||||||
migrationBuilder.CreateTable(
|
columns: table => new
|
||||||
name: "ATMs",
|
{
|
||||||
columns: table => new
|
Id = table.Column<int>(nullable: false)
|
||||||
{
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
Id = table.Column<int>(nullable: false)
|
Balance = table.Column<int>(nullable: false),
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
X = table.Column<float>(nullable: false),
|
||||||
Balance = table.Column<int>(nullable: false),
|
Y = table.Column<float>(nullable: false),
|
||||||
X = table.Column<float>(nullable: false),
|
Z = table.Column<float>(nullable: false),
|
||||||
Y = table.Column<float>(nullable: false),
|
Faulty = table.Column<bool>(nullable: false),
|
||||||
Z = table.Column<float>(nullable: false),
|
Active = table.Column<bool>(nullable: false)
|
||||||
Faulty = table.Column<bool>(nullable: false),
|
},
|
||||||
Active = table.Column<bool>(nullable: false)
|
constraints: table =>
|
||||||
},
|
{
|
||||||
constraints: table =>
|
table.PrimaryKey("PK_ATMs", x => x.Id);
|
||||||
{
|
});
|
||||||
table.PrimaryKey("PK_ATMs", x => x.Id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ATMs");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ATMs");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,21 @@
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class Handmoney : Migration
|
public partial class Handmoney : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<int>(
|
||||||
{
|
name: "Handmoney",
|
||||||
migrationBuilder.AddColumn<int>(
|
table: "Users",
|
||||||
name: "Handmoney",
|
nullable: false,
|
||||||
table: "Users",
|
defaultValue: 0);
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Handmoney",
|
|
||||||
table: "Users");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Handmoney",
|
||||||
|
table: "Users");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,29 +4,29 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class TuningGarage : Migration
|
public partial class TuningGarage : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.CreateTable(
|
||||||
{
|
name: "TuningGarages",
|
||||||
migrationBuilder.CreateTable(
|
columns: table => new
|
||||||
name: "TuningGarages",
|
{
|
||||||
columns: table => new
|
Id = table.Column<int>(nullable: false)
|
||||||
{
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
Id = table.Column<int>(nullable: false)
|
X = table.Column<float>(nullable: false),
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
Y = table.Column<float>(nullable: false),
|
||||||
X = table.Column<float>(nullable: false),
|
Z = table.Column<float>(nullable: false)
|
||||||
Y = table.Column<float>(nullable: false),
|
},
|
||||||
Z = table.Column<float>(nullable: false)
|
constraints: table =>
|
||||||
},
|
{
|
||||||
constraints: table =>
|
table.PrimaryKey("PK_TuningGarages", x => x.Id);
|
||||||
{
|
});
|
||||||
table.PrimaryKey("PK_TuningGarages", x => x.Id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "TuningGarages");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "TuningGarages");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,125 +4,125 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class Groups : Migration
|
public partial class Groups : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<int>(
|
||||||
{
|
name: "GroupId",
|
||||||
migrationBuilder.AddColumn<int>(
|
table: "Users",
|
||||||
name: "GroupId",
|
nullable: true);
|
||||||
table: "Users",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
migrationBuilder.AddColumn<int>(
|
||||||
name: "GroupRank",
|
name: "GroupRank",
|
||||||
table: "Users",
|
table: "Users",
|
||||||
nullable: false,
|
nullable: false,
|
||||||
defaultValue: 0);
|
defaultValue: 0);
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
migrationBuilder.AddColumn<int>(
|
||||||
name: "GroupId",
|
name: "GroupId",
|
||||||
table: "ServerVehicles",
|
table: "ServerVehicles",
|
||||||
nullable: true);
|
nullable: true);
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Groups",
|
name: "Groups",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<int>(nullable: false)
|
Id = table.Column<int>(nullable: false)
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
Name = table.Column<string>(nullable: true)
|
Name = table.Column<string>(nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_Groups", x => x.Id);
|
table.PrimaryKey("PK_Groups", x => x.Id);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "GroupBankAccounts",
|
name: "GroupBankAccounts",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<int>(nullable: false)
|
Id = table.Column<int>(nullable: false)
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
GroupId = table.Column<int>(nullable: true),
|
GroupId = table.Column<int>(nullable: true),
|
||||||
Balance = table.Column<int>(nullable: false)
|
Balance = table.Column<int>(nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_GroupBankAccounts", x => x.Id);
|
table.PrimaryKey("PK_GroupBankAccounts", x => x.Id);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_GroupBankAccounts_Groups_GroupId",
|
name: "FK_GroupBankAccounts_Groups_GroupId",
|
||||||
column: x => x.GroupId,
|
column: x => x.GroupId,
|
||||||
principalTable: "Groups",
|
principalTable: "Groups",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Users_GroupId",
|
name: "IX_Users_GroupId",
|
||||||
table: "Users",
|
table: "Users",
|
||||||
column: "GroupId");
|
column: "GroupId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_ServerVehicles_GroupId",
|
name: "IX_ServerVehicles_GroupId",
|
||||||
table: "ServerVehicles",
|
table: "ServerVehicles",
|
||||||
column: "GroupId");
|
column: "GroupId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_GroupBankAccounts_GroupId",
|
name: "IX_GroupBankAccounts_GroupId",
|
||||||
table: "GroupBankAccounts",
|
table: "GroupBankAccounts",
|
||||||
column: "GroupId");
|
column: "GroupId");
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
migrationBuilder.AddForeignKey(
|
||||||
name: "FK_ServerVehicles_Groups_GroupId",
|
name: "FK_ServerVehicles_Groups_GroupId",
|
||||||
table: "ServerVehicles",
|
table: "ServerVehicles",
|
||||||
column: "GroupId",
|
column: "GroupId",
|
||||||
principalTable: "Groups",
|
principalTable: "Groups",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
migrationBuilder.AddForeignKey(
|
||||||
name: "FK_Users_Groups_GroupId",
|
name: "FK_Users_Groups_GroupId",
|
||||||
table: "Users",
|
table: "Users",
|
||||||
column: "GroupId",
|
column: "GroupId",
|
||||||
principalTable: "Groups",
|
principalTable: "Groups",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_ServerVehicles_Groups_GroupId",
|
|
||||||
table: "ServerVehicles");
|
|
||||||
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_Users_Groups_GroupId",
|
|
||||||
table: "Users");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "GroupBankAccounts");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Groups");
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_Users_GroupId",
|
|
||||||
table: "Users");
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_ServerVehicles_GroupId",
|
|
||||||
table: "ServerVehicles");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "GroupId",
|
|
||||||
table: "Users");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "GroupRank",
|
|
||||||
table: "Users");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "GroupId",
|
|
||||||
table: "ServerVehicles");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_ServerVehicles_Groups_GroupId",
|
||||||
|
table: "ServerVehicles");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Users_Groups_GroupId",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "GroupBankAccounts");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Groups");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Users_GroupId",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_ServerVehicles_GroupId",
|
||||||
|
table: "ServerVehicles");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "GroupId",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "GroupRank",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "GroupId",
|
||||||
|
table: "ServerVehicles");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,20 @@
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class UnusedColumnRemove : Migration
|
public partial class UnusedColumnRemove : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.DropColumn(
|
||||||
{
|
name: "ShopId",
|
||||||
migrationBuilder.DropColumn(
|
table: "ServerVehicles");
|
||||||
name: "ShopId",
|
|
||||||
table: "ServerVehicles");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "ShopId",
|
|
||||||
table: "ServerVehicles",
|
|
||||||
nullable: true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "ShopId",
|
||||||
|
table: "ServerVehicles",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,87 +4,87 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class Jobs : Migration
|
public partial class Jobs : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<int>(
|
||||||
{
|
name: "JobId",
|
||||||
migrationBuilder.AddColumn<int>(
|
table: "Users",
|
||||||
name: "JobId",
|
nullable: true);
|
||||||
table: "Users",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
migrationBuilder.AddColumn<int>(
|
||||||
name: "JobId",
|
name: "JobId",
|
||||||
table: "ServerVehicles",
|
table: "ServerVehicles",
|
||||||
nullable: true);
|
nullable: true);
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Jobs",
|
name: "Jobs",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<int>(nullable: false)
|
Id = table.Column<int>(nullable: false)
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
Name = table.Column<string>(nullable: true)
|
Name = table.Column<string>(nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_Jobs", x => x.Id);
|
table.PrimaryKey("PK_Jobs", x => x.Id);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Users_JobId",
|
name: "IX_Users_JobId",
|
||||||
table: "Users",
|
table: "Users",
|
||||||
column: "JobId");
|
column: "JobId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_ServerVehicles_JobId",
|
name: "IX_ServerVehicles_JobId",
|
||||||
table: "ServerVehicles",
|
table: "ServerVehicles",
|
||||||
column: "JobId");
|
column: "JobId");
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
migrationBuilder.AddForeignKey(
|
||||||
name: "FK_ServerVehicles_Jobs_JobId",
|
name: "FK_ServerVehicles_Jobs_JobId",
|
||||||
table: "ServerVehicles",
|
table: "ServerVehicles",
|
||||||
column: "JobId",
|
column: "JobId",
|
||||||
principalTable: "Jobs",
|
principalTable: "Jobs",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
migrationBuilder.AddForeignKey(
|
||||||
name: "FK_Users_Jobs_JobId",
|
name: "FK_Users_Jobs_JobId",
|
||||||
table: "Users",
|
table: "Users",
|
||||||
column: "JobId",
|
column: "JobId",
|
||||||
principalTable: "Jobs",
|
principalTable: "Jobs",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_ServerVehicles_Jobs_JobId",
|
|
||||||
table: "ServerVehicles");
|
|
||||||
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_Users_Jobs_JobId",
|
|
||||||
table: "Users");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Jobs");
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_Users_JobId",
|
|
||||||
table: "Users");
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_ServerVehicles_JobId",
|
|
||||||
table: "ServerVehicles");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "JobId",
|
|
||||||
table: "Users");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "JobId",
|
|
||||||
table: "ServerVehicles");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_ServerVehicles_Jobs_JobId",
|
||||||
|
table: "ServerVehicles");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Users_Jobs_JobId",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Jobs");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Users_JobId",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_ServerVehicles_JobId",
|
||||||
|
table: "ServerVehicles");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "JobId",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "JobId",
|
||||||
|
table: "ServerVehicles");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,69 +4,69 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class JobFix : Migration
|
public partial class JobFix : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.DropForeignKey(
|
||||||
{
|
name: "FK_ServerVehicles_Jobs_JobId",
|
||||||
migrationBuilder.DropForeignKey(
|
table: "ServerVehicles");
|
||||||
name: "FK_ServerVehicles_Jobs_JobId",
|
|
||||||
table: "ServerVehicles");
|
|
||||||
|
|
||||||
migrationBuilder.DropForeignKey(
|
migrationBuilder.DropForeignKey(
|
||||||
name: "FK_Users_Jobs_JobId",
|
name: "FK_Users_Jobs_JobId",
|
||||||
table: "Users");
|
table: "Users");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Jobs");
|
name: "Jobs");
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
migrationBuilder.DropIndex(
|
||||||
name: "IX_Users_JobId",
|
name: "IX_Users_JobId",
|
||||||
table: "Users");
|
table: "Users");
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
migrationBuilder.DropIndex(
|
||||||
name: "IX_ServerVehicles_JobId",
|
name: "IX_ServerVehicles_JobId",
|
||||||
table: "ServerVehicles");
|
table: "ServerVehicles");
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Jobs",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(nullable: false)
|
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
||||||
Name = table.Column<string>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Jobs", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Users_JobId",
|
|
||||||
table: "Users",
|
|
||||||
column: "JobId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_ServerVehicles_JobId",
|
|
||||||
table: "ServerVehicles",
|
|
||||||
column: "JobId");
|
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
|
||||||
name: "FK_ServerVehicles_Jobs_JobId",
|
|
||||||
table: "ServerVehicles",
|
|
||||||
column: "JobId",
|
|
||||||
principalTable: "Jobs",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
|
||||||
name: "FK_Users_Jobs_JobId",
|
|
||||||
table: "Users",
|
|
||||||
column: "JobId",
|
|
||||||
principalTable: "Jobs",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Jobs",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
Name = table.Column<string>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Jobs", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Users_JobId",
|
||||||
|
table: "Users",
|
||||||
|
column: "JobId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ServerVehicles_JobId",
|
||||||
|
table: "ServerVehicles",
|
||||||
|
column: "JobId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ServerVehicles_Jobs_JobId",
|
||||||
|
table: "ServerVehicles",
|
||||||
|
column: "JobId",
|
||||||
|
principalTable: "Jobs",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Users_Jobs_JobId",
|
||||||
|
table: "Users",
|
||||||
|
column: "JobId",
|
||||||
|
principalTable: "Jobs",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,21 @@
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class ClothesTexture : Migration
|
public partial class ClothesTexture : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<int>(
|
||||||
{
|
name: "Texture",
|
||||||
migrationBuilder.AddColumn<int>(
|
table: "CharacterClothes",
|
||||||
name: "Texture",
|
nullable: false,
|
||||||
table: "CharacterClothes",
|
defaultValue: 0);
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Texture",
|
|
||||||
table: "CharacterClothes");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Texture",
|
||||||
|
table: "CharacterClothes");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,21 @@
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class PlayerWanteds : Migration
|
public partial class PlayerWanteds : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<int>(
|
||||||
{
|
name: "Wanteds",
|
||||||
migrationBuilder.AddColumn<int>(
|
table: "Users",
|
||||||
name: "Wanteds",
|
nullable: false,
|
||||||
table: "Users",
|
defaultValue: 0);
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Wanteds",
|
|
||||||
table: "Users");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Wanteds",
|
||||||
|
table: "Users");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,50 +4,50 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class House : Migration
|
public partial class House : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<int>(
|
||||||
{
|
name: "HouseId",
|
||||||
migrationBuilder.AddColumn<int>(
|
table: "Users",
|
||||||
name: "HouseId",
|
nullable: true);
|
||||||
table: "Users",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Houses",
|
name: "Houses",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<int>(nullable: false)
|
Id = table.Column<int>(nullable: false)
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
Type = table.Column<string>(nullable: true),
|
Type = table.Column<string>(nullable: true),
|
||||||
Price = table.Column<int>(nullable: false),
|
Price = table.Column<int>(nullable: false),
|
||||||
UserId = table.Column<int>(nullable: true)
|
UserId = table.Column<int>(nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_Houses", x => x.Id);
|
table.PrimaryKey("PK_Houses", x => x.Id);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_Houses_Users_UserId",
|
name: "FK_Houses_Users_UserId",
|
||||||
column: x => x.UserId,
|
column: x => x.UserId,
|
||||||
principalTable: "Users",
|
principalTable: "Users",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Houses_UserId",
|
name: "IX_Houses_UserId",
|
||||||
table: "Houses",
|
table: "Houses",
|
||||||
column: "UserId",
|
column: "UserId",
|
||||||
unique: true);
|
unique: true);
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Houses");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "HouseId",
|
|
||||||
table: "Users");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Houses");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "HouseId",
|
||||||
|
table: "Users");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,41 +3,41 @@
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class HousePosition : Migration
|
public partial class HousePosition : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<float>(
|
||||||
{
|
name: "X",
|
||||||
migrationBuilder.AddColumn<float>(
|
table: "Houses",
|
||||||
name: "X",
|
nullable: false,
|
||||||
table: "Houses",
|
defaultValue: 0f);
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0f);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<float>(
|
migrationBuilder.AddColumn<float>(
|
||||||
name: "Y",
|
name: "Y",
|
||||||
table: "Houses",
|
table: "Houses",
|
||||||
nullable: false,
|
nullable: false,
|
||||||
defaultValue: 0f);
|
defaultValue: 0f);
|
||||||
|
|
||||||
migrationBuilder.AddColumn<float>(
|
migrationBuilder.AddColumn<float>(
|
||||||
name: "Z",
|
name: "Z",
|
||||||
table: "Houses",
|
table: "Houses",
|
||||||
nullable: false,
|
nullable: false,
|
||||||
defaultValue: 0f);
|
defaultValue: 0f);
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "X",
|
|
||||||
table: "Houses");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Y",
|
|
||||||
table: "Houses");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Z",
|
|
||||||
table: "Houses");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "X",
|
||||||
|
table: "Houses");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Y",
|
||||||
|
table: "Houses");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Z",
|
||||||
|
table: "Houses");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,25 +3,25 @@
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class UserHouseReference : Migration
|
public partial class UserHouseReference : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddForeignKey(
|
||||||
{
|
name: "FK_Users_Houses_HouseId",
|
||||||
migrationBuilder.AddForeignKey(
|
table: "Users",
|
||||||
name: "FK_Users_Houses_HouseId",
|
column: "HouseId",
|
||||||
table: "Users",
|
principalTable: "Houses",
|
||||||
column: "HouseId",
|
principalColumn: "Id",
|
||||||
principalTable: "Houses",
|
onDelete: ReferentialAction.Restrict);
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Houses_UserId",
|
|
||||||
table: "Houses",
|
|
||||||
column: "UserId",
|
|
||||||
unique: true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Houses_UserId",
|
||||||
|
table: "Houses",
|
||||||
|
column: "UserId",
|
||||||
|
unique: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,21 @@
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class UserWage : Migration
|
public partial class UserWage : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<int>(
|
||||||
{
|
name: "Wage",
|
||||||
migrationBuilder.AddColumn<int>(
|
table: "Users",
|
||||||
name: "Wage",
|
nullable: false,
|
||||||
table: "Users",
|
defaultValue: 0);
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Wage",
|
|
||||||
table: "Users");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Wage",
|
||||||
|
table: "Users");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,58 +4,58 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class BusRoutes : Migration
|
public partial class BusRoutes : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.CreateTable(
|
||||||
{
|
name: "BusRoutes",
|
||||||
migrationBuilder.CreateTable(
|
columns: table => new
|
||||||
name: "BusRoutes",
|
{
|
||||||
columns: table => new
|
Id = table.Column<int>(nullable: false)
|
||||||
{
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
Id = table.Column<int>(nullable: false)
|
Description = table.Column<string>(nullable: true)
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
},
|
||||||
Description = table.Column<string>(nullable: true)
|
constraints: table =>
|
||||||
},
|
{
|
||||||
constraints: table =>
|
table.PrimaryKey("PK_BusRoutes", x => x.Id);
|
||||||
{
|
});
|
||||||
table.PrimaryKey("PK_BusRoutes", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "BusRoutesPoints",
|
name: "BusRoutesPoints",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<int>(nullable: false)
|
Id = table.Column<int>(nullable: false)
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
Description = table.Column<string>(nullable: true),
|
Description = table.Column<string>(nullable: true),
|
||||||
X = table.Column<float>(nullable: false),
|
X = table.Column<float>(nullable: false),
|
||||||
Y = table.Column<float>(nullable: false),
|
Y = table.Column<float>(nullable: false),
|
||||||
Z = table.Column<float>(nullable: false),
|
Z = table.Column<float>(nullable: false),
|
||||||
BusRouteId = table.Column<int>(nullable: true)
|
BusRouteId = table.Column<int>(nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_BusRoutesPoints", x => x.Id);
|
table.PrimaryKey("PK_BusRoutesPoints", x => x.Id);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_BusRoutesPoints_BusRoutes_BusRouteId",
|
name: "FK_BusRoutesPoints_BusRoutes_BusRouteId",
|
||||||
column: x => x.BusRouteId,
|
column: x => x.BusRouteId,
|
||||||
principalTable: "BusRoutes",
|
principalTable: "BusRoutes",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_BusRoutesPoints_BusRouteId",
|
name: "IX_BusRoutesPoints_BusRouteId",
|
||||||
table: "BusRoutesPoints",
|
table: "BusRoutesPoints",
|
||||||
column: "BusRouteId");
|
column: "BusRouteId");
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "BusRoutesPoints");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "BusRoutes");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "BusRoutesPoints");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "BusRoutes");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,41 +3,41 @@
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class UserHouseReferenceFix : Migration
|
public partial class UserHouseReferenceFix : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<int>(
|
||||||
{
|
name: "OwnerId",
|
||||||
migrationBuilder.AddColumn<int>(
|
table: "Houses",
|
||||||
name: "OwnerId",
|
nullable: true);
|
||||||
table: "Houses",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Houses_OwnerId",
|
name: "IX_Houses_OwnerId",
|
||||||
table: "Houses",
|
table: "Houses",
|
||||||
column: "OwnerId");
|
column: "OwnerId");
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
migrationBuilder.AddForeignKey(
|
||||||
name: "FK_Houses_Users_OwnerId",
|
name: "FK_Houses_Users_OwnerId",
|
||||||
table: "Houses",
|
table: "Houses",
|
||||||
column: "OwnerId",
|
column: "OwnerId",
|
||||||
principalTable: "Users",
|
principalTable: "Users",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_Houses_Users_OwnerId",
|
|
||||||
table: "Houses");
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_Houses_OwnerId",
|
|
||||||
table: "Houses");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "OwnerId",
|
|
||||||
table: "Houses");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Houses_Users_OwnerId",
|
||||||
|
table: "Houses");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Houses_OwnerId",
|
||||||
|
table: "Houses");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "OwnerId",
|
||||||
|
table: "Houses");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,21 @@
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class JailTime : Migration
|
public partial class JailTime : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<int>(
|
||||||
{
|
name: "JailTime",
|
||||||
migrationBuilder.AddColumn<int>(
|
table: "Users",
|
||||||
name: "JailTime",
|
nullable: false,
|
||||||
table: "Users",
|
defaultValue: 0);
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "JailTime",
|
|
||||||
table: "Users");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "JailTime",
|
||||||
|
table: "Users");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,21 @@
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class PaydayTimer : Migration
|
public partial class PaydayTimer : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<int>(
|
||||||
{
|
name: "PaydayTimer",
|
||||||
migrationBuilder.AddColumn<int>(
|
table: "Users",
|
||||||
name: "PaydayTimer",
|
nullable: false,
|
||||||
table: "Users",
|
defaultValue: 0);
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "PaydayTimer",
|
|
||||||
table: "Users");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PaydayTimer",
|
||||||
|
table: "Users");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,41 +4,41 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class FactionWeapons : Migration
|
public partial class FactionWeapons : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.CreateTable(
|
||||||
{
|
name: "FactionWeapons",
|
||||||
migrationBuilder.CreateTable(
|
columns: table => new
|
||||||
name: "FactionWeapons",
|
{
|
||||||
columns: table => new
|
Id = table.Column<int>(nullable: false)
|
||||||
{
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
Id = table.Column<int>(nullable: false)
|
FactionId = table.Column<int>(nullable: false),
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
WeaponModel = table.Column<string>(nullable: true),
|
||||||
FactionId = table.Column<int>(nullable: false),
|
SlotID = table.Column<int>(nullable: false),
|
||||||
WeaponModel = table.Column<string>(nullable: true),
|
Rank = table.Column<int>(nullable: false)
|
||||||
SlotID = table.Column<int>(nullable: false),
|
},
|
||||||
Rank = table.Column<int>(nullable: false)
|
constraints: table =>
|
||||||
},
|
{
|
||||||
constraints: table =>
|
table.PrimaryKey("PK_FactionWeapons", x => x.Id);
|
||||||
{
|
table.ForeignKey(
|
||||||
table.PrimaryKey("PK_FactionWeapons", x => x.Id);
|
name: "FK_FactionWeapons_Factions_FactionId",
|
||||||
table.ForeignKey(
|
column: x => x.FactionId,
|
||||||
name: "FK_FactionWeapons_Factions_FactionId",
|
principalTable: "Factions",
|
||||||
column: x => x.FactionId,
|
principalColumn: "Id",
|
||||||
principalTable: "Factions",
|
onDelete: ReferentialAction.Cascade);
|
||||||
principalColumn: "Id",
|
});
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_FactionWeapons_FactionId",
|
name: "IX_FactionWeapons_FactionId",
|
||||||
table: "FactionWeapons",
|
table: "FactionWeapons",
|
||||||
column: "FactionId");
|
column: "FactionId");
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "FactionWeapons");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "FactionWeapons");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,21 @@
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class VehicleLivery : Migration
|
public partial class VehicleLivery : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<int>(
|
||||||
{
|
name: "Livery",
|
||||||
migrationBuilder.AddColumn<int>(
|
table: "ServerVehicles",
|
||||||
name: "Livery",
|
nullable: false,
|
||||||
table: "ServerVehicles",
|
defaultValue: 0);
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Livery",
|
|
||||||
table: "ServerVehicles");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Livery",
|
||||||
|
table: "ServerVehicles");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,70 +4,70 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class HouseEnhancments : Migration
|
public partial class HouseEnhancments : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.AddColumn<bool>(
|
||||||
{
|
name: "CanRentIn",
|
||||||
migrationBuilder.AddColumn<bool>(
|
table: "Houses",
|
||||||
name: "CanRentIn",
|
nullable: false,
|
||||||
table: "Houses",
|
defaultValue: false);
|
||||||
nullable: false,
|
|
||||||
defaultValue: false);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
migrationBuilder.AddColumn<int>(
|
||||||
name: "RentalFee",
|
name: "RentalFee",
|
||||||
table: "Houses",
|
table: "Houses",
|
||||||
nullable: false,
|
nullable: false,
|
||||||
defaultValue: 0);
|
defaultValue: 0);
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "HouseRentals",
|
name: "HouseRentals",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<int>(nullable: false)
|
Id = table.Column<int>(nullable: false)
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
HouseId = table.Column<int>(nullable: true),
|
HouseId = table.Column<int>(nullable: true),
|
||||||
UserId = table.Column<int>(nullable: true)
|
UserId = table.Column<int>(nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_HouseRentals", x => x.Id);
|
table.PrimaryKey("PK_HouseRentals", x => x.Id);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_HouseRentals_Houses_HouseId",
|
name: "FK_HouseRentals_Houses_HouseId",
|
||||||
column: x => x.HouseId,
|
column: x => x.HouseId,
|
||||||
principalTable: "Houses",
|
principalTable: "Houses",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_HouseRentals_Users_UserId",
|
name: "FK_HouseRentals_Users_UserId",
|
||||||
column: x => x.UserId,
|
column: x => x.UserId,
|
||||||
principalTable: "Users",
|
principalTable: "Users",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_HouseRentals_HouseId",
|
name: "IX_HouseRentals_HouseId",
|
||||||
table: "HouseRentals",
|
table: "HouseRentals",
|
||||||
column: "HouseId");
|
column: "HouseId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_HouseRentals_UserId",
|
name: "IX_HouseRentals_UserId",
|
||||||
table: "HouseRentals",
|
table: "HouseRentals",
|
||||||
column: "UserId");
|
column: "UserId");
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "HouseRentals");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "CanRentIn",
|
|
||||||
table: "Houses");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "RentalFee",
|
|
||||||
table: "Houses");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "HouseRentals");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "CanRentIn",
|
||||||
|
table: "Houses");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "RentalFee",
|
||||||
|
table: "Houses");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,41 +4,41 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class VehicleItems : Migration
|
public partial class VehicleItems : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.CreateTable(
|
||||||
{
|
name: "VehicleItems",
|
||||||
migrationBuilder.CreateTable(
|
columns: table => new
|
||||||
name: "VehicleItems",
|
{
|
||||||
columns: table => new
|
Id = table.Column<int>(nullable: false)
|
||||||
{
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
Id = table.Column<int>(nullable: false)
|
ItemId = table.Column<int>(nullable: false),
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
VehicleId = table.Column<int>(nullable: false),
|
||||||
ItemId = table.Column<int>(nullable: false),
|
Amount = table.Column<int>(nullable: false),
|
||||||
VehicleId = table.Column<int>(nullable: false),
|
Slot = table.Column<int>(nullable: false)
|
||||||
Amount = table.Column<int>(nullable: false),
|
},
|
||||||
Slot = table.Column<int>(nullable: false)
|
constraints: table =>
|
||||||
},
|
{
|
||||||
constraints: table =>
|
table.PrimaryKey("PK_VehicleItems", x => x.Id);
|
||||||
{
|
table.ForeignKey(
|
||||||
table.PrimaryKey("PK_VehicleItems", x => x.Id);
|
name: "FK_VehicleItems_ServerVehicles_VehicleId",
|
||||||
table.ForeignKey(
|
column: x => x.VehicleId,
|
||||||
name: "FK_VehicleItems_ServerVehicles_VehicleId",
|
principalTable: "ServerVehicles",
|
||||||
column: x => x.VehicleId,
|
principalColumn: "Id",
|
||||||
principalTable: "ServerVehicles",
|
onDelete: ReferentialAction.Cascade);
|
||||||
principalColumn: "Id",
|
});
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_VehicleItems_VehicleId",
|
name: "IX_VehicleItems_VehicleId",
|
||||||
table: "VehicleItems",
|
table: "VehicleItems",
|
||||||
column: "VehicleId");
|
column: "VehicleId");
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "VehicleItems");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "VehicleItems");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,28 +4,28 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class BusinessData : Migration
|
public partial class BusinessData : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
migrationBuilder.CreateTable(
|
||||||
{
|
name: "BusinessData",
|
||||||
migrationBuilder.CreateTable(
|
columns: table => new
|
||||||
name: "BusinessData",
|
{
|
||||||
columns: table => new
|
Id = table.Column<int>(nullable: false)
|
||||||
{
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
Id = table.Column<int>(nullable: false)
|
BusinessId = table.Column<int>(nullable: false),
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
Price = table.Column<int>(nullable: false)
|
||||||
BusinessId = table.Column<int>(nullable: false),
|
},
|
||||||
Price = table.Column<int>(nullable: false)
|
constraints: table =>
|
||||||
},
|
{
|
||||||
constraints: table =>
|
table.PrimaryKey("PK_BusinessData", x => x.Id);
|
||||||
{
|
});
|
||||||
table.PrimaryKey("PK_BusinessData", x => x.Id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "BusinessData");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "BusinessData");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,35 +10,35 @@ using ReallifeGamemode.Server.Extensions;
|
|||||||
namespace ReallifeGamemode.Server.Shop.Clothing
|
namespace ReallifeGamemode.Server.Shop.Clothing
|
||||||
{
|
{
|
||||||
public class ClotheShop
|
public class ClotheShop
|
||||||
|
{
|
||||||
|
public int category { get; set; }
|
||||||
|
public Vector3 vector { get; set; }
|
||||||
|
public List<ShopClothe> clotheList = new List<ShopClothe>();
|
||||||
|
|
||||||
|
public ClotheShop(int category, Vector3 vector)
|
||||||
{
|
{
|
||||||
public int category { get; set; }
|
this.category = category;
|
||||||
public Vector3 vector { get; set; }
|
this.vector = vector;
|
||||||
public List<ShopClothe> clotheList = new List<ShopClothe>();
|
LoadClothes();
|
||||||
|
}
|
||||||
|
|
||||||
public ClotheShop(int category, Vector3 vector)
|
public void LoadClothes()
|
||||||
{
|
{
|
||||||
this.category = category;
|
using (var dbContext = new DatabaseContext())
|
||||||
this.vector = vector;
|
{
|
||||||
LoadClothes();
|
clotheList = dbContext.ShopClothes.ToList().FindAll(c => c.Category == category);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void LoadClothes()
|
public void LoadShopNUI(Player client)
|
||||||
{
|
{
|
||||||
using (var dbContext = new DatabaseContext())
|
bool gender = client.GetUser().GetCharacter().Gender;
|
||||||
{
|
List<ShopClothe> tops = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 11);
|
||||||
clotheList = dbContext.ShopClothes.ToList().FindAll(c => c.Category == category);
|
List<ShopClothe> legs = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 4);
|
||||||
}
|
List<ShopClothe> shoes = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 6);
|
||||||
}
|
List<ShopClothe> accessoires = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 7);
|
||||||
|
|
||||||
public void LoadShopNUI(Player client)
|
List<Array> clothes = new List<Array>
|
||||||
{
|
|
||||||
bool gender = client.GetUser().GetCharacter().Gender;
|
|
||||||
List<ShopClothe> tops = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 11);
|
|
||||||
List<ShopClothe> legs = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 4);
|
|
||||||
List<ShopClothe> shoes = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 6);
|
|
||||||
List<ShopClothe> accessoires = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 7);
|
|
||||||
|
|
||||||
List<Array> clothes = new List<Array>
|
|
||||||
{
|
{
|
||||||
tops.ToArray(),
|
tops.ToArray(),
|
||||||
legs.ToArray(),
|
legs.ToArray(),
|
||||||
@@ -46,7 +46,7 @@ namespace ReallifeGamemode.Server.Shop.Clothing
|
|||||||
accessoires.ToArray()
|
accessoires.ToArray()
|
||||||
};
|
};
|
||||||
|
|
||||||
client.TriggerEvent("clothesMenu:updateData", JsonConvert.SerializeObject(category), JsonConvert.SerializeObject(clothes.ToArray()), gender);
|
client.TriggerEvent("clothesMenu:updateData", JsonConvert.SerializeObject(category), JsonConvert.SerializeObject(clothes.ToArray()), gender);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,34 +10,34 @@ using ReallifeGamemode.Server.Managers;
|
|||||||
namespace ReallifeGamemode.Server.Shop.SevenEleven
|
namespace ReallifeGamemode.Server.Shop.SevenEleven
|
||||||
{
|
{
|
||||||
public class ItemShop
|
public class ItemShop
|
||||||
|
{
|
||||||
|
public Vector3 vector3;
|
||||||
|
public int id;
|
||||||
|
public List<ShopItem> shopItems = new List<ShopItem>();
|
||||||
|
|
||||||
|
public ItemShop(Vector3 vector3, int id)
|
||||||
{
|
{
|
||||||
public Vector3 vector3;
|
this.vector3 = vector3;
|
||||||
public int id;
|
this.id = id;
|
||||||
public List<ShopItem> shopItems = new List<ShopItem>();
|
|
||||||
|
|
||||||
public ItemShop(Vector3 vector3, int id)
|
|
||||||
{
|
|
||||||
this.vector3 = vector3;
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadItems()
|
|
||||||
{
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
shopItems = dbContext.ShopItems.ToList().FindAll(i => i.ShopId == id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadShopNUI(Player client)
|
|
||||||
{
|
|
||||||
List<ShopItem> itemList = shopItems.ToList().FindAll(s => s.Amount > 0);
|
|
||||||
List<IItem> items = new List<IItem>();
|
|
||||||
foreach (var item in itemList)
|
|
||||||
{
|
|
||||||
items.Add(InventoryManager.GetItemById(item.ItemId));
|
|
||||||
}
|
|
||||||
client.TriggerEvent("itemMenu:updateData", JsonConvert.SerializeObject(items.ToArray()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LoadItems()
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
shopItems = dbContext.ShopItems.ToList().FindAll(i => i.ShopId == id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadShopNUI(Player client)
|
||||||
|
{
|
||||||
|
List<ShopItem> itemList = shopItems.ToList().FindAll(s => s.Amount > 0);
|
||||||
|
List<IItem> items = new List<IItem>();
|
||||||
|
foreach (var item in itemList)
|
||||||
|
{
|
||||||
|
items.Add(InventoryManager.GetItemById(item.ItemId));
|
||||||
|
}
|
||||||
|
client.TriggerEvent("itemMenu:updateData", JsonConvert.SerializeObject(items.ToArray()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,104 +5,104 @@ using GTANetworkAPI;
|
|||||||
namespace ReallifeGamemode.Server.Util
|
namespace ReallifeGamemode.Server.Util
|
||||||
{
|
{
|
||||||
public class CheckPointHandle : Script
|
public class CheckPointHandle : Script
|
||||||
|
{
|
||||||
|
public static List<CheckPointListForPlayer> listHandle = new List<CheckPointListForPlayer>();
|
||||||
|
|
||||||
|
public static void DeleteCheckpoints(Player player)
|
||||||
{
|
{
|
||||||
public static List<CheckPointListForPlayer> listHandle = new List<CheckPointListForPlayer>();
|
RemovePlayerHandlerFromList(player);
|
||||||
|
player.TriggerEvent("destroyCP");
|
||||||
public static void DeleteCheckpoints(Player player)
|
|
||||||
{
|
|
||||||
RemovePlayerHandlerFromList(player);
|
|
||||||
player.TriggerEvent("destroyCP");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void StartCheckPointRoute(Player player, IEnumerable<Vector3> nListCps, int delay, int markerID, int markerSize, string nEvent)
|
|
||||||
{
|
|
||||||
RemovePlayerHandlerFromList(player);
|
|
||||||
CheckPointListForPlayer playerHandle = new CheckPointListForPlayer(player, nListCps, delay, markerID, markerSize, nEvent);
|
|
||||||
playerHandle.DeleteCheckpoints();
|
|
||||||
|
|
||||||
listHandle.Add(playerHandle);
|
|
||||||
|
|
||||||
playerHandle.StartRoute();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void RemovePlayerHandlerFromList(Player player)
|
|
||||||
{
|
|
||||||
CheckPointListForPlayer temp = null;
|
|
||||||
for (int a = 0; a < listHandle.Count; a++)
|
|
||||||
{
|
|
||||||
temp = listHandle[a];
|
|
||||||
if (temp.player == player)
|
|
||||||
{
|
|
||||||
listHandle.Remove(temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("playerInCheckpoint")]
|
|
||||||
public void PlayerInCheckpoint(Player user)
|
|
||||||
{
|
|
||||||
CheckPointListForPlayer temp = null;
|
|
||||||
for (int a = 0; a < listHandle.Count; a++)
|
|
||||||
{
|
|
||||||
temp = listHandle[a];
|
|
||||||
if (temp.player == user)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
temp.NextCheckpoint();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CheckPointListForPlayer
|
public static void StartCheckPointRoute(Player player, IEnumerable<Vector3> nListCps, int delay, int markerID, int markerSize, string nEvent)
|
||||||
{
|
{
|
||||||
public IEnumerable<Vector3> list = new List<Vector3>();
|
RemovePlayerHandlerFromList(player);
|
||||||
public Player player;
|
CheckPointListForPlayer playerHandle = new CheckPointListForPlayer(player, nListCps, delay, markerID, markerSize, nEvent);
|
||||||
public int delay = 0;
|
playerHandle.DeleteCheckpoints();
|
||||||
public int markerID;
|
|
||||||
public int markerSize;
|
listHandle.Add(playerHandle);
|
||||||
public string eventInCheckpoint = "";
|
|
||||||
|
playerHandle.StartRoute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RemovePlayerHandlerFromList(Player player)
|
||||||
|
{
|
||||||
|
CheckPointListForPlayer temp = null;
|
||||||
|
for (int a = 0; a < listHandle.Count; a++)
|
||||||
|
{
|
||||||
|
temp = listHandle[a];
|
||||||
|
if (temp.player == player)
|
||||||
|
{
|
||||||
|
listHandle.Remove(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("playerInCheckpoint")]
|
||||||
|
public void PlayerInCheckpoint(Player user)
|
||||||
|
{
|
||||||
|
CheckPointListForPlayer temp = null;
|
||||||
|
for (int a = 0; a < listHandle.Count; a++)
|
||||||
|
{
|
||||||
|
temp = listHandle[a];
|
||||||
|
if (temp.player == user)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
temp.NextCheckpoint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CheckPointListForPlayer
|
||||||
|
{
|
||||||
|
public IEnumerable<Vector3> list = new List<Vector3>();
|
||||||
|
public Player player;
|
||||||
|
public int delay = 0;
|
||||||
|
public int markerID;
|
||||||
|
public int markerSize;
|
||||||
|
public string eventInCheckpoint = "";
|
||||||
|
|
||||||
private int checkPointsDone = 0;
|
private int checkPointsDone = 0;
|
||||||
|
|
||||||
public CheckPointListForPlayer(Player nPlayer, IEnumerable<Vector3> nList, int nDelay, int nMarkerID, int nMarkerSize, string nEvent)
|
public CheckPointListForPlayer(Player nPlayer, IEnumerable<Vector3> nList, int nDelay, int nMarkerID, int nMarkerSize, string nEvent)
|
||||||
{
|
{
|
||||||
this.player = nPlayer;
|
this.player = nPlayer;
|
||||||
this.list = nList;
|
this.list = nList;
|
||||||
this.delay = nDelay;
|
this.delay = nDelay;
|
||||||
this.markerID = nMarkerID;
|
this.markerID = nMarkerID;
|
||||||
this.markerSize = nMarkerSize;
|
this.markerSize = nMarkerSize;
|
||||||
this.eventInCheckpoint = nEvent;
|
this.eventInCheckpoint = nEvent;
|
||||||
this.checkPointsDone = 0;
|
this.checkPointsDone = 0;
|
||||||
}
|
|
||||||
|
|
||||||
public void StartRoute()
|
|
||||||
{
|
|
||||||
player.TriggerEvent("setCheckPoint", this.list.ElementAt(0), player, 0, this.delay, this.markerID, this.markerSize, this.eventInCheckpoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void NextCheckpoint()
|
|
||||||
{
|
|
||||||
this.checkPointsDone++;
|
|
||||||
if (this.list.Count() > checkPointsDone)
|
|
||||||
{
|
|
||||||
Vector3 nextCp = list.ElementAt(checkPointsDone);
|
|
||||||
this.player.TriggerEvent("setCheckPoint", nextCp, player, this.checkPointsDone, delay, this.markerID, this.markerSize, this.eventInCheckpoint);
|
|
||||||
}
|
|
||||||
if (this.list.Count() == checkPointsDone)
|
|
||||||
{
|
|
||||||
CheckPointHandle.RemovePlayerHandlerFromList(this.player);
|
|
||||||
|
|
||||||
if (this.eventInCheckpoint == "busDriverJob")
|
|
||||||
{
|
|
||||||
Job.BusDriverJob.payWage(this.player, 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteCheckpoints()
|
|
||||||
{
|
|
||||||
this.player.TriggerEvent("destroyCP");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void StartRoute()
|
||||||
|
{
|
||||||
|
player.TriggerEvent("setCheckPoint", this.list.ElementAt(0), player, 0, this.delay, this.markerID, this.markerSize, this.eventInCheckpoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void NextCheckpoint()
|
||||||
|
{
|
||||||
|
this.checkPointsDone++;
|
||||||
|
if (this.list.Count() > checkPointsDone)
|
||||||
|
{
|
||||||
|
Vector3 nextCp = list.ElementAt(checkPointsDone);
|
||||||
|
this.player.TriggerEvent("setCheckPoint", nextCp, player, this.checkPointsDone, delay, this.markerID, this.markerSize, this.eventInCheckpoint);
|
||||||
|
}
|
||||||
|
if (this.list.Count() == checkPointsDone)
|
||||||
|
{
|
||||||
|
CheckPointHandle.RemovePlayerHandlerFromList(this.player);
|
||||||
|
|
||||||
|
if (this.eventInCheckpoint == "busDriverJob")
|
||||||
|
{
|
||||||
|
Job.BusDriverJob.payWage(this.player, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteCheckpoints()
|
||||||
|
{
|
||||||
|
this.player.TriggerEvent("destroyCP");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,34 +4,34 @@ using GTANetworkAPI;
|
|||||||
namespace ReallifeGamemode.Server.Util
|
namespace ReallifeGamemode.Server.Util
|
||||||
{
|
{
|
||||||
public class Converter
|
public class Converter
|
||||||
|
{
|
||||||
|
public static Color HexToColor(string hexColor)
|
||||||
{
|
{
|
||||||
public static Color HexToColor(string hexColor)
|
//Remove # if present
|
||||||
{
|
if (hexColor.IndexOf('#') != -1)
|
||||||
//Remove # if present
|
hexColor = hexColor.Replace("#", "");
|
||||||
if (hexColor.IndexOf('#') != -1)
|
|
||||||
hexColor = hexColor.Replace("#", "");
|
|
||||||
|
|
||||||
int red = 0;
|
int red = 0;
|
||||||
int green = 0;
|
int green = 0;
|
||||||
int blue = 0;
|
int blue = 0;
|
||||||
|
|
||||||
if (hexColor.Length == 6)
|
if (hexColor.Length == 6)
|
||||||
{
|
{
|
||||||
//#RRGGBB
|
//#RRGGBB
|
||||||
red = int.Parse(hexColor.Substring(0, 2), NumberStyles.AllowHexSpecifier);
|
red = int.Parse(hexColor.Substring(0, 2), NumberStyles.AllowHexSpecifier);
|
||||||
green = int.Parse(hexColor.Substring(2, 2), NumberStyles.AllowHexSpecifier);
|
green = int.Parse(hexColor.Substring(2, 2), NumberStyles.AllowHexSpecifier);
|
||||||
blue = int.Parse(hexColor.Substring(4, 2), NumberStyles.AllowHexSpecifier);
|
blue = int.Parse(hexColor.Substring(4, 2), NumberStyles.AllowHexSpecifier);
|
||||||
}
|
}
|
||||||
else if (hexColor.Length == 3)
|
else if (hexColor.Length == 3)
|
||||||
{
|
{
|
||||||
//#RGB
|
//#RGB
|
||||||
red = int.Parse(hexColor[0].ToString() + hexColor[0].ToString(), NumberStyles.AllowHexSpecifier);
|
red = int.Parse(hexColor[0].ToString() + hexColor[0].ToString(), NumberStyles.AllowHexSpecifier);
|
||||||
green = int.Parse(hexColor[1].ToString() + hexColor[1].ToString(), NumberStyles.AllowHexSpecifier);
|
green = int.Parse(hexColor[1].ToString() + hexColor[1].ToString(), NumberStyles.AllowHexSpecifier);
|
||||||
blue = int.Parse(hexColor[2].ToString() + hexColor[2].ToString(), NumberStyles.AllowHexSpecifier);
|
blue = int.Parse(hexColor[2].ToString() + hexColor[2].ToString(), NumberStyles.AllowHexSpecifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color returnColor = new Color(red, green, blue);
|
Color returnColor = new Color(red, green, blue);
|
||||||
return returnColor;
|
return returnColor;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,16 +4,16 @@ using GTANetworkAPI;
|
|||||||
namespace ReallifeGamemode.Server.Util
|
namespace ReallifeGamemode.Server.Util
|
||||||
{
|
{
|
||||||
public static class GlobalHelper
|
public static class GlobalHelper
|
||||||
{
|
{
|
||||||
public static List<Player> DutyAdmins = new List<Player>();
|
public static List<Player> DutyAdmins = new List<Player>();
|
||||||
public static List<Player> tsupAdmins = new List<Player>();
|
public static List<Player> tsupAdmins = new List<Player>();
|
||||||
|
|
||||||
public static Dictionary<string, string> CustomJoinMessages = new Dictionary<string, string>
|
public static Dictionary<string, string> CustomJoinMessages = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{ ".MichaPlays.", "Der Echte Ballas Leader ist online (MichaPlays)" },
|
{ ".MichaPlays.", "Der Echte Ballas Leader ist online (MichaPlays)" },
|
||||||
{ "balboistderbeste", "Hurra! Hurra! Der Balbo ist jetzt da! (balbo)" },
|
{ "balboistderbeste", "Hurra! Hurra! Der Balbo ist jetzt da! (balbo)" },
|
||||||
{ "Roachkook", "Niemand, nicht einmal deine Mutter möchte so etwas sehen. (Siga)" },
|
{ "Roachkook", "Niemand, nicht einmal deine Mutter möchte so etwas sehen. (Siga)" },
|
||||||
{ "Paaqo1337", "Picasso is back! (Paaqo)" }
|
{ "Paaqo1337", "Picasso is back! (Paaqo)" }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
namespace ReallifeGamemode.Server.Util
|
namespace ReallifeGamemode.Server.Util
|
||||||
{
|
{
|
||||||
public class IndicatorData
|
public class IndicatorData
|
||||||
{
|
{
|
||||||
public bool Left { get; set; } = false;
|
public bool Left { get; set; } = false;
|
||||||
public bool Right { get; set; } = false;
|
public bool Right { get; set; } = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,38 +3,38 @@
|
|||||||
namespace ReallifeGamemode.Server.Util
|
namespace ReallifeGamemode.Server.Util
|
||||||
{
|
{
|
||||||
public class SmoothThrottleAntiReverse : Script
|
public class SmoothThrottleAntiReverse : Script
|
||||||
|
{
|
||||||
|
[ServerEvent(Event.PlayerExitVehicle)]
|
||||||
|
public void SmoothThrottleExitEvent(Player player, Vehicle veh)
|
||||||
{
|
{
|
||||||
[ServerEvent(Event.PlayerExitVehicle)]
|
NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_PlayerExitVehicle", veh);
|
||||||
public void SmoothThrottleExitEvent(Player player, Vehicle veh)
|
|
||||||
{
|
|
||||||
NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_PlayerExitVehicle", veh);
|
|
||||||
}
|
|
||||||
|
|
||||||
[ServerEvent(Event.PlayerEnterVehicle)]
|
|
||||||
public void SmoothThrottleEnterEvent(Player player, Vehicle veh, sbyte seat)
|
|
||||||
{
|
|
||||||
NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_PlayerEnterVehicle", veh, seat);
|
|
||||||
}
|
|
||||||
|
|
||||||
//You can call these to change settings on player if you want.
|
|
||||||
//Note that these are toggles, you only need to call them once.
|
|
||||||
|
|
||||||
//This disables/enables the smooth throttle
|
|
||||||
public static void SetSmoothThrottle(Player player, bool turnedOn)
|
|
||||||
{
|
|
||||||
NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_SetSmoothThrottle", turnedOn);
|
|
||||||
}
|
|
||||||
|
|
||||||
//This disables/enables anti reverse
|
|
||||||
public static void SetAntiReverse(Player player, bool turnedOn)
|
|
||||||
{
|
|
||||||
NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_SetAntiReverse", turnedOn);
|
|
||||||
}
|
|
||||||
|
|
||||||
//This disables/enables both
|
|
||||||
public static void SetSmoothThrottleAntiReverse(Player player, bool turnedOn)
|
|
||||||
{
|
|
||||||
NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_SetGlobal", turnedOn);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ServerEvent(Event.PlayerEnterVehicle)]
|
||||||
|
public void SmoothThrottleEnterEvent(Player player, Vehicle veh, sbyte seat)
|
||||||
|
{
|
||||||
|
NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_PlayerEnterVehicle", veh, seat);
|
||||||
|
}
|
||||||
|
|
||||||
|
//You can call these to change settings on player if you want.
|
||||||
|
//Note that these are toggles, you only need to call them once.
|
||||||
|
|
||||||
|
//This disables/enables the smooth throttle
|
||||||
|
public static void SetSmoothThrottle(Player player, bool turnedOn)
|
||||||
|
{
|
||||||
|
NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_SetSmoothThrottle", turnedOn);
|
||||||
|
}
|
||||||
|
|
||||||
|
//This disables/enables anti reverse
|
||||||
|
public static void SetAntiReverse(Player player, bool turnedOn)
|
||||||
|
{
|
||||||
|
NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_SetAntiReverse", turnedOn);
|
||||||
|
}
|
||||||
|
|
||||||
|
//This disables/enables both
|
||||||
|
public static void SetSmoothThrottleAntiReverse(Player player, bool turnedOn)
|
||||||
|
{
|
||||||
|
NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_SetGlobal", turnedOn);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
namespace ReallifeGamemode.Server.Util
|
namespace ReallifeGamemode.Server.Util
|
||||||
{
|
{
|
||||||
public class TaxiContract
|
public class TaxiContract
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
public Vector3 Position { get; set; }
|
public Vector3 Position { get; set; }
|
||||||
|
|
||||||
public Player Driver { get; set; }
|
public Player Driver { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,50 +8,50 @@ using ReallifeGamemode.Server.WeaponDeal;
|
|||||||
namespace ReallifeGamemode.Server.Util
|
namespace ReallifeGamemode.Server.Util
|
||||||
{
|
{
|
||||||
public class ThreadTimers
|
public class ThreadTimers
|
||||||
|
{
|
||||||
|
private static Timer timer500 = new Timer(500); //0.5 seconds timer
|
||||||
|
private static Timer timer2500 = new Timer(2500); //2.5 seconds timer
|
||||||
|
private static Timer timer10000 = new Timer(10000); // 10 second timer
|
||||||
|
private static Timer timer60000 = new Timer(60000); //60 seconds timer
|
||||||
|
|
||||||
|
public static void StartAllTimers()
|
||||||
{
|
{
|
||||||
private static Timer timer500 = new Timer(500); //0.5 seconds timer
|
timer500.Start();
|
||||||
private static Timer timer2500 = new Timer(2500); //2.5 seconds timer
|
timer500.Elapsed += Timer500_Elapsed;
|
||||||
private static Timer timer10000 = new Timer(10000); // 10 second timer
|
|
||||||
private static Timer timer60000 = new Timer(60000); //60 seconds timer
|
|
||||||
|
|
||||||
public static void StartAllTimers()
|
timer2500.Start();
|
||||||
{
|
timer2500.Elapsed += Timer2500_Elapsed;
|
||||||
timer500.Start();
|
|
||||||
timer500.Elapsed += Timer500_Elapsed;
|
|
||||||
|
|
||||||
timer2500.Start();
|
timer10000.Start();
|
||||||
timer2500.Elapsed += Timer2500_Elapsed;
|
timer10000.Elapsed += Timer10000_Elapsed;
|
||||||
|
|
||||||
timer10000.Start();
|
timer60000.Start();
|
||||||
timer10000.Elapsed += Timer10000_Elapsed;
|
timer60000.Elapsed += Timer60000_Elapsed;
|
||||||
|
|
||||||
timer60000.Start();
|
|
||||||
timer60000.Elapsed += Timer60000_Elapsed;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void Timer500_Elapsed(object sender, ElapsedEventArgs e)
|
|
||||||
{
|
|
||||||
TaxiDriverJob.UpdateFare();
|
|
||||||
VehicleManager.VehicleTimerTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void Timer60000_Elapsed(object sender, ElapsedEventArgs e)
|
|
||||||
{
|
|
||||||
Jail.JailOut_Elapsed();
|
|
||||||
Economy.Timer_Elapsed();
|
|
||||||
WeaponDealManager.Timer_Elapsed();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void Timer10000_Elapsed(object sender, ElapsedEventArgs e)
|
|
||||||
{
|
|
||||||
Jail.BrakeOut_Elapsed();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void Timer2500_Elapsed(object sender, ElapsedEventArgs e)
|
|
||||||
{
|
|
||||||
WantedEscapeTimer.Timer_Elapsed();
|
|
||||||
Jail.JailIn_Elapsed();
|
|
||||||
Gangwar.Gangwar.Value_TimerElapsed();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void Timer500_Elapsed(object sender, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
TaxiDriverJob.UpdateFare();
|
||||||
|
VehicleManager.VehicleTimerTick();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Timer60000_Elapsed(object sender, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
Jail.JailOut_Elapsed();
|
||||||
|
Economy.Timer_Elapsed();
|
||||||
|
WeaponDealManager.Timer_Elapsed();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Timer10000_Elapsed(object sender, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
Jail.BrakeOut_Elapsed();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Timer2500_Elapsed(object sender, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
WantedEscapeTimer.Timer_Elapsed();
|
||||||
|
Jail.JailIn_Elapsed();
|
||||||
|
Gangwar.Gangwar.Value_TimerElapsed();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user