Author Topic: onenter?  (Read 830 times)

Whats the code to do something whenever someone enters the server?

Whats the code to do something whenever someone enters the server?
use GameConnection::AutoAdminCheck(%this)

use GameConnection::AutoAdminCheck(%this)
When did he ask anything about admins?

Try: gameconnection::oncliententergame(%client)

When did he ask anything about admins?

Try: GameConnection::onClientEnterGame(%client)

It's one of the commands always called on client join, but good idea to suggest against piggybacking branched commands like that.

onClientEnterGame is called when the player SPAWNS, not when they connect.

This 'piggybacking branched command' is ALWAYS called and ALWAYS will be. It's completely safe to use.

So repeated:

use GameConnection::AutoAdminCheck(%this)

onClientEnterGame is called when the player SPAWNS, not when they connect.

This 'piggybacking branched command' is ALWAYS called and ALWAYS will be. It's completely safe to use.

So repeated:


I know, I said branched commands. AKA commands that run when a player joins from a main command. What command calls AutoAdminCheck?

Just remember to parent it. Otherwise all auto admins will not get admin.

Just remember to parent it. Otherwise all auto admins will not get admin.
I'm confused about this whole parenting thing. I know you have to do it, but I don't know why. Could anyone give me a brief explanation of this?

I know, I said branched commands. AKA commands that run when a player joins from a main command. What command calls AutoAdminCheck?
I believe onConnected, but that function is protected.

I'm confused about this whole parenting thing. I know you have to do it, but I don't know why. Could anyone give me a brief explanation of this?
Calling the parent function determines when and if the original function is called.

For example:

function hello(){echo($asd);}
That will print $asd on it's own.
packaging this function:
function hello(){parent::hello();echo($dsf);}
That will print $asd, then print $dsf when hello is called.
If you do it this way:
function hello(){$asd = getRandom(1,100);Parent::hello();}
$asd will become a random number between 1 and 100, and the original function will print it to the console.
Packaging it without parent:
function hello(){$asd = getRandom(1,100);}
This will set $asd to a random number, but because the original function isn't called, it's NOT printed to the console.

Thanks for clearing that up.