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 ?