Template:Op multiplayer and networking

Multiplayer and networking
This section is eagerly waiting for someone to write documentation comments.

Conditional operations
player_is_active = 401
 * (player_is_active, ),
 * Checks that the specified player is active (i.e. connected to server). Players are assigned a free ID after connection and on disconnection it becomes free/invalid until taken by another connecting player.

multiplayer_is_server = 417
 * (multiplayer_is_server),
 * Checks that the code is running on multiplayer server. Operation will fail on client machines or in singleplayer mode. This will succeed for listen and dedicated servers and will only fail on clients.

multiplayer_is_dedicated_server = 418
 * (multiplayer_is_dedicated_server),
 * Checks that the game running is a dedicated server. This will only succeed for dedicated servers and will fail on listen servers and clients.

game_in_multiplayer_mode = 419
 * (game_in_multiplayer_mode),
 * Checks that the game is running in multiplayer mode.

player_is_admin = 430
 * (player_is_admin, ),
 * Checks that the player used the admin password to join the server.

player_is_busy_with_menus = 438
 * (player_is_busy_with_menus, ),
 * This one is used when a player presses a hotkey like TAB or ESC to check if he doesn't have any kind of presentation open, however, it works strangely and is almost always acompannied by some sort of (neg|is_presentation_active, "prst"), in native.
 * Research: Is actually not getting used together with (neg|is_presentation_active, "prst"). It is getting called on the server and isn't synched with clients. Used in multiplayer to prevent the spawning of a player agent if the player is still busy with the menus (and might still change the loadout of the agent).

player_item_slot_is_picked_up = 461
 * (player_item_slot_is_picked_up, , ),
 * Checks that the provided item slot for the referenced player was picked up from the battlefield instead of bought.

Player slot operations
player_set_slot = 508
 * (player_set_slot, , , ),

player_get_slot = 528
 * (player_get_slot,, , ),

player_slot_eq = 548
 * (player_slot_eq, , , ),

player_slot_ge = 568
 * (player_slot_ge, , , ),

Network communication operations
send_message_to_url = 380
 * (send_message_to_url, , ),
 * Sends an HTTP request. Response from that URL will be returned to "script_game_receive_url_response". Parameter  is optional and effects are unclear. Supposedly it's equivalent of calling (str_encode_url) on the first parameter which doesn't make sense for me.

multiplayer_send_message_to_server = 388
 * (multiplayer_send_message_to_server, <message_type>),
 * Multiplayer client operation. Send a simple message (only message code, no data) to game server.

multiplayer_send_int_to_server = 389
 * (multiplayer_send_int_to_server, <message_type>, ),
 * Multiplayer client operation. Send a message with a single extra integer value to game server.

multiplayer_send_2_int_to_server = 390
 * (multiplayer_send_2_int_to_server, <message_type>,, ),
 * Same as (multiplayer_send_int_to_server), but two integer values are sent.

multiplayer_send_3_int_to_server = 391
 * (multiplayer_send_3_int_to_server, <message_type>,, , ),
 * Same as (multiplayer_send_int_to_server), but three integer values are sent.

multiplayer_send_4_int_to_server = 392
 * (multiplayer_send_4_int_to_server, <message_type>,, , , ),
 * Same as (multiplayer_send_int_to_server), but four integer values are sent.

multiplayer_send_string_to_server = 393
 * (multiplayer_send_string_to_server, <message_type>, <string_id>),
 * Multiplayer client operation. Send a message with a string value to game server.

<message_type> parameter must be between 0 and 127 or it will be truncated. In the case of Native they can be found on header_common.py as client and server events.

These are handled in script_game_receive_network_message and are used for server events. As for strings, the input is s0 (in the script).

The other 6 operations (multiplayer_send_*_to_player) have the same functionality but are called on the server and send the message to the player referenced by <player_id>. Also handled by script_game_receive_network_message.

multiplayer_send_message_to_player = 394
 * (multiplayer_send_message_to_player, <player_id>, <message_type>),
 * Multiplayer server operation. Send a simple message (only message code, no data) to one of connected players.

multiplayer_send_int_to_player = 395
 * (multiplayer_send_int_to_player, <player_id>, <message_type>, ),
 * Multiplayer server operation. Send a message with a single extra integer value to one of connected players.

