Narrator Posted March 21, 2020 Share Posted March 21, 2020 (edited) Hi. I'm thinking about the creation of a mod for our roleplay PZ server : an icon showing on the character while its player is typing something in local chat. Being aware that another player is currently typing could be very useful on a roleplay server. I'm looking for solutions, as no Lua event is linked to this specific situation. As for now, I have tried to simply capture the "OnKeyPressed" event for the "Return" key (I know it's not either an elegant or a pro approach as keybinding could change.) But I can't even manage to capture the event... Is the return key out of "OnKeyPressed" range ? What am I doing wrong ? My current test is : -- If player(0) press "ENTER" key, log it and say it local function typingIconShow(_keyPressed) local key = _keyPressed; -- Store the parameter in a local variable. print(key); -- Prints the pressed key to the console. -- We test if the correct key is pressed. local player = getSpecificPlayer(0); if key == 13 then print('TYPINGICON MOD - RETURN key hit !'); player:Say("I press the RETURN key !"); else print('TYPINGICON MOD - '..key..' key hit !'); player:Say("I press the "..key.." key !"); end end -- Register the function to key pressed event Events.OnKeyPressed.Add(typingIconShow); Current results : the mod is loaded, but no output, nor in game nor in the console (I tested it by hosting a test multiplayer game). I'm also wondering... How to get the "typing icon" to appear on other players' client ? I mean, which mechanic should I use to place a small icon on the typing player character and make it visible for every other players ? Does anyone can help me please ? Edited March 22, 2020 by Narrator Link to comment Share on other sites More sharing options...
Neanderthal Posted March 25, 2020 Share Posted March 25, 2020 Maybe you can utilize something from the mechanic for the PvP toggle which puts a skull above the head when they toggle PvP, not sure if that helps, hope someone makes a mod of this sort though. Link to comment Share on other sites More sharing options...
Narrator Posted March 25, 2020 Author Share Posted March 25, 2020 Thank you for your answer. I was thinking of the PvP skull, but didn't find its mechanics yet in the source. As I struggle with the simple test I mentionned above, for a reason I don't understand (I followed working source code from the community), I'm still stuck. 😕 Link to comment Share on other sites More sharing options...
avensis Posted April 14, 2020 Share Posted April 14, 2020 (edited) Hi, did you manage to find the solution ? Edited July 25, 2022 by avensis Link to comment Share on other sites More sharing options...
Narrator Posted May 13, 2020 Author Share Posted May 13, 2020 Not at all. I could not find any sources nor get any helping answer. 😕 Link to comment Share on other sites More sharing options...
Aiteron Posted August 23, 2020 Share Posted August 23, 2020 (edited) Hi Your problem - local before function is unnecessary. Function for trigger by Event must be global correct code: -- If player(0) press "ENTER" key, log it and say it function typingIconShow(_keyPressed) local key = _keyPressed; ........... Edited August 23, 2020 by Aiteron Link to comment 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