~~NOTOC~~ ====== openUIView ====== [[developer_center:developer_editor:script:ui_event|From Customui Class]] Player:openUIView(playerid ,uiid) **API description** The main function of this method: open a UI interface for Player ^ Parameters ^ Types ^ Info ^ | playerid | number | player ID | | uiid | string | the ID of interface | ^ Return ^ value ^ type ^ | Error Code 0 is Success | 0 or 1001 | number | ==== Examples ==== --When a player enters the game, execute this function local function player_enter(event) local uin=event.eventobjid--The mini account of the player entering the game local uiid="6986982063319417057"--The interface id to be opened, replace your UIid here Player:openUIView(uin,uiid)--Open the interface for the player end -- Register Event for Game.AnyPlayer.EnterGame ScriptSupportEvent:registerEvent([=[Game.AnyPlayer.EnterGame]=],player_enter) ==== Lua Code Explanation: Player Enter Event Handler ==== This Lua code executes when any player enters the game, opening a specific UI interface for them. === Function Definition === local function player_enter(event) * Declares a function named **player_enter** that triggers when the event occurs * The **event** parameter contains game event data === Getting Player ID === local uin=event.eventobjid * Extracts the **player's account identifier** from the event object * **uin** stores which player entered the game === UI Configuration === local uiid="6986982063319417057" * Defines the **interface ID** of the UI to display * **Important**: Replace this with your actual UI ID (placeholder shown) === Opening the Interface === Player:openUIView(uin,uiid) * Calls the game's **Player API** to display a UI to the specific player * Parameters: * **uin** → Target player's account ID * **uiid** → Interface to display === Event Registration === ScriptSupportEvent:registerEvent([=[Game.AnyPlayer.EnterGame]=],player_enter) * Registers the **player_enter** function to handle **Game.AnyPlayer.EnterGame** events * Event details: * **[=[Game.AnyPlayer.EnterGame]=]** → Triggers for all players joining * **player_enter** → Handler function name === Educational Notes === Key concepts demonstrated: * **Player lifecycle events** (detecting game entry) * **UI management** (opening interfaces) * **Game API usage** (Player methods) * **Event parameter handling** (extracting player ID) **Result**: Every player sees your specified UI when joining the game. === Important Note === Remember to: * Replace **6986982063319417057** with your actual UI ID * Ensure the UI resource is properly loaded in your game