Changed login design, moved all db entities to Entities folder

This commit is contained in:
hydrant
2019-03-07 15:55:08 +01:00
parent be82292ab7
commit 04ed4bc322
24 changed files with 466 additions and 349 deletions

View File

@@ -6,81 +6,58 @@
var loginBrowser; var loginBrowser;
var loginCam = mp.cameras.new('login', new mp.Vector3(-1883.736, -781.4911, 78.27616), new mp.Vector3(3.185999, 0, -79.59519), 40); var loginCam = mp.cameras.new('login', new mp.Vector3(-1883.736, -781.4911, 78.27616), new mp.Vector3(3.185999, 0, -79.59519), 40);
mp.events.callRemote('IsPlayerBanned'); var localPlayer = mp.players.local;
mp.events.add('loginInformationToServer', (password) => { mp.events.add('SERVER:Login_ShowBrowser', _ => {
mp.events.callRemote('OnPlayerLogin', password);
});
mp.events.add('registerInformationToServer', (password) => {
mp.events.callRemote('OnPlayerRegister', password);
});
mp.events.add('registerSuccess', () => {
if (loginBrowser)
{
loginBrowser.destroy();
}
mp.gui.cursor.show(false, false);
mp.gui.chat.activate(true);
loginCam.setActive(false);
mp.game.cam.renderScriptCams(false, false, 0, true, false);
mp.game.ui.displayRadar(true);
mp.game.ui.displayHud(true);
});
mp.events.add('loginSuccess', () => {
mp.gui.chat.push("Erfolgreich eingeloggt!");
if (loginBrowser)
{
loginBrowser.destroy();
loginBrowser = undefined;
}
mp.gui.cursor.show(false, false);
mp.gui.chat.activate(true);
loginCam.setActive(false);
mp.game.cam.renderScriptCams(false, false, 0, true, false);
mp.game.ui.displayRadar(true);
mp.game.ui.displayHud(true);
});
mp.events.add('loginFail', (reason) => {
showCefError(reason);
});
mp.events.add('loginDeny', (reason) => {
mp.gui.cursor.show(false, false);
mp.gui.chat.activate(true);
showCefError(reason.toString());
});
mp.events.add('registerFail', (reason) => {
showCefError(reason);
});
mp.events.add('showLogin', () => {
loginBrowser = mp.browsers.new('package://assets/html/login/index.html');
mp.gui.chat.activate(false);
mp.gui.cursor.show(true, true); mp.gui.cursor.show(true, true);
mp.gui.chat.show(false);
mp.game.ui.displayHud(false); mp.game.ui.displayHud(false);
mp.game.ui.displayRadar(false); mp.game.ui.displayRadar(false);
loginBrowser = mp.browsers.new("package://assets/html/login/index.html");
loginCam.setActive(true); loginCam.setActive(true);
mp.game.cam.renderScriptCams(true, false, 0, true, false); mp.game.cam.renderScriptCams(true, false, 0, true, false);
}); });
mp.events.add('disableLogin', () => { mp.events.add('SERVER:Login_Error', (error, deactivate = false) => {
if (loginBrowser) {
loginBrowser.execute(`showError("${error}");`);
if (deactivate) {
loginBrowser.destroy();
mp.gui.cursor.show(false, false);
mp.gui.chat.show(true);
mp.game.ui.displayHud(true);
mp.game.ui.displayRadar(true);
}
}
});
mp.events.add('CEF:Login_RequestPlayerName', _ => {
if (loginBrowser) {
loginBrowser.execute(`setPlayerName("${localPlayer.name}");`);
}
});
mp.events.add('CEF:Login_LoginRequest', (username, password) => {
mp.events.callRemote('CLIENT:Login_LoginRequest', username, password);
});
mp.events.add('CEF:Login_RegisterRequest', (username, password, passwordRepeat) => {
mp.events.callRemote('CLIENT:Login_RegisterRequest', username, password, passwordRepeat);
});
mp.events.add('SERVER:Login_Success', _ => {
if (loginBrowser) { if (loginBrowser) {
loginBrowser.destroy(); loginBrowser.destroy();
} }
mp.gui.cursor.show(false, false);
mp.gui.chat.activate(true);
});
function showCefError(error) { mp.gui.cursor.show(false, false);
loginBrowser.execute(`showError('${error}')`); mp.gui.chat.show(true);
} mp.game.ui.displayHud(true);
mp.game.ui.displayRadar(true);
loginCam.setActive(false);
mp.game.cam.renderScriptCams(false, false, 0, true, false);
});

