Jump to content

Recommended Posts

Posted (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 by Narrator

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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. 😕

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...