multiplayer_send_2_int_to_player = 396
 * (multiplayer_send_2_int_to_player, <player_id>, <message_type>,, ),
 * Same as (multiplayer_send_int_to_player), but two integer values are sent.

multiplayer_send_3_int_to_player = 397
 * (multiplayer_send_3_int_to_player, <player_id>, <message_type>,, , ),
 * Same as (multiplayer_send_int_to_player), but three integer values are sent.

multiplayer_send_4_int_to_player = 398
 * (multiplayer_send_4_int_to_player, <player_id>, <message_type>,, , , ),
 * Same as (multiplayer_send_int_to_player), but four integer values are sent.

multiplayer_send_string_to_player = 399
 * (multiplayer_send_string_to_player, <player_id>, <message_type>, <string_id>),
 * Multiplayer server operation. Send a message with a string value to one of connected players.

Player handling operations
get_max_players = 400
 * (get_max_players, ),
 * Returns maximum possible number of connected players. Apparently always returns a constant value, however it's return value can change as maximum increases with new patches.

player_get_team_no = 402
 * (player_get_team_no,, <player_id>),
 * Retrieves the team that the player belongs to.

player_set_team_no = 403
 * (player_set_team_no, <player_id>, <team_id>),
 * Assigns a player to the specified team.

player_get_troop_id = 404
 * (player_get_troop_id,, <player_id>),
 * Retrieves player's selected troop reference.

player_set_troop_id = 405
 * (player_set_troop_id, <player_id>, <troop_id>),
 * Assigns the selected troop reference to a player.

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

agent_get_player_id = 1724
 * (agent_get_player_id,, <agent_id>),
 * Retrieves player reference that is currently controlling the specified agent.

player_get_gold = 407
 * (player_get_gold,, <player_id>),
 * Retrieves player's current gold amount.

player_set_gold = 408
 * (player_set_gold, <player_id>,, <max_value>),
 * Sets player's new gold amount and maximum allowed gold amount. Use 0 for <max_value> to remove gold limit.

player_spawn_new_agent = 409
 * (player_spawn_new_agent, <player_id>, <entry_point>),
 * Spawns a new agent for the specified player. Essentially a combination of (spawn_agent) and (player_control_agent) operations.

player_add_spawn_item = 410
 * (player_add_spawn_item, <player_id>, <item_slot_no>, <item_id>),
 * Adds the specified item to the specified player. Will take effect after the next player_spawn_new_agent. Available item slots are: ek_item_0, ek_item_1, ek_item_2, ek_item_3, ek_head, ek_body, ek_foot, ek_gloves, ek_horse. Unsure if ek_food is used in multiplayer; Taken from header_items.py

multiplayer_get_my_team = 411
 * (multiplayer_get_my_team, ),
 * Client operation. Retrieves player's currently selected team.

multiplayer_get_my_troop = 412
 * (multiplayer_get_my_troop, ),
 * Client operation. Retrieves player's currently selected troop.

multiplayer_set_my_troop = 413
 * (multiplayer_set_my_troop, ),
 * Client operation. Selects a new troop for the player.

multiplayer_get_my_gold = 414
 * (multiplayer_get_my_gold, ),
 * Client operation. Retrieves current player's gold amount.

multiplayer_get_my_player = 415
 * (multiplayer_get_my_player, ),
 * Client operation. Retrieves current player's player_id reference.

multiplayer_make_everyone_enemy = 420
 * (multiplayer_make_everyone_enemy),
 * Used in deathmatch mode to make everyone hostile to all other agents.

player_control_agent = 421
 * (player_control_agent, <player_id>, <agent_id>),
 * Server operation. Puts the agent under specified player's control. Operation will change agent's face code and banner to those of player.

player_get_item_id = 422
 * (player_get_item_id,, <player_id>, <item_slot_no>),
 * Server operation. Retrieves item that's currently equipped by specified player in <item_slot_no> equipment slot.

player_get_banner_id = 423
 * (player_get_banner_id,, <player_id>),
 * Server operation. Retrieves banner_id reference used by the specified player. Note that in MP banners are enumerated starting from 0 (unlike single-player where they're enumeration depends on scene prop banners' reference range).

player_set_is_admin = 429
 * (player_set_is_admin, <player_id>, ),
 * Server operation. Set the current player as admin (value = 1) or not (value = 0).