View File

@@ -63,7 +63,7 @@ mp.events.add('render', () =>
var drivenDistance = player.vehicle.getVariable("drivenDistance"); var drivenDistance = player.vehicle.getVariable("drivenDistance");
var drivenDistanceStr = "0"; var drivenDistanceStr = "0";
if (drivenDistance) drivenDistanceStr = parseFloat(drivenDistance).toFixed(3).toString(); if (drivenDistance) drivenDistanceStr = parseFloat(drivenDistance).toFixed(3).toString().replace(".", ",");
mp.game.graphics.drawText(drivenDistanceStr + " KM", [0.48, 0.973], { mp.game.graphics.drawText(drivenDistanceStr + " KM", [0.48, 0.973], {
font: 0, font: 0,
color: [255, 255, 255, 255], color: [255, 255, 255, 255],

File diff suppressed because one or more lines are too long

View File

@@ -1,150 +1,181 @@
/** *, *:before, *:after {
* @overview Life of German Reallife - Login CSS style.css
* @author Orangebox, hydrant
* @copyright (c) 2008 - 2018 Life of German
*/
.login-page {
width: 360px;
margin: auto;
}
.isa_info, .isa_success, .isa_warning, .isa_error {
margin: 10px 0px;
padding: 12px;
display: none;
}
.isa_info {
color: #00529B;
background-color: #BDE5F8;
}
.isa_success {
color: #4F8A10;
background-color: #DFF2BF;
}
.isa_warning {
color: #9F6000;
background-color: #FEEFB3;
}
.isa_error {
color: #D8000C;
background-color: #FFBABA;
}
.isa_info i, .isa_success i, .isa_warning i, .isa_error i {
margin: 10px 22px;
font-size: 2em;
vertical-align: middle;
}
.form {
position: relative;
z-index: 1;
background: rgba(255, 255, 255, .85);
max-width: 360px;
padding: 20px 45px 45px 45px;
text-align: center;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
}
input {
font-family: "Roboto", sans-serif;
outline: 0;
background: #f2f2f2;
width: 100%;
border: 0;
margin: 0 0 15px;
padding: 15px;
box-sizing: border-box; box-sizing: border-box;
font-size: 14px;
}
button {
font-family: "Roboto", sans-serif;
text-transform: uppercase;
outline: 0;
background: #0035A5;
width: 100%;
border: 0;
padding: 15px;
color: #FFFFFF;
font-size: 14px;
-webkit-transition: all 0.3s ease;
transition: all 0.3s ease;
cursor: pointer;
}
button:hover, .form button:active, .form button:focus {
background: #002574;
}
.quitBtn {
background-color: orangered;
}
.quitBtn:hover, .quitBtn:focus, .quitBtn:active {
background-color: #cc3700 !important;
}
.message {
margin: 15px 0 0;
font-size: 12px;
}
.message a {
color: #0035A5;
text-decoration: none;
}
.register-form {
display: none;
}
.container {
position: relative;
z-index: 1;
max-width: 300px;
margin: 0 auto;
}
.container:before, .container:after {
content: "";
display: block;
clear: both;
}
.container .info {
margin: 50px auto;
text-align: center;
}
.info h1 {
margin: 0 0 15px;
padding: 0;
font-size: 36px;
font-weight: 300;
color: #1a1a1a;
}
.info span {
color: #4d4d4d;
font-size: 12px;
}
.info span a {
color: #000000;
text-decoration: none;
}
.info span .fa {
color: #EF3B3A;
} }
body { body {
font-family: "Roboto", sans-serif; font-family: 'Titillium Web', sans-serif;
-webkit-font-smoothing: antialiased; }
a {
text-decoration: none;
color: #1ab188;
transition: 0.5s ease;
}
a:hover {
color: #179b77;
}
.form {
background: rgba(19, 35, 47, .9);
padding: 40px;
max-width: 600px;
margin: 40px auto;
border-radius: 4px;
box-shadow: 0 4px 10px 4px rgba(19, 35, 47, .3);
}
.tab-group {
list-style: none;
padding: 0;
margin: 0 0 40px 0;
}
.tab-group:after {
content: "";
display: table;
clear: both;
}
.tab-group li a {
display: block;
text-decoration: none;
padding: 15px;
background: rgba(160, 179, 176, .25);
color: #a0b3b0;
font-size: 20px;
float: left;
width: 50%;
text-align: center;
cursor: pointer;
transition: 0.5s ease;
}
.tab-group li a:hover {
background: #179b77;
color: #fff;
}
.tab-group .active a {
background: #1ab188;
color: #fff;
}
.tab-content > div:last-child {
display: none;
}
h1 {
text-align: center;
color: #fff;
font-weight: 300;
margin: 0 0 40px;
}
label {
position: absolute;
transform: translateY(6px);
left: 13px;
color: rgba(255, 255, 255, .5);
transition: all 0.25s ease;
-webkit-backface-visibility: hidden;
pointer-events: none;
font-size: 22px;
}
label .req {
margin: 2px;
color: #1ab188;
}
label.active {
transform: translateY(40px);
left: 2px;
font-size: 14px;
}
label.active .req {
opacity: 0;
}
label.highlight {
color: #fff;
}
input, textarea {
font-size: 22px;
display: block;
width: 100%;
padding: 5px 10px;
background: none;
background-image: none;
border: 1px solid #a0b3b0;
color: #fff;
border-radius: 0;
transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
input:focus, textarea:focus {
outline: 0;
border-color: #1ab188;
}
textarea {
border: 2px solid #a0b3b0;
resize: vertical;
}
.field-wrap {
position: relative;
margin-bottom: 40px;
}
.top-row:after {
content: "";
display: table;
clear: both;
}
.top-row > div {
float: left;
width: 48%;
margin-right: 4%;
}
.top-row > div:last-child {
margin: 0;
}
.button {
border: 0;
outline: none;
border-radius: 0;
padding: 15px 0;
font-size: 2rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.1em;
background: #1ab188;
color: #fff;
transition: all 0.5s ease;
-webkit-appearance: none;
}
.button:hover, .button:focus {
background: #179b77;
}
.button-block {
display: block;
width: 100%;
}
.forgot {
margin-top: -20px;
text-align: right;
}
#error-field {
margin-bottom: 40px;
display: none;
} }

View File

@@ -1,51 +1,89 @@
<!-- <html>
* @overview Life of German Reallife - Client Login login.html
* @author Orangebox, hydrant, VegaZ
* @copyright (c) 2008 - 2018 Life of German
*-->
<!DOCTYPE html>
<html>
<head> <head>
<meta charset="UTF-8">
<link rel="stylesheet" href="package://assets/css/login/style.css" /> <link rel="stylesheet" href="package://assets/css/login/style.css" />
<link rel="stylesheet" href="package://assets/css/jquery-ui.min.css" />
<meta charset="utf-8" />
</head> </head>
<body> <body>
<div class="login-page" style="padding: 10% 0 0;"> <div class="form">
<div class="form">
<div class="isa_error"> <ul class="tab-group">
ERROR TEXT <li class="tab active"><a href="#login">Anmelden</a></li>
</div> <li class="tab"><a href="#signup">Registrieren</a></li>
<div class="register-form form-l"> </ul>
<input type="password" placeholder="Passwort" id="passwordInputRegister" />
<input type="password" placeholder="Passwort wiederholen" id="passwordRepeatInputRegister" /> <div class="ui-widget" id="error-field">
<button id="registerBtn" onclick="registerPlayer()";>Registrieren</button><br /><br /> <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;">
<button class="quitBtn">Server verlassen</button> <p>
<p class="message">Bereits registriert? <a href="#">Logg dich ein</a></p> </p>
</div>
<div class="login-form form-l">
<input type="password" placeholder="Passwort" id="passwordInputLogin" />
<button id="loginBtn" onclick="loginPlayer()">Einloggen</button><br /><br />
<button class="quitBtn">Server verlassen</button>
<p class="message">Nicht registriert? <a href="#">Erstelle einen Account</a></p>
</div> </div>
</div> </div>
</div>
<script src="package://assets/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
$(".message a").click(() => {
$(".form-l").animate({ height: "toggle", opacity: "toggle" }, "slow");
});
$(".quitBtn").click(() => { <div class="tab-content">
resourceCall("Quit"); <div id="login">
}); <h1>Wilkommen zurück</h1>
function showError(error) { <form id="form-login">
$(".isa_error").html(error.toString());
$(".isa_error").slideDown(); <div class="field-wrap">
} <label>
</script> Benutzername<span class="req">*</span>
<script src="package://assets/js/login/script.js" type="text/javascript"></script> </label>
<input type="text" id="login-username" class="input-username" required autocomplete="off" />
</div>
<div class="field-wrap">
<label>
Passwort<span class="req">*</span>
</label>
<input type="password" id="login-password" required autocomplete="off" />
</div>
<p class="forgot"><a href="#">Passwort vergessen?</a></p>
<button class="button button-block">Anmelden</button>
</form>
</div>
<div id="signup">
<h1>Kostenlos registrieren</h1>
<form id="form-register">
<div class="field-wrap">
<label>
Benutzername<span class="req">*</span>
</label>
<input type="text" id="register-username" class="input-username" required autocomplete="off" />
</div>
<div class="field-wrap">
<label>
Passwort<span class="req">*</span>
</label>
<input type="password" id="register-password-first" required autocomplete="off" />
</div>
<div class="field-wrap">
<label>
Passwort wiederholen<span class="req">*</span>
</label>
<input type="password" id="register-password-second" required autocomplete="off" />
</div>
<button type="submit" class="button button-block">Registrieren</button>
</form>
</div>
</div><!-- tab-content -->
</div> <!-- /form -->
<script type="text/javascript" src="package://assets/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="package://assets/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="package://assets/js/login/script.js"></script>
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

View File

@@ -1,40 +1,103 @@
/** var playerName = undefined;
* @overview Life of German Reallife - Login Login login.js var errorShown = false;
* @author VegaZ
* @copyright (c) 2008 - 2018 Life of German
*/
function registerPlayer() {
var password = document.getElementById("passwordInputRegister").value; $(document).ready(_ => {
var passwordRepeat = document.getElementById("passwordRepeatInputRegister").value; mp.trigger("CEF:Login_RequestPlayerName");
if(password === "" || passwordRepeat === "") { $('.form').find('input, textarea').on('keyup blur focus', function (e) {
showError("Mindestens ein Passwort Feld ist leer!");
return;
}
if (password !== passwordRepeat) { var $this = $(this),
showError("Die beiden Passwörter stimmen nicht überein!"); label = $this.prev('label');
return;
}
if (password.length < 8) { if (e.type === 'keyup') {
showError("Das Passwort muss mindestens 8 Zeichen lang sein"); if ($this.val() === '') {
return; label.removeClass('active highlight');
} } else {
$('.isa_error').hide(); label.addClass('active highlight');
mp.trigger("registerInformationToServer", password); }
} else if (e.type === 'blur') {
if ($this.val() === '') {
label.removeClass('active highlight');
} else {
label.removeClass('highlight');
}
} else if (e.type === 'focus') {
if ($this.val() === '') {
label.removeClass('highlight');
}
else if ($this.val() !== '') {
label.addClass('highlight');
}
}
});
$('.tab a').on('click', function (e) {
e.preventDefault();
$(this).parent().addClass('active');
$(this).parent().siblings().removeClass('active');
target = $(this).attr('href');
$('.tab-content > div').not(target).hide();
$(target).fadeIn(600);
});
$('#form-login').on('submit', e => {
e.preventDefault();
var username = $("#login-username").val();
var password = $("#login-password").val();
if (password.trim().length === 0 || username.trim().length === 0) {
showError("Alle Felder müssen <b>ausgefüllt</b< werden");
return;
}
mp.trigger('CEF:Login_LoginRequest', username, password);
});
$('#form-register').on('submit', e => {
e.preventDefault();
var username = $("#register-username").val();
var password = $("#register-password-first").val();
var passwordRepeat = $("#register-password-second").val();
if (password.trim().length === 0 || username.trim().length === 0 || passwordRepeat.trim().length === 0) {
showError("Alle Felder müssen <b>ausgefüllt</b< werden");
return;
}
if (password !== passwordRepeat) {
showError("Beide <b>Passwörter</b> müssen <b>übereinstimmen</b>");
return;
}
mp.trigger('CEF:Login_RegisterRequest', username, password, passwordRepeat);
});
});
function setPlayerName(name) {
playerName = name;
$(".input-username").val(playerName);
$(".input-username").prev("label").addClass("active");
} }
function loginPlayer() { function showError(error) {
$("#error-field p").html(error);
let password = document.getElementById("passwordInputLogin").value; if (errorShown) {
$("#error-field").effect("shake", null, 500);
if (password === "") { } else {
showError("Du musst ein Passwort angeben!"); $("#error-field").slideDown();
return;
} }
$('.isa_error').hide();
mp.trigger("loginInformationToServer", password); errorShown = true;
} }

View File

@@ -1,3 +1,3 @@
exports = function (money) { exports = function (money, digits = 0) {
return money.toLocaleString("de-DE", { minimumFractionDigits: 0 }); return money.toLocaleString("de-DE", { minimumFractionDigits: digits });
}; };

View File

@@ -10,7 +10,7 @@ using System.Text;
* @copyright (c) 2008 - 2018 Life of German * @copyright (c) 2008 - 2018 Life of German
*/ */
namespace ReallifeGamemode.Server.Logs namespace ReallifeGamemode.Server.Entities.Logs
{ {
public class BankAccountTransactionHistory public class BankAccountTransactionHistory
{ {

View File

@@ -11,7 +11,7 @@ using ReallifeGamemode.Server.Entities;
* @copyright (c) 2008 - 2018 Life of German * @copyright (c) 2008 - 2018 Life of German
*/ */
namespace ReallifeGamemode.Server.Logs namespace ReallifeGamemode.Server.Entities.Logs
{ {
public class Death public class Death
{ {

View File

@@ -10,7 +10,7 @@ using System.ComponentModel.DataAnnotations.Schema;
* @copyright (c) 2008 - 2018 Life of German * @copyright (c) 2008 - 2018 Life of German
*/ */
namespace ReallifeGamemode.Server.Saves namespace ReallifeGamemode.Server.Entities.Saves
{ {
public class SavedBlip public class SavedBlip
{ {

View File

@@ -10,7 +10,7 @@ using System.ComponentModel.DataAnnotations.Schema;
* @copyright (c) 2008 - 2018 Life of German * @copyright (c) 2008 - 2018 Life of German
*/ */
namespace ReallifeGamemode.Server.Saves namespace ReallifeGamemode.Server.Entities.Saves
{ {
public class SavedMarker public class SavedMarker
{ {

View File

@@ -10,7 +10,7 @@ using System.ComponentModel.DataAnnotations.Schema;
* @copyright (c) 2008 - 2018 Life of German * @copyright (c) 2008 - 2018 Life of German
*/ */
namespace ReallifeGamemode.Server.Saves namespace ReallifeGamemode.Server.Entities.Saves
{ {
public class SavedPed public class SavedPed
{ {

View File

@@ -10,7 +10,7 @@ using System.ComponentModel.DataAnnotations.Schema;
* @copyright (c) 2008 - 2018 Life of German * @copyright (c) 2008 - 2018 Life of German
*/ */
namespace ReallifeGamemode.Server.Saves namespace ReallifeGamemode.Server.Entities.Saves
{ {
public class SavedPickup public class SavedPickup
{ {

View File

@@ -10,7 +10,7 @@ using System.ComponentModel.DataAnnotations.Schema;
* @copyright (c) 2008 - 2018 Life of German * @copyright (c) 2008 - 2018 Life of German
*/ */
namespace ReallifeGamemode.Server.Saves namespace ReallifeGamemode.Server.Entities.Saves
{ {
public class SavedTextLabel public class SavedTextLabel
{ {

View File

@@ -12,7 +12,7 @@ using ReallifeGamemode.Server.Entities;
* @copyright (c) 2008 - 2018 Life of German * @copyright (c) 2008 - 2018 Life of German
*/ */
namespace ReallifeGamemode.Server.Saves namespace ReallifeGamemode.Server.Entities.Saves
{ {
public class SavedVehicle : ServerVehicle public class SavedVehicle : ServerVehicle
{ {

View File

@@ -15,8 +15,6 @@ namespace ReallifeGamemode.Server.Events
{ {
class Connect : Script class Connect : Script
{ {
[ServerEvent(Event.PlayerConnected)] [ServerEvent(Event.PlayerConnected)]
public void OnPlayerConnected(Client player) public void OnPlayerConnected(Client player)
{ {
@@ -28,8 +26,6 @@ namespace ReallifeGamemode.Server.Events
{ {
if(!dbContext.WhitelistEntries.Any(w => w.SocialClubName.ToLower() == player.SocialClubName.ToLower())) if(!dbContext.WhitelistEntries.Any(w => w.SocialClubName.ToLower() == player.SocialClubName.ToLower()))
{ {
player.TriggerEvent("disableLogin");
string msg2 = "~m~*** " + player.Name + "[" + player.SocialClubName + "] (" + player.Address + ") hat versucht, sich einzuloggen, steht aber nicht auf der Whitelist."; string msg2 = "~m~*** " + player.Name + "[" + player.SocialClubName + "] (" + player.Address + ") hat versucht, sich einzuloggen, steht aber nicht auf der Whitelist.";
ChatService.BroadcastAdmin(msg2, AdminLevel.ADMIN); ChatService.BroadcastAdmin(msg2, AdminLevel.ADMIN);
@@ -42,29 +38,30 @@ namespace ReallifeGamemode.Server.Events
} }
} }
if (IsPlayerBanned(player)) return;
player.TriggerEvent("SERVER:Login_ShowBrowser");
string msg = "~m~*** " + player.Name + " [" + player.SocialClubName + "] [ID:" + player.Handle.Value + "] (" + player.Address + ")"; string msg = "~m~*** " + player.Name + " [" + player.SocialClubName + "] [ID:" + player.Handle.Value + "] (" + player.Address + ")";
ChatService.BroadcastAdmin(msg, AdminLevel.ADMIN); ChatService.BroadcastAdmin(msg, AdminLevel.ADMIN);
} }
[RemoteEvent("IsPlayerBanned")] private bool IsPlayerBanned(Client player)
public void IsPlayerBanned(Client player)
{ {
using (var loginUser = new DatabaseContext()) using (var dbContext = new DatabaseContext())
{ {
var user = loginUser.Users.SingleOrDefault(b => b.Name == player.Name); var user = dbContext.Users.SingleOrDefault(b => b.Name == player.Name);
if (user == null) if (user == null)
{ {
player.TriggerEvent("showLogin"); return false;
return;
} }
if (user.BanId != null) if (user.BanId != null)
{ {
var dt = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); var dt = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
var bannedUser = loginUser.Bans.SingleOrDefault(u => u.Id == user.BanId); var bannedUser = dbContext.Bans.SingleOrDefault(u => u.Id == user.BanId);
if (bannedUser.Applied == bannedUser.UntilDateTime) if (bannedUser.Applied == bannedUser.UntilDateTime)
{ {
player.SendChatMessage("!{#FF4040}Du wurdest permanent gebannt! [" + bannedUser.Reason + "]"); player.SendChatMessage("!{#FF4040}Du wurdest permanent gebannt! [" + bannedUser.Reason + "]");
player.Kick(); player.Kick();
return true;
} }
else else
{ {
@@ -75,16 +72,17 @@ namespace ReallifeGamemode.Server.Events
{ {
player.SendChatMessage("Du bist noch bis zum !{#FF4040}" + dt.AddSeconds(timeStamp).ToLocalTime() + " Uhr ~s~gebannt. [" + bannedUser.Reason + "]"); player.SendChatMessage("Du bist noch bis zum !{#FF4040}" + dt.AddSeconds(timeStamp).ToLocalTime() + " Uhr ~s~gebannt. [" + bannedUser.Reason + "]");
player.Kick(); player.Kick();
return true;
} }
else else
{ {
user.BanId = null; user.BanId = null;
loginUser.SaveChanges(); dbContext.SaveChanges();
player.TriggerEvent("showLogin"); return false;
} }
} }
} }
else player.TriggerEvent("showLogin"); return false;
} }
} }
} }

View File

@@ -91,7 +91,7 @@ namespace ReallifeGamemode.Server.Events
using (var userDeath = new DatabaseContext()) using (var userDeath = new DatabaseContext())
{ {
var dead = new Logs.Death { VictimId = player.GetUser().Id, KillerId = killerId, KillerPositionX = killerPosX, KillerPositionY = killerPosY, var dead = new 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, KillerPositionZ = killerPosZ, KillerHeading = killerHeading, VictimPositionX = player.Position.X, VictimPositionY = player.Position.Y,
VictimPositionZ = player.Position.Z, VictimHeading = player.Heading, CauseOfDeath = reason.ToString()}; VictimPositionZ = player.Position.Z, VictimHeading = player.Heading, CauseOfDeath = reason.ToString()};
userDeath.DeathLogs.Add(dead); userDeath.DeathLogs.Add(dead);

View File

@@ -14,32 +14,33 @@ namespace ReallifeGamemode.Server.Events
{ {
public class Login : Script public class Login : Script
{ {
[RemoteEvent("OnPlayerLogin")] [RemoteEvent("CLIENT:Login_LoginRequest")]
public void OnPlayerLogin(Client player, string password) public void OnPlayerLogin(Client player, string username, string password)
{ {
using (var loginUser = new DatabaseContext()) using (var loginUser = new DatabaseContext())
{ {
var user = loginUser.Users.SingleOrDefault(b => b.Name == player.Name); var user = loginUser.Users.SingleOrDefault(b => b.Name == username);
if (user == null) if (user == null)
{ {
player.TriggerEvent("loginFail", "Benutzer existiert nicht! Registriere dich zuerst!"); player.TriggerEvent("SERVER:Login_Error", "Benutzer existiert nicht! Registriere dich zuerst!");
} }
else else
{ {
if (user.SocialClubName != player.SocialClubName && user.Password == NAPI.Util.GetHashSha256(password)) if (user.SocialClubName != player.SocialClubName && user.Password == NAPI.Util.GetHashSha256(password))
{ {
player.TriggerEvent("loginDeny", "Dieser Benutzer gehört dir nicht!"); player.TriggerEvent("SERVER:Login_Error", "Dieser Benutzer gehört dir nicht!");
//TODO ?? Log einbauen für den bösen Bub. //TODO ?? Log einbauen für den bösen Bub.
player.Kick(); player.Kick();
} }
if (user.Password != NAPI.Util.GetHashSha256(password)) if (user.Password != NAPI.Util.GetHashSha256(password))
{ {
player.TriggerEvent("loginFail", "Passwort inkorrekt!"); player.TriggerEvent("SERVER:Login_Error", "Passwort inkorrekt!");
} }
else else
{ {
player.TriggerEvent("loginSuccess"); player.Name = username;
player.TriggerEvent("SERVER:Login_Success");
player.SetData("isLoggedIn", true); player.SetData("isLoggedIn", true);
player.SetData("spec", true); player.SetData("spec", true);
player.SetData("duty", false); player.SetData("duty", false);

View File

@@ -12,13 +12,12 @@ namespace ReallifeGamemode.Server.Events
{ {
class Register : Script class Register : Script
{ {
[RemoteEvent("OnPlayerRegister")] [RemoteEvent("CLIENT:Login_RegisterRequest")]
public void OnPlayerRegister(Client player, string password) public void OnPlayerRegister(Client player, string username, string password, string passwordRepeat)
{ {
using (var dbContext = new DatabaseContext()) using (var dbContext = new DatabaseContext())
{ {
var checkedUser = dbContext.Users.SingleOrDefault(b => b.Name == player.Name); if (!dbContext.Users.Any(u => u.Name == username))
if (checkedUser == null)
{ {
var user = new Entities.User var user = new Entities.User
{ {
@@ -42,7 +41,7 @@ namespace ReallifeGamemode.Server.Events
dbContext.UserBankAccounts.Add(userBankAccount); dbContext.UserBankAccounts.Add(userBankAccount);
dbContext.SaveChanges(); dbContext.SaveChanges();
player.TriggerEvent("registerSuccess"); player.TriggerEvent("SERVER:Login_Success");
player.SetData("isLoggedIn", true); player.SetData("isLoggedIn", true);
player.SetData("isDead", false); player.SetData("isDead", false);
@@ -52,14 +51,13 @@ namespace ReallifeGamemode.Server.Events
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension"); player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
player.TriggerEvent("toggleCreator"); player.TriggerEvent("toggleCreator");
} }
else if (dbContext.Users.Where(u => u.SocialClubName == player.SocialClubName).Count() >= 3)
else if (player.SocialClubName == checkedUser.SocialClubName)
{ {
player.TriggerEvent("registerFail", "Dieser SocialClubAccount ist schon registriert!"); player.TriggerEvent("SERVER:Login_Error", "Es sind schon 3 Konten mit dieser Socialclub-ID registriert.");
} }
else if (checkedUser.Name == player.Name) else
{ {
player.TriggerEvent("registerFail", "Benutzername existiert schon!"); player.TriggerEvent("SERVER:Login_Error", "Dieser Benutzername kann nicht registriert werden.");
} }
} }
} }

View File

@@ -5,6 +5,7 @@ using System.Text;
using GTANetworkAPI; using GTANetworkAPI;
using ReallifeGamemode.Server.Business; using ReallifeGamemode.Server.Business;
using ReallifeGamemode.Server.Entities; using ReallifeGamemode.Server.Entities;
using ReallifeGamemode.Server.Entities.Logs;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Models; using ReallifeGamemode.Server.Models;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
@@ -29,7 +30,7 @@ namespace ReallifeGamemode.Server.Managers
if (account == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT; if (account == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT;
var transactionLog = new Logs.BankAccountTransactionHistory var transactionLog = new BankAccountTransactionHistory
{ {
Sender = "ADMIN: " + admin.Name, Sender = "ADMIN: " + admin.Name,
SenderBalance = 0, SenderBalance = 0,
@@ -67,7 +68,7 @@ namespace ReallifeGamemode.Server.Managers
if (senderAccount.Balance < amount) return TransactionResult.SENDER_NOT_ENOUGH_MONEY; if (senderAccount.Balance < amount) return TransactionResult.SENDER_NOT_ENOUGH_MONEY;
var transactionLog = new Logs.BankAccountTransactionHistory var transactionLog = new BankAccountTransactionHistory
{ {
Sender = sender.Name, Sender = sender.Name,
SenderBalance = senderAccount.Balance, SenderBalance = senderAccount.Balance,

View File

@@ -1,7 +1,7 @@
using GTANetworkAPI; using GTANetworkAPI;
using ReallifeGamemode.Server.Entities; using ReallifeGamemode.Server.Entities;
using ReallifeGamemode.Server.Entities.Saves;
using ReallifeGamemode.Server.Models; using ReallifeGamemode.Server.Models;
using ReallifeGamemode.Server.Saves;
/** /**
* @overview Life of German Reallife - Managers LoadManager (LoadManager.cs) * @overview Life of German Reallife - Managers LoadManager (LoadManager.cs)

View File

@@ -1,9 +1,9 @@
using GTANetworkAPI; using GTANetworkAPI;
using ReallifeGamemode.Server.Business; using ReallifeGamemode.Server.Business;
using ReallifeGamemode.Server.Entities; using ReallifeGamemode.Server.Entities;
using ReallifeGamemode.Server.Entities.Saves;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Models; using ReallifeGamemode.Server.Models;
using ReallifeGamemode.Server.Saves;
using System; using System;
namespace ReallifeGamemode.Server.Managers namespace ReallifeGamemode.Server.Managers

View File

@@ -10,16 +10,6 @@ namespace ReallifeGamemode.Server.Models
{ {
public partial class DatabaseContext : DbContext public partial class DatabaseContext : DbContext
{ {
public DatabaseContext(DbContextOptions<DatabaseContext> options) :base (options)
{
}
public DatabaseContext()
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
@@ -70,18 +60,18 @@ namespace ReallifeGamemode.Server.Models
//Logs //Logs
//public DbSet<Logs.Ban> BanLogs { get; set; } //public DbSet<Logs.Ban> BanLogs { get; set; }
public DbSet<Logs.BankAccountTransactionHistory> BankAccountTransactionLogs { get; set; } public DbSet<Entities.Logs.BankAccountTransactionHistory> BankAccountTransactionLogs { get; set; }
public DbSet<Logs.Death> DeathLogs { get; set; } public DbSet<Entities.Logs.Death> DeathLogs { get; set; }
//Saves //Saves
public DbSet<Saves.SavedBlip> Blips { get; set; } public DbSet<Entities.Saves.SavedBlip> Blips { get; set; }
public DbSet<Entities.Door> Doors { get; set; } public DbSet<Entities.Door> Doors { get; set; }
public DbSet<Entities.GotoPoint> GotoPoints { get; set; } public DbSet<Entities.GotoPoint> GotoPoints { get; set; }
public DbSet<Saves.SavedMarker> Markers { get; set; } public DbSet<Entities.Saves.SavedMarker> Markers { get; set; }
public DbSet<Saves.SavedPed> Peds { get; set; } public DbSet<Entities.Saves.SavedPed> Peds { get; set; }
public DbSet<Saves.SavedPickup> Pickups { get; set; } public DbSet<Entities.Saves.SavedPickup> Pickups { get; set; }
public DbSet<Saves.SavedTextLabel> TextLabels { get; set; } public DbSet<Entities.Saves.SavedTextLabel> TextLabels { get; set; }
public DbSet<Saves.SavedVehicle> Vehicles { get; set; } public DbSet<Entities.Saves.SavedVehicle> Vehicles { get; set; }
public DbSet<Entities.ShopVehicle> ShopVehicles { get; set; } public DbSet<Entities.ShopVehicle> ShopVehicles { get; set; }
// Business // Business