Hi!
I want to obtain the connecting players name during loadingscreen and then insert it into a special div on the loadingscreen.
The code below is what I have come up with at the moment:
Client:
RegisterNetEvent("sendPlayerName")
AddEventHandler("sendPlayerName", function (value)
SendNUIMessage({ run = true, UserName = value })
end)
And server:
RegisterServerEvent("playerConnecting")
AddEventHandler("playerConnecting", function(source)
local PlayerData = GetPlayerName(source)
TriggerClientEvent('sendPlayerName', source, PlayerData)
end)
Javascript:
$(function() //GetNumberOfPlayers()
{
window.addEventListener('message', function(event)
{
document.getElementById('para').innerHTML = event.data.UserName;
});
});
It does not seem to be working as nothing appears on the “para” div, even if I replace “event.data.UserName” with “Test” for example it does not change.
Any ideas on what I have done wrong?