Author Topic: Detect if client is the host  (Read 949 times)

I know there are ways to tell if the client is an admin or super admin
Code: [Select]
if(%client.isAdmin)
but how do you tell if the client is the host? I have heard from many people that you cannot do
Code: [Select]
if(%client.isHost)
If that is true, then what do I do to make it detect whether it is the host or not?

if(%cl.bl_id == getNumKeyID())   //Does not work for LAN/singleplayer!
   - or -
if(%cl.isAdmin && %cl.isSuperAdmin)

if(%cl.bl_id == getNumKeyID())   //Does not work for LAN/singleplayer!
   - or -
if(%cl.isAdmin && %cl.isSuperAdmin)
I will try out the second one

if(%cl.bl_id == getNumKeyID())   //Does not work for LAN/singleplayer!
   - or -
if(%cl.isAdmin && %cl.isSuperAdmin)

Second option is true for super admins as well as the host.

Your best bet would be to do a combo of checking if the client id is the same as the server or if the client's ip is local (for lan servers), presuming isHost doesn't actually work.

...presuming isHost doesn't actually work.

It does "work", but only when there's a server mod which sets it. The problem is that this isn't easy to realize for new modders, with the unfortunate consequence that they'll try to use it for a check and then it won't work with vanilla Blockland.


Second option is true for super admins as well as the host.

Really? I could have sworn that on SAs, isAdmin is false.

Really? I could have sworn that on SAs, isAdmin is false.
Nope, I just remembered once when I tried making something that greets a client
when they connect, it was greeting the wrong people. (It was telling super admins that
they were admins)

This is what I've been using:

Code: [Select]
%isHost = (%client.isLocalConnection() || ($Server::LAN && $Server::Dedicated) || %client.getBLID() $= getNumKeyID());
That should cover everything.