player_get_score = 431 player_set_score = 432 player_get_kill_count = 433 player_set_kill_count = 434 player_get_death_count = 435 player_set_death_count = 436 player_get_ping = 437 player_get_is_muted = 439
 * (player_get_score,, <player_id>),
 * (player_set_score, <player_id>, ),
 * (player_get_kill_count,, <player_id>),
 * (player_set_kill_count, <player_id>, ),
 * (player_get_death_count,, <player_id>),
 * (player_set_death_count, <player_id>, ),
 * (player_get_ping,, <player_id>),
 * (player_get_is_muted,, <player_id>),
 * Sets if a player gets muted (1) or unmuted (0). mute_for_everyone is an optional parameter and should be set to 1 if player is muted for everyone (this works only on server).

player_set_is_muted = 440
 * (player_set_is_muted, <player_id>,, [mute_for_everyone]),
 * Sets if a player gets muted (1) or unmuted (0). mute_for_everyone is an optional parameter and should be set to 1 if player is muted for everyone (this works only on server).

player_get_unique_id = 441
 * (player_get_unique_id,, <player_id>),:can only bew used on server side
 * Server operation. Retrieves player's unique identifier which is determined by player's game license code. This number is supposed to be unique for each license, allowing reliable player identification across servers.

player_get_gender = 442
 * (player_get_gender,, <player_id>),
 * Gets the current player gender/skin, in Native 0 for the male and 1 for the female skin. Take note that Native can only process two genders/skins in multiplayer.

player_save_picked_up_items_for_next_spawn = 459 player_get_value_of_original_items = 460
 * (player_save_picked_up_items_for_next_spawn, <player_id>),
 * (player_get_value_of_original_items, <player_id>),
 * Undocumented. Official docs: this operation returns values of the items, but default troop items will be counted as zero (except horse)

profile_get_banner_id = 350
 * (profile_get_banner_id, ),
 * Client operation. Retrieves banner_id reference used by the game for multiplayer. Note that in MP banners are enumerated starting from 0 (unlike single-player where they're enumeration depends on scene prop banners' reference range).

profile_set_banner_id = 351
 * (profile_set_banner_id, ),
 * Client operation. Assigns a new banner_id to be used for multiplayer. Note that in MP banners are enumerated starting from 0 (unlike single-player where they're enumeration depends on scene prop banners' reference range).

Team handling operations
team_get_bot_kill_count = 450 team_set_bot_kill_count = 451 team_get_bot_death_count = 452 team_set_bot_death_count = 453 team_get_kill_count = 454 team_get_score = 455 team_set_score = 456 team_set_faction = 457 team_get_faction = 458
 * (team_get_bot_kill_count,, <team_id>),
 * (team_get_bot_kill_count,, <team_id>),
 * (team_get_bot_death_count,, <team_id>),
 * (team_get_bot_death_count,, <team_id>),
 * (team_get_kill_count,, <team_id>),
 * (team_get_score,, <team_id>),
 * (team_set_score, <team_id>, ),
 * (team_set_faction, <team_id>, <faction_id>),
 * (team_get_faction,, <team_id>),

General scene and mission handling operations
multiplayer_clear_scene = 416 multiplayer_find_spawn_point = 425
 * (multiplayer_clear_scene),
 * (multiplayer_find_spawn_point,, <team_no>, <examine_all_spawn_points>, <is_horseman>),

set_spawn_effector_scene_prop_kind, set_spawn_effector_scene_prop_id - this two are used in capture the flag and similar game modes to make players of a certain team tend to spawn nearer to those scene props

set_spawn_effector_scene_prop_kind = 426
 * (set_spawn_effector_scene_prop_kind, <team_no>, <scene_prop_kind_no>),
 * Specifies some scene prop kind as one of the teams' spawn effector, making players of that team more likely to spawn closer to the specified effector prop instances. Use -1 to disable spawn effector for a team.

set_spawn_effector_scene_prop_id = 427
 * (set_spawn_effector_scene_prop_id, <team_no>, <scene_prop_id>),
 * Specifies a single prop instance as a team's spawn effector. Different from (set_spawn_effector_scene_prop_kind) as other instances of the same scene prop will not affect player spawning.

start_multiplayer_mission = 470
 * (start_multiplayer_mission, <mission_template_id>, <scene_id>, <started_manually>),

