Hey everyone,
Just a quick question. When, for example an admin uses a console command to teleport to another player/location, what functions are called on the admin client.
ie, is OnPlayerRespawned (I know it's probably not) called?
At the risk of checking if a teleport command is about to be run on the server, I wondered if there was a cleaner way to identify what happens upon teleportation.
Thanks for reading.
What's called when a player teleports?
Discussion in 'Rust Development' started by lethal_d0se, Feb 1, 2016.
-
Good question,
i have taken a quick look into the Assembly-CSharp.dll for the command "teleport2me"
-> /assembly-CSharp/ConVar/Global.cs
Line 375
(There are also the methods "teleportany" and "teleport")Code:public static void teleport2me(ConsoleSystem.Arg args) { //few lines of Code }
Not sure if that helps you out? But you could Hook these methods. Of course that depends on weither you are using the standard teleport commands or a oxide Plugin that does the teleport on "its own".
I am pretty sure methods for the gfx side of things are called as well (displaying the player model).
What do you actually want to archive? Logging the teleport activities your admins are executing? -
Hey, thanks for your response, very helpful.
I asked because I have a bug (of sorts) in my plugin. Users have stated that the GUI element my plugin draws, redraws when teleporting, showing a duplicate over the original. The result of my question would ideally be destroying the element on teleport, as it's redrawn when the player is teleported anyway. -
Ok i see.
As a workaround you could .Clear()/null/empty all GUI Elements for a player before (re)drawing them maybe?
Or take a look on how other plugins do create/handle their GUI Elements?
Sorry i cant be more precice i have like 0 experience in the GUI section. -
Most teleportation plugins put players to sleep during the teleportation. I looked at your plugin and it seems like you use the OnPlayerSleepEnded(...) hook to create your GUI elements. This isn't a problem normally because the player will only ever be put to sleep when he dies beforehand and you do use the OnPlayerRespawned(...) hook to destroy the GUI elements if that happens.
In case of the teleportation plugin players won't die or respawn before they are put to sleep so your GUI elements will never be destroyed beforehand (OnPlayerRespawned(...) never gets called). So when they wake up they will trigger the OnPlayerSleepEnded hook again and an additional set of GUI elements will be added.
At least, that's my take on it. -
Thanks, I think the user in question is using a plugin rather than the vanilla commands. I say that because when I'm teleporting myself on a test server, I see no unexpected draws. In light of this, I'll take your advice and check the sleep state of the player, then ask the user to test accordingly.
I'll post my findings, it's an interesting one.
