Jump to content

Call function whenever a player joins/leaves

Recommended Posts


at the moment i use the "ms_playerjoined" and "ms_playerleft" events to call my function whenever someone leaves or joins the game:

inst:ListenForEvent("ms_playerjoined", eventfn, GLOBAL.TheWorld)
inst:ListenForEvent("ms_playerleft", eventfn, GLOBAL.TheWorld)

"inst" in this case is an icebox standing anywhere in the world/caves.

The problem i have is that these aren't the right events i think... because ms_playerleft gets only called when someone leaves the caves or logs out from the caves. If the player joined in the overworld and never goes underground, neither event gets called.

I need an event that fires when a player logs in and that i can catch regardless if the player joins in the overworld or caves and a similar event for a leaving player.

Is there anything i can use? As a temporary fix i use periodic tasks to check for players, but this is pretty bad for performance considering i only care when a player joins or leaves.

Edited by BakaSchwarz
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...