Author Topic: Custom Keys; Directional Keys  (Read 681 times)

0 Members and 1 Guest are viewing this topic.

Offline pete99

  • First Sergeant
  • *
  • Posts: 70
  • Gang Warily
    • View Profile
  • Nick: Drummond
  • Side: Confederacy
Custom Keys; Directional Keys
« on: May 07, 2018, 03:16:11 pm »
I have been looking into using the custom keys script in Napoleonic Wars to trigger a particular animation in game. However, while it works when the game is simply in multiplayer mode, it doesn't seem to work on my server.

I tried using the same .txt files for server and client side, but it still doesn't work. Here is an example of the type of code I am using:
             (else_try),
            (eq, ":action_type", player_action_key_down_held),       
(get_player_agent_no, ":player_agent"),
(agent_set_animation, ":player_agent", "anim_unused_human_anim_64", 0),
           #   (multiplayer_send_string_to_player, ":player_no", multiplayer_event_return_admin_chat, "@DOWN"), 

Are these custom keys unusable on a hosted server, or is there something I have missed or need to change/add?

Online Caesim

  • Sergeant Major
  • *
  • Posts: 19
  • With the edge of the sword.
    • View Profile
  • Nick: Caesim
  • Side: Neutral
Re: Custom Keys; Directional Keys
« Reply #1 on: May 07, 2018, 06:35:58 pm »
Make sure you have actually enabled it in module_scripts.

Code
      (assign, "$g_enable_custom_directional_keys", 0), #set to 1 to enable custom actions on directional keys

Offline pete99

  • First Sergeant
  • *
  • Posts: 70
  • Gang Warily
    • View Profile
  • Nick: Drummond
  • Side: Confederacy
Re: Custom Keys; Directional Keys
« Reply #2 on: May 07, 2018, 11:29:56 pm »
yep did that

Offline pete99

  • First Sergeant
  • *
  • Posts: 70
  • Gang Warily
    • View Profile
  • Nick: Drummond
  • Side: Confederacy
Re: Custom Keys; Directional Keys
« Reply #3 on: May 07, 2018, 11:44:42 pm »
Noticed in mission templates it says this:

# To enable, set mod_variable_custom_direction_keys to 1 in module_scripts.py and send to players

Is there some way I am meant to send it to players, or is this automatic?

It also says this:

multiplayer_client_custom_directional_keys = (
  0, 0, 0.25, [
  (neg|multiplayer_is_dedicated_server),

Since it doesn't have (multiplayer_is_server), could this explain why it doesn't work on my server?
« Last Edit: May 07, 2018, 11:47:34 pm by pete99 »

Online Caesim

  • Sergeant Major
  • *
  • Posts: 19
  • With the edge of the sword.
    • View Profile
  • Nick: Caesim
  • Side: Neutral
Re: Custom Keys; Directional Keys
« Reply #4 on: May 08, 2018, 10:33:41 am »
As you can see its only for singleplayer

Code
get_player_agent_no                      = 1700  # (get_player_agent_no, <destination>),
                                                 # Retrieves the reference to the player-controlled agent. Singleplayer mode only.

Use the following instead

Code
player_get_agent_id                          =  406  # (player_get_agent_id, <destination>, <player_id>),
                                                     # Retrieves player's current agent reference. Returns a negative value if player has no agent.

I suggest you use this for reference: https://forums.taleworlds.com/index.php/topic,213060.0.html

Offline pete99

  • First Sergeant
  • *
  • Posts: 70
  • Gang Warily
    • View Profile
  • Nick: Drummond
  • Side: Confederacy
Re: Custom Keys; Directional Keys
« Reply #5 on: May 08, 2018, 10:36:43 am »
Just found this myself too, thanks!