Add Playerlist (tablist)
This commit is contained in:
31
Client/Gui/playerlist.html
Normal file
31
Client/Gui/playerlist.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<!--
|
||||
* @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">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><center>ID</center></th>
|
||||
<th>Name</th>
|
||||
<th><center>Ping</center></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tr class="playerAmount"></tr>
|
||||
</table>
|
||||
</div>
|
||||
<script src="jquery-3.3.1.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
24
Client/Gui/playerlist.js
Normal file
24
Client/Gui/playerlist.js
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @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", (players) => {
|
||||
|
||||
for (var player in players)
|
||||
{
|
||||
mp.gui.chat.push(player["Id"] + ", " + player["Name"] + ", " + player["Ping"])
|
||||
}
|
||||
});
|
||||
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%;
|
||||
}
|
||||
@@ -15,6 +15,14 @@ mp.keys.bind(0x0D, false, function () {
|
||||
}
|
||||
});
|
||||
|
||||
//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) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
require('./Gui/infobox.js');
|
||||
require('./Gui/playerlist.js');
|
||||
require('./Login/main.js');
|
||||
require('./Player/keys.js');
|
||||
require('./Save/main.js');
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Server.Util;
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Key (Key.cs)
|
||||
* @author VegaZ
|
||||
@@ -12,6 +13,23 @@ 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", ListPlayers);
|
||||
}
|
||||
[RemoteEvent("keyPress:N")]
|
||||
public void KeyPressN(Client player)
|
||||
{
|
||||
|
||||
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 : Script
|
||||
{
|
||||
public int Id;
|
||||
public string Name;
|
||||
public int Ping;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user