Add DbContext, Models
This commit is contained in:
40
Model/DatabaseContext.cs
Normal file
40
Model/DatabaseContext.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* @overview Life of German Reallife - DatabaseContext.cs
|
||||||
|
* @author VegaZ
|
||||||
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Model
|
||||||
|
{
|
||||||
|
public partial class DatabaseContext : DbContext
|
||||||
|
{
|
||||||
|
public DatabaseContext(DbContextOptions<DatabaseContext> options) :base (options)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public DatabaseContext()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
optionsBuilder.UseMySql("Host=localhost;Port=3306;Database=gtav-devdb;Username=gtav-dev;Password=Test123");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
base.OnModelCreating(modelBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DbSet<Server.Entities.User> Users { get; set; }
|
||||||
|
public DbSet<Server.Entities.Character> Characters { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Model/Efmigrationshistory.cs
Normal file
11
Model/Efmigrationshistory.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Model
|
||||||
|
{
|
||||||
|
public partial class Efmigrationshistory
|
||||||
|
{
|
||||||
|
public string MigrationId { get; set; }
|
||||||
|
public string ProductVersion { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
5
Model/appsettings.json
Normal file
5
Model/appsettings.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"gtavDatabase": "Host=localhost;Port=3306;Database=gtav-devdb;Username=gtav-dev;Password=JZi(k0HpKZ9MSDc9Ifrvh>qm>WbMTC!MQ]uAG08PN!fzG1elmDAJqU8VC<6c{eOsEChzxy8Yn<6W{MIG;"
|
||||||
|
}
|
||||||
|
}
|
||||||
16
Server/Commands/Admin.cs
Normal file
16
Server/Commands/Admin.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using GTANetworkAPI;
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Command
|
||||||
|
{
|
||||||
|
public class Admin : Script
|
||||||
|
{
|
||||||
|
[Command("o")]
|
||||||
|
public void sendOChat(Client player, string message)
|
||||||
|
{
|
||||||
|
NAPI.Chat.SendChatMessageToAll("~r~" + player.Name + " sagt:~w~ " + message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
Server/Entities/Character.cs
Normal file
16
Server/Entities/Character.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Entities
|
||||||
|
{
|
||||||
|
public class Character
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int UserId { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public byte Gender { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
26
Server/Entities/User.cs
Normal file
26
Server/Entities/User.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Entities
|
||||||
|
{
|
||||||
|
public class User
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
[StringLength(32)]
|
||||||
|
public string Name { get; set; }
|
||||||
|
[StringLength(32)]
|
||||||
|
public string SocialClubName { get; set; }
|
||||||
|
[StringLength(64)]
|
||||||
|
public string Password { get; set; }
|
||||||
|
public int LogUserId { get; set; }
|
||||||
|
public DateTime RegistrationDate { get; set; }
|
||||||
|
[EmailAddress]
|
||||||
|
[StringLength(64)]
|
||||||
|
public string Email { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
20
Server/Events/Spawn.cs
Normal file
20
Server/Events/Spawn.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using GTANetworkAPI;
|
||||||
|
using GTANetworkMethods;
|
||||||
|
using reallife_gamemode.Model;
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Event
|
||||||
|
{
|
||||||
|
public class Spawn : Script
|
||||||
|
{
|
||||||
|
|
||||||
|
[ServerEvent(GTANetworkAPI.Event.PlayerSpawn)]
|
||||||
|
public void OnPlayerSpawn(Client player)
|
||||||
|
{
|
||||||
|
NAPI.Chat.SendChatMessageToPlayer(player, "~b~Du wurdest gespawnt.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user