How to get player's name at the ping screen
#1
Tongue 
Ok, so I'm trying to get player's username to display in the server's description when the player pings my server, as I'd like to show personalised description.

I've read the description, but it would appear that on some servers(not using Cuberite) they're able to get the username.
How would I be able to reproduce this?
Reply
Thanks given by:
#2
Do you mean something like this?:

function OnServerPing(ClientHandle, ServerDescription, OnlinePlayers, MaxPlayers, Favicon)
	local newDescription = "";
	cRoot:ForEachPlayer(function(player)
		newDescription = newDescription .. player:GetName();
	end);
	
	return false, newDescription, OnlinePlayers, MaxPlayers, Favicon
end
Reply
Thanks given by:
#3
(08-14-2018, 01:25 AM)NiLSPACE Wrote: Do you mean something like this?:

function OnServerPing(ClientHandle, ServerDescription, OnlinePlayers, MaxPlayers, Favicon)
 local newDescription = "";
 cRoot:ForEachPlayer(function(player)
 newDescription = newDescription .. player:GetName();
 end);
 
 return false, newDescription, OnlinePlayers, MaxPlayers, Favicon
end

No, I'm sorry, but I don't see it working... I get the following [img]data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmkAAABLCAIAAACk6IeRAAAAA3NCSVQICAjb4U/gAAAZpklEQVR4Xu2dCZQV1ZnH39ZNN93IJkGjgktwiZqMy4wxiSNGZYnQAhIHwRVxkEmiGT3jHM9xjvHEk3gYx0nigguRAWRRoUUBF+TgmhiP46CimbgL4oJI0900/ejldc1363uv3ld166tXr/vBOTr/sm3q3br3u1/93q379Xe/e28lhw+uTyQSezq76DcfNdVV3rlM9xLppDvX432sr+1XMr8sG0e+VpdM1+qNIx/6M0nt+wX/aD5oP9F80H6i+aD9RPP5SrSflNQS5yAAAiAAAiAAAiUJZLpzuUAmmeKkiz5lbbroa0p/ReaXf09l0kXDLH1BmV/m0cpK9TQ5Mg/0Zxrgb7d+tB9mgufXfkbQ/zAT9J922wjtN+B32h0sUkAABEAABEAgigBsZxQdXAMBEAABEAABmwBsp80EKSAAAiAAAiAQRSBZV2Nm1crYWP8R3+g3cnh6UH0ynRRFHeWcksWlpJatD+mqzITTneva2d7+wY6uT1o99eLEUDP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Y2t3cXDV0aKFGsk9hI6Lq+C3bs7AixjsslV4Ihbq1R+SnqyxKVmfOu3fuYs3lHTlp83ZSPmrTReMq42Q+AsIAyzVA2jpOmUfGALT1Q5ocT0lzI8W/YBLQn8lo3MBfthw+R/thDnh+7bahPUfofwrPTtFGlGw/Pr8zu3mza7fYLJE07bwQAc0j9/JzEe+LKDNdHb+VaqhVZDd/arcVpIAACIAACIBAxQn4bGfHJ1uz77/n1hHD7PVmoHVvWeXse1s6tn5RcToQCAIgAAIgAAI2geD6zra/vNWzq7XfISPTgwaaLWrzB9m8sEHX4EAr5Q4fUA0vro3NBsWGVe2WdXLdueZdHVs+b9/yuX1vSAEBEAABEACBvUEgv5+tHNuNE0PKFM1qoi3b4WlWU100xtq6KCl/T2f4HrMyzpfMFeXHKQv9+esAf+aA9sMc/M+492cxnt987yX5oP+x+xC0n8BzZK9R2RsWGjJBAARAAARA4OtDALbz6/Nd4k5AAARAAAT2DQHYzn3DGbWAAAiAAAh8fQgkB9aZFZDaHqoyZiZjmRKAtq5RxjI1YHIMPY5MTQ70ZzJaPFjjBv5MBu0H7Qf9DxPwr30vrndE/x/oRf8PtnTQe2cllg0AAAAASUVORK5CYIIA[/img]
even tho I wanted to have pinging player's name shown in there.

Thanks anyways.

EDIT: Hmm it'd appear that the image system is broken(it works fine in the editor).
Putting it again:
[Image: Screenshot_at_2018_08_13_21_17_59.png]
Reply
Thanks given by:
#4
I tried the code I provided (as I didn't test it beforehand) and it seems I made a slight error. cRoot has to be replaced with cRoot:Get(). Afterwards it works for me.
Reply
Thanks given by:
#5
(08-14-2018, 07:05 PM)NiLSPACE Wrote: I tried the code I provided (as I didn't test it beforehand) and it seems I made a slight error. cRoot has to be replaced with cRoot:Get(). Afterwards it works for me.

Sadly it doesn't do what I wanted it to. It lists all of the players online, but I want to get the "pinging's player" name.

EDIT: Yeah, I've noticed the skipped ":Get()"
Reply
Thanks given by:
#6
Ah, then I misunderstood you. the cClientHandle has a GetPlayer method which returns a cPlayer object, but it might not be filled yet which would mean it returns nil.
Reply
Thanks given by:
#7
(08-23-2018, 03:48 AM)NiLSPACE Wrote: Ah, then I misunderstood you. the cClientHandle has a GetPlayer method which returns a cPlayer object, but it might not be filled yet which would mean it returns nil.

So in short, there is no way?
Reply
Thanks given by:
#8
It might be. You'll have to try it. What happens in the console when you use
function OnServerPing(ClientHandle, ServerDescription, OnlinePlayers, MaxPlayers, Favicon)
    local name = ClientHandle:GetPlayer():GetName();
    print(name)
end
Reply
Thanks given by:
#9
(08-23-2018, 05:19 AM)NiLSPACE Wrote: It might be. You'll have to try it. What happens in the console when you use
function OnServerPing(ClientHandle, ServerDescription, OnlinePlayers, MaxPlayers, Favicon)
    local name = ClientHandle:GetPlayer():GetName();
    print(name)
end

Just a lot of errors...

Code:
[09:35:36] LUA: Plugins/BanPlus/BanPlus.lua:52: attempt to index a nil value
[09:35:36] Stack trace:
[09:35:36]   Plugins/BanPlus/BanPlus.lua(52): (no name)
[09:35:36] Stack trace end
[09:35:36] Error in <attached> calling function <callback>()

So it would appear as it isn't possible?
Reply
Thanks given by:
#10
Yes, it is not possible. The player is only added to the client handle once it has logged in, and I don't believe the username is even sent in ping packets. Can you link to an example of another server that implements this feature?
Reply
Thanks given by:




Users browsing this thread: 8 Guest(s)