Fixed server -> client transport
This commit is contained in:
@@ -15,10 +15,9 @@ mp.events.add("showPlayerlist", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("fetchPlayerList", (players) => {
|
mp.events.add("fetchPlayerList", (playersJson) => {
|
||||||
|
var players = JSON.parse(playersJson);
|
||||||
for (var player in players)
|
players.forEach((player) => {
|
||||||
{
|
mp.gui.chat.push(player.Id + ", " + player.Name + ", " + player.Ping);
|
||||||
mp.gui.chat.push(player["Id"] + ", " + player["Name"] + ", " + player["Ping"])
|
});
|
||||||
}
|
|
||||||
});
|
});
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using reallife_gamemode.Server.Util;
|
using reallife_gamemode.Server.Util;
|
||||||
/**
|
/**
|
||||||
* @overview Life of German Reallife - Event Key (Key.cs)
|
* @overview Life of German Reallife - Event Key (Key.cs)
|
||||||
@@ -28,7 +29,7 @@ namespace reallife_gamemode.Server.Events
|
|||||||
|
|
||||||
ListPlayers.Add(lPlayer);
|
ListPlayers.Add(lPlayer);
|
||||||
}
|
}
|
||||||
player.TriggerEvent("fetchPlayerList", ListPlayers);
|
player.TriggerEvent("fetchPlayerList", JsonConvert.SerializeObject(ListPlayers));
|
||||||
}
|
}
|
||||||
[RemoteEvent("keyPress:N")]
|
[RemoteEvent("keyPress:N")]
|
||||||
public void KeyPressN(Client player)
|
public void KeyPressN(Client player)
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ using GTANetworkAPI;
|
|||||||
|
|
||||||
namespace reallife_gamemode.Server.Util
|
namespace reallife_gamemode.Server.Util
|
||||||
{
|
{
|
||||||
public class ListPlayer : Script
|
public class ListPlayer
|
||||||
{
|
{
|
||||||
public int Id;
|
public int Id { get; set; }
|
||||||
public string Name;
|
public string Name { get; set; }
|
||||||
public int Ping;
|
public int Ping { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user