Merge branch 'feature/user-backend' into develop
This commit is contained in:
@@ -3,17 +3,10 @@
|
||||
* @author VegaZ, hydrant
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
var loginBrowser;
|
||||
loginBrowser = mp.browsers.new('package://Login/login.html');
|
||||
mp.gui.chat.activate(false);
|
||||
mp.gui.cursor.show(true, true);
|
||||
mp.game.ui.displayHud(false);
|
||||
mp.game.ui.displayRadar(false);
|
||||
|
||||
var loginCam = mp.cameras.new('login', new mp.Vector3(-1883.736, -781.4911, 78.27616), new mp.Vector3(3.185999, 0, -79.59519), 40);
|
||||
loginCam.setActive(true);
|
||||
mp.game.cam.renderScriptCams(true, false, 0, true, false);
|
||||
|
||||
mp.events.callRemote('IsPlayerBanned');
|
||||
|
||||
mp.events.add('loginInformationToServer', (password) => {
|
||||
|
||||
@@ -73,6 +66,22 @@ mp.events.add('registerFail', (reason) => {
|
||||
showCefError(reason);
|
||||
});
|
||||
|
||||
mp.events.add('showLogin', () => {
|
||||
|
||||
loginBrowser = mp.browsers.new('package://Login/login.html');
|
||||
mp.gui.chat.activate(false);
|
||||
mp.gui.cursor.show(true, true);
|
||||
mp.game.ui.displayHud(false);
|
||||
mp.game.ui.displayRadar(false);
|
||||
|
||||
loginCam.setActive(true);
|
||||
mp.game.cam.renderScriptCams(true, false, 0, true, false);
|
||||
});
|
||||
|
||||
function showCefError(error) {
|
||||
loginBrowser.execute(`showError(\`` + error + `\`)`);
|
||||
}
|
||||
|
||||
//function isPlayerBanned() {
|
||||
|
||||
//}
|
||||
2
Main.cs
2
Main.cs
@@ -25,7 +25,7 @@ namespace reallife_gamemode
|
||||
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
context.Users.FirstOrDefault();
|
||||
context.Bans.FirstOrDefault();
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,18 @@ namespace reallife_gamemode.Model
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
|
||||
//User
|
||||
public DbSet<Server.Entities.User> Users { get; set; }
|
||||
public DbSet<Server.Entities.UserVehicle> UserVehicles { get; set; }
|
||||
public DbSet<Server.Entities.UserBankAccount> BankAccounts { get; set; }
|
||||
public DbSet<Server.Entities.Ban> Bans { get; set; }
|
||||
|
||||
//Logs
|
||||
//public DbSet<Server.Logs.Ban> BanLogs { get; set; }
|
||||
public DbSet<Server.Logs.BankAccountTransactionHistory> BankAccountTransactionLogs { get; set; }
|
||||
public DbSet<Server.Logs.Death> DeathLogs { get; set; }
|
||||
|
||||
//Saves
|
||||
public DbSet<Server.Saves.SavedBlip> Blips { get; set; }
|
||||
public DbSet<Server.Saves.SavedMarker> Markers { get; set; }
|
||||
public DbSet<Server.Saves.SavedPed> Peds { get; set; }
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Server.Events;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
using reallife_gamemode.Server.Services;
|
||||
using reallife_gamemode.Server.Util;
|
||||
using reallife_gamemode.Model;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Admin Commands (Admin.cs)
|
||||
@@ -58,7 +62,6 @@ namespace reallife_gamemode.Server.Commands
|
||||
Vehicle v = NAPI.Vehicle.CreateVehicle(hash, player.Position, player.Rotation.Z, color1, color2);
|
||||
|
||||
player.SetIntoVehicle(v.Handle, -1);
|
||||
player.SendChatMessage("Maxspeed: + " +player.Vehicle.MaxSpeed + "");
|
||||
}
|
||||
|
||||
[Command("fv")]
|
||||
@@ -552,7 +555,136 @@ namespace reallife_gamemode.Server.Commands
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[Command("ban", "~m~Benutzung: ~s~/ban [User] [Zeit in Minuten(0 für Permanent)] [Grund] ", GreedyArg = true)]
|
||||
public void CmdAdminBan(Client admin, string user, int mins, string reason)
|
||||
{
|
||||
if (ClientExtension.IsLoggedIn(admin) == false)
|
||||
{
|
||||
ChatService.PlayerNotLoggedIn(admin);
|
||||
return;
|
||||
}
|
||||
if (!admin.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(admin);
|
||||
return;
|
||||
}
|
||||
Client target = ClientService.GetClientByName(user);
|
||||
ClientExtension.BanPlayer(admin, target, reason, mins);
|
||||
}
|
||||
[Command("unban", "~m~Benutzung: ~s~/unban [User] ", GreedyArg = true)]
|
||||
public void CmdAdminUnban(Client admin, string user)
|
||||
{
|
||||
if (ClientExtension.IsLoggedIn(admin) == false)
|
||||
{
|
||||
ChatService.PlayerNotLoggedIn(admin);
|
||||
return;
|
||||
}
|
||||
if (!admin.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(admin);
|
||||
return;
|
||||
}
|
||||
Client target = ClientService.GetClientByName(user);
|
||||
ClientExtension.UnbanPlayer(admin, target);
|
||||
}
|
||||
|
||||
|
||||
//TEST COMMAND
|
||||
[Command("own")]
|
||||
public void CmdAdminOwn(Client player)
|
||||
{
|
||||
if (ClientExtension.IsLoggedIn(player) == false)
|
||||
{
|
||||
ChatService.PlayerNotLoggedIn(player);
|
||||
return;
|
||||
}
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.IsInVehicle)
|
||||
{
|
||||
Vehicle playerVehicle = player.Vehicle;
|
||||
using (var saveVehicle = new Model.DatabaseContext())
|
||||
{
|
||||
var dataSet = new Entities.UserVehicle
|
||||
{
|
||||
UserId = player.GetUser().Id,
|
||||
Model = (VehicleHash) playerVehicle.Model,
|
||||
PositionX = playerVehicle.Position.X,
|
||||
PositionY = playerVehicle.Position.Y,
|
||||
PositionZ = playerVehicle.Position.Z,
|
||||
Heading = playerVehicle.Heading,
|
||||
NumberPlate = playerVehicle.NumberPlate,
|
||||
PrimaryColor = Convert.ToByte(playerVehicle.PrimaryColor),
|
||||
SecondaryColor = Convert.ToByte(playerVehicle.SecondaryColor),
|
||||
Locked = playerVehicle.Locked,
|
||||
Engine = playerVehicle.EngineStatus,
|
||||
Dimension = Convert.ToByte(playerVehicle.Dimension),
|
||||
};
|
||||
saveVehicle.UserVehicles.Add(dataSet);
|
||||
saveVehicle.SaveChanges();
|
||||
}
|
||||
|
||||
}
|
||||
else player.SendChatMessage("~m~Du sitzt in keinem Fahrzeug!");
|
||||
|
||||
}
|
||||
//TEST COMMAND
|
||||
[Command("myvehicles")]
|
||||
public void CmdAdminMyVehicles(Client player)
|
||||
{
|
||||
if (ClientExtension.IsLoggedIn(player) == false)
|
||||
{
|
||||
ChatService.PlayerNotLoggedIn(player);
|
||||
return;
|
||||
}
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
player.SendChatMessage("Deine Fahrzeuge: ");
|
||||
using (var loadData = new DatabaseContext())
|
||||
{
|
||||
foreach (Entities.UserVehicle v in loadData.UserVehicles)
|
||||
{
|
||||
if (v.UserId == ClientExtension.GetUser(player).Id)
|
||||
{
|
||||
player.SendChatMessage("~b~" + NAPI.Vehicle.GetVehicleDisplayName(v.Model));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
[Command("restart")]
|
||||
public void CmdAdminRestart(Client player)
|
||||
{
|
||||
if (ClientExtension.IsLoggedIn(player) == false)
|
||||
{
|
||||
ChatService.PlayerNotLoggedIn(player);
|
||||
return;
|
||||
}
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
var users = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
foreach(Client user in users)
|
||||
{
|
||||
user.SendChatMessage("~r~Server startet neu.~s~ Bitte verbinde dich über ~y~F1~s~ neu.");
|
||||
user.Kick();
|
||||
}
|
||||
|
||||
NAPI.Resource.StopResource("reallife-gamemode");
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
32
Server/Entities/Ban.cs
Normal file
32
Server/Entities/Ban.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Entities Ban (Ban.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Entities
|
||||
{
|
||||
public class Ban
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
|
||||
public string Reason { get; set; }
|
||||
public string BannedBy { get; set; }
|
||||
|
||||
public int Applied { get; set; }
|
||||
public int UntilDateTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using reallife_gamemode.Server.Util;
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
@@ -27,10 +28,18 @@ namespace reallife_gamemode.Server.Entities
|
||||
public int LogUserId { get; set; }
|
||||
[Timestamp]
|
||||
public byte[] RegistrationDate { get; set; }
|
||||
|
||||
[EmailAddress]
|
||||
[StringLength(64)]
|
||||
public string Email { get; set; }
|
||||
public AdminLevel AdminLevel { get; set; }
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
public float PositionZ { get; set; }
|
||||
|
||||
[ForeignKey("Ban")]
|
||||
public int? BanId { get; set; }
|
||||
public Ban Ban { get; set; }
|
||||
|
||||
public bool IsAdmin(AdminLevel level) => AdminLevel >= level;
|
||||
}
|
||||
|
||||
32
Server/Entities/UserBankAccount.cs
Normal file
32
Server/Entities/UserBankAccount.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Entities UserBankAccount (UserBankAccount.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Entities
|
||||
{
|
||||
public class UserBankAccount
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
[StringLength(12)]
|
||||
public string Bic { get; set; }
|
||||
[StringLength(32)]
|
||||
public string Iban { get; set; }
|
||||
public float Balance { get; set; }
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
}
|
||||
40
Server/Entities/UserVehicle.cs
Normal file
40
Server/Entities/UserVehicle.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Entities UserVehicle (UserVehicle.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Entities
|
||||
{
|
||||
public class UserVehicle
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
|
||||
public VehicleHash Model { get; set; }
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
public float PositionZ { get; set; }
|
||||
public float Heading { get; set; }
|
||||
[StringLength(8)]
|
||||
public string NumberPlate { get; set; }
|
||||
public byte Alpha { get; set; }
|
||||
public byte PrimaryColor { get; set; }
|
||||
public byte SecondaryColor { get; set; }
|
||||
public bool Locked { get; set; }
|
||||
public bool Engine { get; set; }
|
||||
public byte Dimension { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,36 @@ namespace reallife_gamemode.Server.Events
|
||||
player.Position = new Vector3(-1883.736, -781.4911, -10);
|
||||
player.FreezePosition = true;
|
||||
}
|
||||
[RemoteEvent("IsPlayerBanned")]
|
||||
public void IsPlayerBanned(Client player)
|
||||
{
|
||||
using (var loginUser = new Model.DatabaseContext())
|
||||
{
|
||||
var user = loginUser.Users.SingleOrDefault(b => b.Name == player.Name);
|
||||
if (user.BanId != null)
|
||||
{
|
||||
using (var banUser = new DatabaseContext())
|
||||
{
|
||||
|
||||
var dt = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
var bannedUser = banUser.Bans.SingleOrDefault(u => u.Id == user.BanId);
|
||||
if (bannedUser.Applied == bannedUser.UntilDateTime)
|
||||
{
|
||||
player.SendChatMessage("!{#FF4040}Du wurdest permanent gebannt! [" + bannedUser.Reason + "]");
|
||||
//player.Kick();
|
||||
}
|
||||
else
|
||||
{
|
||||
var timeStamp = bannedUser.UntilDateTime;
|
||||
player.SendChatMessage("Du bist noch bis zum !{#FF4040}" + dt.AddSeconds(timeStamp).ToLocalTime() + " Uhr ~s~gebannt. [" + bannedUser.Reason + "]");
|
||||
//player.Kick();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else player.TriggerEvent("showLogin");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkMethods;
|
||||
using reallife_gamemode.Model;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
|
||||
/*
|
||||
* Author: balbo
|
||||
@@ -18,7 +19,38 @@ namespace reallife_gamemode.Server.Events
|
||||
[ServerEvent(Event.PlayerDeath)]
|
||||
public void OnPlayerDeath(Client player, Client killer, uint reason)
|
||||
{
|
||||
//TODO: Zum Full Release entfernen
|
||||
NAPI.Chat.SendChatMessageToPlayer(player, "Du bist durch " + killer.Name + " gestorben: " + reason.ToString());
|
||||
|
||||
int? killerId;
|
||||
float killerPosX;
|
||||
float killerPosY;
|
||||
float killerPosZ;
|
||||
float killerHeading;
|
||||
|
||||
if (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;
|
||||
}
|
||||
|
||||
using (var userDeath = new DatabaseContext())
|
||||
{
|
||||
var dead = new 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
|
||||
@@ -11,13 +12,34 @@ using GTANetworkAPI;
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
class Disconnect : Script
|
||||
public class Disconnect : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerDisconnected)]
|
||||
public void OnPlayerDisconnected(Client player)
|
||||
public void OnPlayerDisconnected(Client player, DisconnectionType type, string reason)
|
||||
{
|
||||
if (type == DisconnectionType.Left)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " left");
|
||||
}
|
||||
if (type == DisconnectionType.Kicked)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " kicked");
|
||||
}
|
||||
if (type == DisconnectionType.Timeout)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " Timeoutet");
|
||||
}
|
||||
/*
|
||||
using (var saveUser = new Model.DatabaseContext())
|
||||
{
|
||||
var user = saveUser.Users.SingleOrDefault(u => u.Name == player.Name);
|
||||
|
||||
user.PositionX = player.Position.X;
|
||||
user.PositionY = player.Position.Y;
|
||||
user.PositionZ = player.Position.Z;
|
||||
saveUser.SaveChanges();
|
||||
}*/
|
||||
player.SetData("isLoggedIn", false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Model;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||
@@ -44,6 +46,7 @@ namespace reallife_gamemode.Server.Events
|
||||
|
||||
player.SetData("isLoggedIn", true);
|
||||
player.TriggerEvent("draw");
|
||||
player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace reallife_gamemode.Server.Events
|
||||
}
|
||||
player.TriggerEvent("registerSuccess");
|
||||
NAPI.Player.SpawnPlayer(player, Main.DEFAULT_SPAWN_POSITION, Main.DEFAULT_SPAWN_HEADING);
|
||||
player.SetData("isLoggedIn", true);
|
||||
}
|
||||
else if (player.SocialClubName == checkedUser.SocialClubName)
|
||||
{
|
||||
|
||||
38
Server/Events/ResourceStop.cs
Normal file
38
Server/Events/ResourceStop.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkMethods;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event ResourceStop (ResourceStop.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
public class ResourceStop : Script
|
||||
{
|
||||
[ServerEvent(Event.ResourceStop)]
|
||||
public void OnResourceStop()
|
||||
{
|
||||
var users = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
foreach(Client user in users)
|
||||
{
|
||||
using (var saveUsers = new Model.DatabaseContext())
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ namespace reallife_gamemode.Server.Extensions
|
||||
{
|
||||
public static User GetUser(this Client client)
|
||||
{
|
||||
using(DatabaseContext dbContext = new DatabaseContext())
|
||||
using (DatabaseContext dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Users.FirstOrDefault(u => u.Name == client.Name);
|
||||
}
|
||||
@@ -28,5 +28,45 @@ namespace reallife_gamemode.Server.Extensions
|
||||
{
|
||||
return player.GetData("isLoggedIn");
|
||||
}
|
||||
|
||||
public static void BanPlayer(Client admin, Client target, string reason, int mins)
|
||||
{
|
||||
using (var banUser = new DatabaseContext())
|
||||
{
|
||||
int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||
Ban user;
|
||||
if (mins == 0)
|
||||
{
|
||||
NAPI.Chat.SendChatMessageToAll("!{#FF4040}[BAN] " + target.Name + " wurde von " + admin.Name + " permanent gebannt. [" + reason + "]");
|
||||
user = new Ban { UserId = GetUser(target).Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp };
|
||||
//TODO user.Kick();
|
||||
mins--;
|
||||
}
|
||||
else
|
||||
{
|
||||
NAPI.Chat.SendChatMessageToAll("!{#FF4040}[BAN] " + target.Name + " wurde von " + admin.Name + " für " + mins + " Minuten gebannt. [" + reason + "]");
|
||||
user = new Ban { UserId = GetUser(target).Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp + mins * 60 };
|
||||
//TODO user.Kick();
|
||||
}
|
||||
|
||||
banUser.Bans.Add(user);
|
||||
banUser.SaveChanges();
|
||||
|
||||
var targetUser = banUser.Users.FirstOrDefault(u => u.Name == target.Name);
|
||||
targetUser.BanId = user.Id;
|
||||
banUser.SaveChanges();
|
||||
}
|
||||
}
|
||||
public static void UnbanPlayer(Client admin, Client target)
|
||||
{
|
||||
using (var unbanUser = new DatabaseContext())
|
||||
{
|
||||
var targetUser = unbanUser.Bans.FirstOrDefault(u => u.Id == target.GetUser().BanId);
|
||||
unbanUser.Bans.Remove(targetUser);
|
||||
unbanUser.SaveChanges();
|
||||
}
|
||||
admin.SendChatMessage(target.Name + " wurde entbannt.");
|
||||
//TODO ***Admin Info: {ADMIN-NAME} hat {USER-NAME} entbannt.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
34
Server/Logs/BankAccountTransactionHistory.cs
Normal file
34
Server/Logs/BankAccountTransactionHistory.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Logs BankAccountTransactionHistory (BankAccountTransactionHistory.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Logs
|
||||
{
|
||||
public class BankAccountTransactionHistory
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[StringLength(32)]
|
||||
public string Sender { get; set; }
|
||||
public float SenderBalance { get; set; }
|
||||
public float MoneySent { get; set; }
|
||||
[StringLength(32)]
|
||||
public string Receiver { get; set; }
|
||||
public float ReceiverBalance { get; set; }
|
||||
public float NewSenderBalance { get; set; }
|
||||
public float NewReceiverBalance { get; set; }
|
||||
public float Fee { get; set; }
|
||||
[Timestamp]
|
||||
public byte[] Timestamp { get; set; }
|
||||
}
|
||||
}
|
||||
45
Server/Logs/Death.cs
Normal file
45
Server/Logs/Death.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Logs Death (Death.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Logs
|
||||
{
|
||||
public class Death
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[ForeignKey("Victim")]
|
||||
public int VictimId { get; set; }
|
||||
public User Victim { get; set; }
|
||||
|
||||
[ForeignKey("Killer")]
|
||||
public int? KillerId { get; set; }
|
||||
public User Killer { get; set; }
|
||||
|
||||
public float VictimPositionX { get; set; }
|
||||
public float VictimPositionY { get; set; }
|
||||
public float VictimPositionZ { get; set; }
|
||||
public float VictimHeading { get; set; }
|
||||
|
||||
public float KillerPositionX { get; set; }
|
||||
public float KillerPositionY { get; set; }
|
||||
public float KillerPositionZ { get; set; }
|
||||
public float KillerHeading { get; set; }
|
||||
|
||||
[StringLength(64)]
|
||||
public string CauseOfDeath { get; set; }
|
||||
[Timestamp]
|
||||
public byte[] Timestamp { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ namespace reallife_gamemode.Server.Managers
|
||||
{
|
||||
if (v.Active == true)
|
||||
{
|
||||
NAPI.Vehicle.CreateVehicle((uint)v.Model, new Vector3(v.PositionX, v.PositionY, v.PositionZ), v.Heading, (int)(v.PrimaryColor),
|
||||
NAPI.Vehicle.CreateVehicle((uint)v.Model, new Vector3(v.PositionX, v.PositionY, v.PositionZ), v.Heading, (v.PrimaryColor),
|
||||
v.SecondaryColor, v.NumberPlate, v.Alpha, v.Locked, v.Engine = false, v.Dimension);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user