After the update there is a strange (Bug?) thing. My plugin GUI (InfoPanel) isn't show up.
That is my code now in the OnPlayerInit:
Its working "fine" but my GUI remains in Wonderland....Code:void OnPlayerInit(BasePlayer player) { Puts("PINIT"); Puts(player.displayName); Puts("PL: "+Panels.Count); InitializeGUI(player); timer.Once(1, () => RefreshOnlineAndSleeperPlayerGui()); }
If i add this to the OnPlayerSleepEnded then my GUI show up.
Based on the console messages every variable is the same.Code:void OnPlayerSleepEnded(BasePlayer player) { Puts("PSLEEPEND"); Puts(player.displayName); Puts("PL: " + Panels.Count); InitializeGUI(player); timer.Once(1, () => RefreshOnlineAndSleeperPlayerGui()); }
There is an other code pieces in the OnServerInitialized function.
This one is calling the same InitializeGUI function and working fine if i am on the server and reload the plugin, so there is no problem i think.Code:foreach (BasePlayer player in BasePlayer.activePlayerList) { InitializeGUI(player); }
Any idea? Suggestion?
Solved CUI not working in OnPlayerInit?
Discussion in 'Rust Development' started by Ghosst, Oct 2, 2015.
-
Wulf Community Admin
Nothing changed with the hook, but it may be the player is taking longer to be spawned in the game now.
-
Use OnPlayerSleepEnded() as you already are.
Edit:
LustyMap still works init, maybe worth looking into.Last edited by a moderator: Oct 2, 2015 -
I know some of the other UI stuff has changed, it seem like OnPlayerInit is called to early to be used to add UI's now.
If you use a timer to add the UI later (e.g. 10 seconds later, which is what I am currently doing in LustyMap), then it works, but this is a bit hit and miss as some clients may take longer than 10 seconds to load...
OnPlayerSleepEnded() is an ok workaround but you need to create some logic so that it only fires once per player per join.
I guess we need some kind of way to check when the client has finished activating and is ready to accept the UI, but this is where someone cleverer than me needs to step in...
[DOUBLEPOST=1443799693][/DOUBLEPOST]Been experimenting a little and best I have come up with so far is to check and wait until the ReceivingSnapshot flag for the player is false, then you seem to be able to send the UI.
Code:[HookMethod("OnPlayerInit")] void OnPlayerInit(BasePlayer player) { sendUI(player); } private void sendUI(BasePlayer player) { if (player.HasPlayerFlag(BasePlayer.PlayerFlags.ReceivingSnapshot)) { // Player still receiving snapshot, try again in a second... timer.In(1, () => sendUI(player)); } else { // Your UI code / method } }
Last edited by a moderator: Oct 2, 2015 -
Yeah that is a good solution i think. I tried a lots of variable/function in the BasePlayer/Connection but didn't find better than that.
-
What if the player gets disconnect before the timer kicks in? Like in rpc recieve texture error? maybe OnPlayerRespawned?
-
Wulf Community Admin
-
Just saying, 100% of the times a player gets connected then immediatly disconnected because of rpc recievetexture error (sign artist), the plugin starts throwing timer errors non stop, either until that player connects again, or i reload the infopanel plugin.
-
Wulf Community Admin
-