Administrative operations and settings
kick_player = 465 ban_player = 466
 * (kick_player, <player_id>),
 * (ban_player, <player_id>,, <player_id>),
 * Official docs: set value = 1 for banning temporarily, assign 2nd player id as the administrator player id if banning is permanent
 * Those values are saved into a text file

save_ban_info_of_player = 467 ban_player_using_saved_ban_info = 468
 * (save_ban_info_of_player, <player_id>),
 * (ban_player_using_saved_ban_info),

server_add_message_to_log = 473
 * (server_add_message_to_log, <string_id>),

server_get_renaming_server_allowed, server_get_changing_game_type_allowed - both of these get the values for dedicated servers which have commands to run on the console to (dis)allowing them

server_get_renaming_server_allowed = 475
 * (server_get_renaming_server_allowed, ),
 * Official docs: 0-1

server_get_changing_game_type_allowed = 476
 * (server_get_changing_game_type_allowed, ),
 * Official docs: 0-1

server_get_combat_speed = 478
 * (server_get_combat_speed, ),
 * Official docs: 0-2

server_set_combat_speed = 479
 * (server_set_combat_speed, ),
 * Official docs: 0-2
 * Unofficial: is actually 0-4, going from slowest to fastest, you can see it's used in module_presentations from 0 to 4

server_get_friendly_fire = 480
 * (server_get_friendly_fire, ),
 * Gets if friendly fire is enabled (1) or not (0).

server_set_friendly_fire = 481
 * (server_set_friendly_fire, ),
 * Official docs: 0 = off, 1 = on

server_get_control_block_dir = 482
 * (server_get_control_block_dir, ),
 * Gets if control block direction at the server are 'automatic' (0) or 'by mouse movement' (1).

server_set_control_block_dir = 483
 * (server_set_control_block_dir, ),
 * Official docs: 0 = automatic, 1 = by mouse movement

server_set_password = 484 server_get_add_to_game_servers_list = 485
 * (server_set_password, <string_id>),
 * (server_get_add_to_game_servers_list, ),
 * Gets if server is added to game servers list (1) or not (0).

server_set_add_to_game_servers_list = 486
 * (server_set_add_to_game_servers_list, ),
 * Sets if server is added to game servers list (1) or not (0).

server_get_ghost_mode = 487
 * (server_get_ghost_mode, ),
 * Gets if dead players are allowed to move their camera freely (0), sticked to any player (1), sticked to team members (2), sticked to team members' view (3).

server_set_ghost_mode = 488
 * (server_set_ghost_mode, ),
 * Sets if dead players are allowed to move their camera freely (0), sticked to any player (1), sticked to team members (2), sticked to team members' view (3).

server_set_name = 489 server_get_max_num_players = 490 server_set_max_num_players = 491 server_set_welcome_message = 492 server_get_melee_friendly_fire = 493
 * (server_set_name, <string_id>),
 * (server_get_max_num_players, ),
 * (server_set_max_num_players, ),
 * (server_set_welcome_message, <string_id>),
 * (server_get_melee_friendly_fire, ),
 * Gets if melee friendly fire is enabled (1) or not (0).

server_set_melee_friendly_fire = 494
 * (server_set_melee_friendly_fire, ),
 * Official docs: 0 = off, 1 = on

server_get_friendly_fire_damage_self_ratio = 495
 * (server_get_friendly_fire_damage_self_ratio, ),
 * Gets the percentage of damage received by self when player hits a friend (0-100).

server_set_friendly_fire_damage_self_ratio = 496
 * (server_set_friendly_fire_damage_self_ratio, ),
 * Official docs: 0-100
 * Sets the percentage of damage received by self when player hits a friend (0-100).

server_get_friendly_fire_damage_friend_ratio = 497
 * (server_get_friendly_fire_damage_friend_ratio, ),
 * Gets the percentage of damage received by friend when player hits a friend (0-100).

server_set_friendly_fire_damage_friend_ratio = 498
 * (server_set_friendly_fire_damage_friend_ratio, ),
 * Sets the percentage of damage received by friend when player hits a friend (0-100).

server_get_anti_cheat = 499
 * (server_get_anti_cheat, ),
 * Gets if valve anti cheat is enabled (1) or not (0).

server_set_anti_cheat = 477
 * (server_set_anti_cheat, ),
 * Sets if valve anti cheat is enabled (1) or not (0).