Understanding some hooks
Good day all.
So I have a plugin I am using but it isn't working correctly so I have gone through the code (with my little coding knowledge) and have a few questions regarding some lines in the plugin. The plugin is for rust.

So first one is the following code:
void OnPlayerInt(BasePlayer player)
So my question is on this. From the docs I read that this is called on player initialization. Is this only called when they first connect or every time the console logs "player has entered the game"?

The second line of code is this:
timer.In(1, () => OnPlayerInit(player))
What does this line mean exactly? I couldn't figure it out yet so was wondering if someone can please help me understand the above lines so I can better troubleshoot the plugin and learn how plugins work so I may one day create my own.

Thank you in advance
  1. OnPlayerInit (not OnPlayerInt) is called when a player is fully initialized after connecting to the server. It is called every connection.
  2. timer.In is shorthand for timer.Every, which means run timer every X seconds; in your case every 1 second. For your above example, it is setup to call the OnPlayerInit method in that plugin every 1 second.
When you say every connection does that include when the console logs "Player has entered the game" after joining, teleporting and respawning?
In response to silent001 ():
When you say every connection does that include when the console logs "Player has entered the game"...
What shows when that hook is called depends on what plugins you have that utilize it. The hook will only be called ONCE, every time the player connects to the server; not when they respawn while already on the server and never when teleporting.
Thank you for clearing that up for me Wulf. What would be the correct hook then that will allow me to call a method once a player joins, teleports and respawns?
From the consle what I can see is that when a player joins the server the following two console outputs are done:

(19:58:53) | 1**.***.1**.***:59257/7*************508/A_Snow_Cock joined [windows/7*************508]
(19:58:54) | A_Snow_Cock[15338186/7*************508] has entered the game

Then when the player teleports the following message is put to console:
(19:58:54) | A_Snow_Cock[15338186/7*************508] has entered the game

When a player dies and respawns:
(19:58:54) | A_Snow_Cock[15338186/7*************508] has entered the game

These console loggs appear to be a rust server default and not related to any plugins. So my thought process was somehow hooking too that with the correct hook. At the momement the only replacement for void OnPlayerInit(BasePlayer player) that I can find from the docs is void OnPlayerSleepEnded(BasePlayer player) but I fear that this may cause issues if someone is using a plugin that removes sleep from the server.
  1. OnPlayerConnected or OnPlayerInit = when they connect to the server
  2. There are no hooks for teleporting, there is nothing that exists in Rust for that
  3. OnPlayerSpawn or OnPlayerRespawn = when player first spawns, and when they respawn
  4. OnPlayerSleepEnded = when the player wakes up from sleeping
So the best would be to use onsleepend as a player has to wake up after connecting for the first time, respawning after death as well as when teleporting