FurryEskimo Posted March 25, 2022 Share Posted March 25, 2022 We already have code to detect when the player is typing in the chat, but do we know how to detect when the player is using the crafting menu? Link to comment https://forums.kleientertainment.com/forums/topic/138563-code-to-detect-when-player-is-typing-in-the-crafting-menu/ Share on other sites More sharing options...
FurryEskimo Posted March 25, 2022 Author Share Posted March 25, 2022 Phew, got it! Big thanks to Vyuri who's hard work found a solution! I made a few small edits, but this worked perfectly! local playercontroller = ThePlayer.components.playercontroller local v1, v2 = playercontroller:IsEnabled() --"Gives two values, the 2nd value being False means you're using the crafting search bar." if playercontroller and v2 == false then --Don't allow toggle if player is using crafting menu. return end 1 Link to comment https://forums.kleientertainment.com/forums/topic/138563-code-to-detect-when-player-is-typing-in-the-crafting-menu/#findComment-1551951 Share on other sites More sharing options...
FurryEskimo Posted March 28, 2022 Author Share Posted March 28, 2022 So it appears there’s an issue.. When the player is on the character select screen and pressed the key, ThePlayer is called but it crashes the server.. I’ve tried a few ways to fix this but nothing’s worked yet. Does anyone have a suggestion? Link to comment https://forums.kleientertainment.com/forums/topic/138563-code-to-detect-when-player-is-typing-in-the-crafting-menu/#findComment-1553104 Share on other sites More sharing options...
FurryEskimo Posted March 29, 2022 Author Share Posted March 29, 2022 (edited) We got it working. Turns out I made a typo and it wasn't working even though the code was right. AddModRPCHandler(modname,"ToogleSwimming",ToogleSwimming) GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.key_to_swim, function() --Recoded with IronHunter's help. if not GLOBAL.ThePlayer or GLOBAL.ThePlayer.prefab ~= "wildchild" or GLOBAL.TheFrontEnd:GetActiveScreen() ~= GLOBAL.ThePlayer.HUD then --Prevents toggle being used by other players and on character select screen. return end --Now that we can confirm that ThePlayer isn't nil we can attempt to run the player controller code local playercontroller = ThePlayer.components.playercontroller if playercontroller then local v1, v2 = playercontroller:IsEnabled() --"Gives two values, the 2nd value being False means you're using the crafting search bar." if v2 == false then --Don't allow toggle if player is using crafting search menu. return end end --[[ if ThePlayer.HUD ~= nil and ThePlayer.HUD:IsCraftingOpen() then --Do not toggle ability if crafting menu is open. return end --]] if GLOBAL.ThePlayer then SendModRPCToServer(MOD_RPC[modname]["ToogleSwimming"]) end end) Edited March 29, 2022 by FurryEskimo 1 Link to comment https://forums.kleientertainment.com/forums/topic/138563-code-to-detect-when-player-is-typing-in-the-crafting-menu/#findComment-1553442 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now