Merge
This commit is contained in:
40
Client/Gui/playerlist.html
Normal file
40
Client/Gui/playerlist.html
Normal file
@@ -0,0 +1,40 @@
|
||||
<!--
|
||||
* @overview Life of German Reallife - Client Gui playerlist.html
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
<script src="playerlist.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="playerlist">
|
||||
<div id="testDiv"></div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><center>ID</center></th>
|
||||
<th>Name</th>
|
||||
<th><center>Ping</center></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="playerData"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script src="jquery-3.3.1.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
//var table;
|
||||
for (var player in pList) {
|
||||
$("#playerData").append("<tr><td>" + player.Id + "</td><td>" + player.Name + "</td><td>" + player.Ping + "</td></tr>");
|
||||
//table =+ tableRow;
|
||||
}
|
||||
//document.getElementById("testDiv").innerHTML = table;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
35
Client/Gui/playerlist.js
Normal file
35
Client/Gui/playerlist.js
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Gui Playerlist playerlist.js
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
var playerlistBrowser
|
||||
var pList;
|
||||
|
||||
mp.events.add("showPlayerlist", () => {
|
||||
if (!playerlistBrowser) {
|
||||
playerlistBrowser = mp.browsers.new('package://Gui/playerlist.html');
|
||||
mp.gui.chat.activate(false);
|
||||
mp.gui.cursor.show(true, true);
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("fetchPlayerList", (playersJson) => {
|
||||
|
||||
pList = JSON.parse(playersJson);
|
||||
|
||||
pList.forEach((player) => {
|
||||
mp.gui.chat.push(player.Id + ", " + player.Name + ", " + player.Ping);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//function getTable() {
|
||||
// var table = "";
|
||||
// pList.forEach((player) => {
|
||||
// var tableRow = "<tr><td>" + player.Id + "</td><td>" + player.Name + "</td><td>" + player.Ping + "</td>";
|
||||
// table = table + tableRow;
|
||||
// })
|
||||
// return document.write(table);
|
||||
//}
|
||||
8
Client/Gui/script.js
Normal file
8
Client/Gui/script.js
Normal file
@@ -0,0 +1,8 @@
|
||||
$(document).ready(function () {
|
||||
|
||||
mp.trig
|
||||
|
||||
for (var player in pList) {
|
||||
$("#playerData").append("<tr><td>" + player.Id + "</td><td>" + player.Name + "</td><td>" + player.Ping + "</td></tr>");
|
||||
}
|
||||
});
|
||||
38
Client/Gui/style.css
Normal file
38
Client/Gui/style.css
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Save CSS style.css
|
||||
* @author Orangebox, hydrant, VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
.playerlist {
|
||||
background-color: rgba(61, 68, 87, 0.50);
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
margin-right: -50%;
|
||||
transform: translate(-50%, -50%);
|
||||
min-width: 60%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Roboto", sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
overflow: hidden;
|
||||
}
|
||||
td {
|
||||
align-content: stretch;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 0 0 0 rgba(0, 0, 0, 0.24);
|
||||
border-top: 2px double gray;
|
||||
border-bottom: 2px double gray;
|
||||
border-width: 0.5px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
table {
|
||||
margin: auto;
|
||||
align-self:center;
|
||||
width: 100%;
|
||||
}
|
||||
45
Client/Player/keys.js
Normal file
45
Client/Player/keys.js
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Player Keys keys.js
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
//https://docs.microsoft.com/de-de/windows/desktop/inputdev/virtual-key-codes
|
||||
|
||||
var chat = false;
|
||||
|
||||
//ENTER
|
||||
mp.keys.bind(0x0D, false, function () {
|
||||
if (chat === true) {
|
||||
chat = false;
|
||||
}
|
||||
});
|
||||
|
||||
//I
|
||||
mp.keys.bind(0x49, false, function () {
|
||||
if (!chat) {
|
||||
mp.events.callRemote("keyPress:I");
|
||||
mp.events.call("showPlayerlist");
|
||||
}
|
||||
});
|
||||
|
||||
//N
|
||||
mp.keys.bind(0x4E, false, function () {
|
||||
if (!chat) {
|
||||
mp.events.callRemote("keyPress:N");
|
||||
}
|
||||
});
|
||||
|
||||
//T
|
||||
mp.keys.bind(0x54, false, function () {
|
||||
if (chat === false) {
|
||||
chat = true;
|
||||
}
|
||||
});
|
||||
|
||||
//X
|
||||
mp.keys.bind(0x58, false, function () {
|
||||
if (!chat) {
|
||||
mp.events.callRemote("keyPress:X");
|
||||
}
|
||||
});
|
||||
@@ -10,7 +10,9 @@ require('./Save/main.js');
|
||||
require('./Save/save.js');
|
||||
|
||||
require('./Gui/infobox.js');
|
||||
require('./Gui/playerlist.js');
|
||||
require('./Login/main.js');
|
||||
require('./Player/keys.js');
|
||||
require('./Save/main.js');
|
||||
|
||||
require('./FactionManagement/main.js');
|
||||
|
||||
@@ -599,8 +599,13 @@ namespace reallife_gamemode.Server.Commands
|
||||
if (player.IsInVehicle)
|
||||
{
|
||||
Vehicle vehicle = player.Vehicle;
|
||||
<<<<<<< HEAD
|
||||
SaveManager.SaveVehicleData((VehicleHash)vehicle.Model, vehicle.Position, vehicle.Heading, vehicle.NumberPlate,
|
||||
Convert.ToByte(vehicle.PrimaryColor), Convert.ToByte(vehicle.SecondaryColor), vehicle.Locked, vehicle.EngineStatus, Convert.ToByte(vehicle.Dimension));
|
||||
=======
|
||||
SaveData.SaveVehicleData((VehicleHash)vehicle.Model, vehicle.Position, vehicle.Heading, vehicle.NumberPlate,
|
||||
Convert.ToByte(vehicle.PrimaryColor), Convert.ToByte(vehicle.SecondaryColor), vehicle.Locked, Convert.ToByte(vehicle.Dimension));
|
||||
>>>>>>> feature/client-player-keys
|
||||
}
|
||||
else player.SendChatMessage("~m~Du sitzt in keinem Fahrzeug!");
|
||||
break;
|
||||
|
||||
66
Server/Events/Key.cs
Normal file
66
Server/Events/Key.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using reallife_gamemode.Server.Util;
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Key (Key.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
public class Key : Script
|
||||
{
|
||||
[RemoteEvent("keyPress:I")]
|
||||
public void KeyPressI(Client player)
|
||||
{
|
||||
List<Client> players = NAPI.Pools.GetAllPlayers();
|
||||
List<ListPlayer> ListPlayers = new List<ListPlayer>();
|
||||
|
||||
foreach(Client listPlayer in players)
|
||||
{
|
||||
var lPlayer = new ListPlayer();
|
||||
lPlayer.Id = listPlayer.Handle.Value;
|
||||
lPlayer.Name = listPlayer.Name;
|
||||
lPlayer.Ping = listPlayer.Ping;
|
||||
|
||||
ListPlayers.Add(lPlayer);
|
||||
}
|
||||
player.TriggerEvent("fetchPlayerList", JsonConvert.SerializeObject(ListPlayers));
|
||||
}
|
||||
[RemoteEvent("keyPress:N")]
|
||||
public void KeyPressN(Client player)
|
||||
{
|
||||
if (NAPI.Player.IsPlayerInAnyVehicle(player))
|
||||
{
|
||||
bool engineStatus = NAPI.Vehicle.GetVehicleEngineStatus(player.Vehicle);
|
||||
if (engineStatus == false)
|
||||
{
|
||||
player.Vehicle.EngineStatus = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.Vehicle.EngineStatus = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
[RemoteEvent("keyPress:X")]
|
||||
public void KeyPressX(Client player)
|
||||
{
|
||||
if (NAPI.Player.IsPlayerInAnyVehicle(player))
|
||||
{
|
||||
if (player.Seatbelt == false)
|
||||
{
|
||||
player.Seatbelt = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.Seatbelt = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
78
Server/Events/SaveData.cs
Normal file
78
Server/Events/SaveData.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using GTANetworkAPI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
public class SaveData : Script
|
||||
{
|
||||
[RemoteEvent("OnSaveBlipData")]
|
||||
public void OnSaveBlipData(Client player, string blipSprite, string blipName, string blipScale, string blipColor,
|
||||
string blipAlpha, string blipDrawDistance, string blipShortRange, string blipRotation, string blipDimension)
|
||||
{
|
||||
float x = player.Position.X;
|
||||
float y = player.Position.Y;
|
||||
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 Model.DatabaseContext())
|
||||
{
|
||||
var dataSet = new Server.Saves.SavedBlip
|
||||
{
|
||||
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 void SaveVehicleData(VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
||||
string vehicleNumberPlate, byte vehiclePrimaryColor, byte vehicleSecondaryColor, bool vehicleLocked, byte vehicleDimension)
|
||||
{
|
||||
using (var saveData = new Model.DatabaseContext())
|
||||
{
|
||||
var dataSet = new Server.Saves.SavedVehicle
|
||||
{
|
||||
Model = vehicleModel,
|
||||
PositionX = vehiclePosition.X,
|
||||
PositionY = vehiclePosition.Y,
|
||||
PositionZ = vehiclePosition.Z,
|
||||
Heading = vehicleHeading,
|
||||
NumberPlate = vehicleNumberPlate,
|
||||
PrimaryColor = vehiclePrimaryColor,
|
||||
SecondaryColor = vehicleSecondaryColor,
|
||||
Locked = vehicleLocked,
|
||||
Engine = false,
|
||||
Dimension = vehicleDimension,
|
||||
Active = true
|
||||
};
|
||||
saveData.Vehicles.Add(dataSet);
|
||||
saveData.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,11 @@ namespace reallife_gamemode.Server.Extensions
|
||||
{
|
||||
public static User GetUser(this Client client, DatabaseContext context = null)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
if (!client.IsLoggedIn()) return null;
|
||||
=======
|
||||
|
||||
>>>>>>> feature/client-player-keys
|
||||
using (DatabaseContext dbContext = new DatabaseContext())
|
||||
if(context == null)
|
||||
{
|
||||
@@ -36,7 +40,70 @@ namespace reallife_gamemode.Server.Extensions
|
||||
|
||||
public static bool IsLoggedIn(this Client player)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
return player.HasData("isLoggedIn") ? player.GetData("isLoggedIn") : false;
|
||||
=======
|
||||
if(context == null)
|
||||
{
|
||||
using(context = new DatabaseContext())
|
||||
{
|
||||
User u = client.GetUser();
|
||||
if (u == null) return null;
|
||||
return u.GetFaction();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
User u = client.GetUser();
|
||||
if (u == null) return null;
|
||||
return u.GetFaction();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsLoggedIn(Client player)
|
||||
{
|
||||
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(unbanUser).BanId);
|
||||
unbanUser.Bans.Remove(targetUser);
|
||||
unbanUser.SaveChanges();
|
||||
}
|
||||
admin.SendChatMessage(target.Name + " wurde entbannt.");
|
||||
//TODO ***Admin Info: {ADMIN-NAME} hat {USER-NAME} entbannt.
|
||||
>>>>>>> feature/client-player-keys
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,11 @@ namespace reallife_gamemode.Server.Services
|
||||
{
|
||||
player.SendChatMessage("~r~[FEHLER]~s~ Der Spieler wurde nicht gefunden.");
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
|
||||
>>>>>>> feature/client-player-keys
|
||||
public static void PlayerNotLoggedIn(Client player)
|
||||
{
|
||||
player.SendChatMessage("~r~[FEHLER]~s~ Du bist nicht eingeloggt.");
|
||||
@@ -36,7 +40,10 @@ namespace reallife_gamemode.Server.Services
|
||||
{
|
||||
player.SendChatMessage("~r~[FEHLER]~s~ Die Aktion wurde nicht ausgeführt.");
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
>>>>>>> feature/client-player-keys
|
||||
public static void BroadcastFaction(string message, List<Faction> factions)
|
||||
{
|
||||
foreach (Client c in NAPI.Pools.GetAllPlayers())
|
||||
@@ -55,6 +62,7 @@ namespace reallife_gamemode.Server.Services
|
||||
public static void BroadcastFaction(string message, Faction faction)
|
||||
{
|
||||
BroadcastFaction(message, new List<Faction> { faction });
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
|
||||
public static void BroadcastAdmin(string message, AdminLevel minLevel)
|
||||
@@ -66,6 +74,8 @@ namespace reallife_gamemode.Server.Services
|
||||
p.SendChatMessage(message);
|
||||
}
|
||||
});
|
||||
=======
|
||||
>>>>>>> feature/client-player-keys
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
20
Server/Util/ListPlayer.cs
Normal file
20
Server/Util/ListPlayer.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Util ListPlayer ListPlayer.cs
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Util
|
||||
{
|
||||
public class ListPlayer
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int Ping { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user