Jump to content

[MP][RP] typing icon mod


Narrator

Recommended Posts

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 by Narrator
Link to comment
Share on other sites

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

  • 3 weeks later...
  • 5 weeks later...
  • 3 months later...

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 by Aiteron
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...