DWARF3
Veteran
Multiplayer Sound script
In general, If the server played sound, client can't hear that.
This script can play sound in a multiplayer game.
FEATURE
This script does not use the send_message_server command.(Except for the initial setting)
As a substitute, This script uses animation_finished trigger by scene_prop.
And, It can play plural sounds in the same trigger at the same time.(max: 4)
CODES
In general, If the server played sound, client can't hear that.
This script can play sound in a multiplayer game.
FEATURE
This script does not use the send_message_server command.(Except for the initial setting)
As a substitute, This script uses animation_finished trigger by scene_prop.
And, It can play plural sounds in the same trigger at the same time.(max: 4)
(multiplayer_is_server),
(call_script, "script_cf_sound_and_particle_helper", pos1, 7),
#pos1=play sound position
#7=sound_no(optional no)
#This script must run in the server side.
(call_script, "script_cf_sound_and_particle_helper", pos1, 7),
#pos1=play sound position
#7=sound_no(optional no)
#This script must run in the server side.
CODES
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
player_joined_trigger = (ti_server_player_joined, 0, 0,[(multiplayer_is_server)],
[
(store_trigger_param_1, ":player_no"),
(multiplayer_send_4_int_to_player, ":player_no", multiplayer_event_receive4_client1, "$g_sound_and_particle_helper_ins1", "$g_sound_and_particle_helper_ins2", "$g_sound_and_particle_helper_ins3", "$g_sound_and_particle_helper_ins4"),
(multiplayer_send_4_int_to_player, ":player_no", multiplayer_event_receive4_client2, "$g_sound_and_particle_helper_ins5", "$g_sound_and_particle_helper_ins6", "$g_sound_and_particle_helper_ins7", "$g_sound_and_particle_helper_ins8"),
])
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
initial_trigger = (0, 0.1, ti_once,[],
[
(assign, "$g_init_flag", 1),
(multiplayer_is_server),
(call_script, "script_cf_sound_and_particle_helper_init"),
])
#Please register trigger with each game mode.
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
player_joined_trigger = (ti_server_player_joined, 0, 0,[(multiplayer_is_server)],
[
(store_trigger_param_1, ":player_no"),
(multiplayer_send_4_int_to_player, ":player_no", multiplayer_event_receive4_client1, "$g_sound_and_particle_helper_ins1", "$g_sound_and_particle_helper_ins2", "$g_sound_and_particle_helper_ins3", "$g_sound_and_particle_helper_ins4"),
(multiplayer_send_4_int_to_player, ":player_no", multiplayer_event_receive4_client2, "$g_sound_and_particle_helper_ins5", "$g_sound_and_particle_helper_ins6", "$g_sound_and_particle_helper_ins7", "$g_sound_and_particle_helper_ins8"),
])
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
initial_trigger = (0, 0.1, ti_once,[],
[
(assign, "$g_init_flag", 1),
(multiplayer_is_server),
(call_script, "script_cf_sound_and_particle_helper_init"),
])
#Please register trigger with each game mode.
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------------------
#in "script_game_receive_network_message"
#client
(else_try),
(eq, ":event_type", multiplayer_event_admin_set_ban_voteable),
(try_begin),
(store_script_param, ":value", 3),
#validity check
(player_is_admin, ":player_no"),
(is_between, ":value", 0, 2),
#condition checks are done
(assign, "$g_multiplayer_ban_voteable", ":value"),
(get_max_players, ":num_players"),
(try_for_range, ":cur_player", 1, ":num_players"),
(player_is_active, ":cur_player"),
(multiplayer_send_int_to_player, ":cur_player", multiplayer_event_return_ban_voteable, ":value"),
(try_end),
(try_end),
#add_mod-----------------------------------------------------------------
(else_try),
(eq, ":event_type", multiplayer_event_receive4_client1),
(store_script_param, "$g_sound_and_particle_helper_ins1", 3),
(store_script_param, "$g_sound_and_particle_helper_ins2", 4),
(store_script_param, "$g_sound_and_particle_helper_ins3", 5),
(store_script_param, "$g_sound_and_particle_helper_ins4", 6),
(else_try),
(eq, ":event_type", multiplayer_event_receive4_client2),
(store_script_param, "$g_sound_and_particle_helper_ins5", 3),
(store_script_param, "$g_sound_and_particle_helper_ins6", 4),
(store_script_param, "$g_sound_and_particle_helper_ins7", 5),
(store_script_param, "$g_sound_and_particle_helper_ins8", 6),
#end_mod-----------------------------------------------------------------
#---------------------------------------------------------------------------------------------------------------
#add_script
# script_cf_sound_and_particle_helper_init
("cf_sound_and_particle_helper_init",
[
(multiplayer_is_server),
(init_position, pos0),
(position_set_x, pos0, 0),
(position_set_y, pos0, 0),
(position_set_z, pos0, 0),
(set_spawn_position, pos0),
(spawn_scene_prop, "spr_empty"),
(assign, "$g_sound_and_particle_helper_ins1", reg0),
(spawn_scene_prop, "spr_empty"),
(assign, "$g_sound_and_particle_helper_ins2", reg0),
(spawn_scene_prop, "spr_empty"),
(assign, "$g_sound_and_particle_helper_ins3", reg0),
(spawn_scene_prop, "spr_empty"),
(assign, "$g_sound_and_particle_helper_ins4", reg0),
(spawn_scene_prop, "spr_empty"),
(assign, "$g_sound_and_particle_helper_ins5", reg0),
(spawn_scene_prop, "spr_empty"),
(assign, "$g_sound_and_particle_helper_ins6", reg0),
(spawn_scene_prop, "spr_empty"),
(assign, "$g_sound_and_particle_helper_ins7", reg0),
(spawn_scene_prop, "spr_empty"),
(assign, "$g_sound_and_particle_helper_ins8", reg0),
]),
#---------------------------------------------------------------------------------------------------------------
#add_script
# script_cf_sound_and_particle_helper
("cf_sound_and_particle_helper",
[
(store_script_param_1, ":position"),
(store_script_param_2, ":sound_no"),
(copy_position, pos31, ":position"),
(assign, ":pos_z", ":sound_no",),
(init_position, pos30),
(position_set_x, pos30, 0),
(position_set_y, pos30, 0),
(position_set_z, pos30, ":pos_z"),
(prop_instance_is_animating, ":animating2", "$g_sound_and_particle_helper_ins2"),
(prop_instance_is_animating, ":animating4", "$g_sound_and_particle_helper_ins4"),
(prop_instance_is_animating, ":animating6", "$g_sound_and_particle_helper_ins6"),
(prop_instance_is_animating, ":animating8", "$g_sound_and_particle_helper_ins8"),
(try_begin),
(eq, ":animating2", 0),
(prop_instance_set_position, "$g_sound_and_particle_helper_ins1", pos30),
(prop_instance_animate_to_position, "$g_sound_and_particle_helper_ins2", pos31, 1),
(else_try),
(eq, ":animating4", 0),
(prop_instance_set_position, "$g_sound_and_particle_helper_ins3", pos30),
(prop_instance_animate_to_position, "$g_sound_and_particle_helper_ins4", pos31, 1),
(else_try),
(eq, ":animating6", 0),
(prop_instance_set_position, "$g_sound_and_particle_helper_ins5", pos30),
(prop_instance_animate_to_position, "$g_sound_and_particle_helper_ins6", pos31, 1),
(else_try),
(eq, ":animating8", 0),
(prop_instance_set_position, "$g_sound_and_particle_helper_ins7", pos30),
(prop_instance_animate_to_position, "$g_sound_and_particle_helper_ins8", pos31, 1),
(try_end),
]),
#---------------------------------------------------------------------------------------------------------------
#add_script
# script_cf_sound_and_particle_helper_client
("cf_sound_and_particle_helper_client",
[
(store_script_param_1, ":instance_no"),
(assign, ":true", 0),
(try_begin),
(eq, ":instance_no", "$g_sound_and_particle_helper_ins2"),
(prop_instance_get_position, pos0, "$g_sound_and_particle_helper_ins1"),
(prop_instance_get_position, pos1, "$g_sound_and_particle_helper_ins2"),
(assign, ":true", 1),
(else_try),
(eq, ":instance_no", "$g_sound_and_particle_helper_ins4"),
(prop_instance_get_position, pos0, "$g_sound_and_particle_helper_ins3"),
(prop_instance_get_position, pos1, "$g_sound_and_particle_helper_ins4"),
(assign, ":true", 1),
(else_try),
(eq, ":instance_no", "$g_sound_and_particle_helper_ins6"),
(prop_instance_get_position, pos0, "$g_sound_and_particle_helper_ins5"),
(prop_instance_get_position, pos1, "$g_sound_and_particle_helper_ins6"),
(assign, ":true", 1),
(else_try),
(eq, ":instance_no", "$g_sound_and_particle_helper_ins8"),
(prop_instance_get_position, pos0, "$g_sound_and_particle_helper_ins7"),
(prop_instance_get_position, pos1, "$g_sound_and_particle_helper_ins8"),
(assign, ":true", 1),
(try_end),
(eq, ":true", 1),
(try_begin),
(neg|multiplayer_is_server),
(set_fixed_point_multiplier, 100),
(try_end),
(position_get_z, ":effect_no", pos0),
(try_begin),
(eq, ":effect_no", 1),
(play_sound_at_position, "snd_sound1", pos1),
(else_try),
(eq, ":effect_no", 2),
(play_sound_at_position, "snd_sound2", pos1),
(else_try),
(eq, ":effect_no", 3),
(play_sound_at_position, "snd_sound3", pos1),
(else_try),
(eq, ":effect_no", 4),
(play_sound_at_position, "snd_sound4", pos1),
(else_try),
(eq, ":effect_no", 5),
(play_sound_at_position, "snd_sound5", pos1),
(else_try),
(eq, ":effect_no", 6),
(play_sound_at_position, "snd_sound6", pos1),
(else_try),
(eq, ":effect_no", 7),
(play_sound_at_position, "snd_sound7", pos1),
(else_try),
(eq, ":effect_no", ,
(play_sound_at_position, "snd_sound8", pos1),
(else_try),
(eq, ":effect_no", 9),
(play_sound_at_position, "snd_sound9", pos1),
(else_try),
(eq, ":effect_no", 10),
(play_sound_at_position, "snd_sound10", pos1),
(else_try),
(display_message, "@effect_no_error"),
(try_end),
#for_debug
(assign, reg0, ":effect_no"),
(display_message, "@effect_no: {reg0}"),
]),
#---------------------------------------------------------------------------------------------------------------
#in "script_game_receive_network_message"
#client
(else_try),
(eq, ":event_type", multiplayer_event_admin_set_ban_voteable),
(try_begin),
(store_script_param, ":value", 3),
#validity check
(player_is_admin, ":player_no"),
(is_between, ":value", 0, 2),
#condition checks are done
(assign, "$g_multiplayer_ban_voteable", ":value"),
(get_max_players, ":num_players"),
(try_for_range, ":cur_player", 1, ":num_players"),
(player_is_active, ":cur_player"),
(multiplayer_send_int_to_player, ":cur_player", multiplayer_event_return_ban_voteable, ":value"),
(try_end),
(try_end),
#add_mod-----------------------------------------------------------------
(else_try),
(eq, ":event_type", multiplayer_event_receive4_client1),
(store_script_param, "$g_sound_and_particle_helper_ins1", 3),
(store_script_param, "$g_sound_and_particle_helper_ins2", 4),
(store_script_param, "$g_sound_and_particle_helper_ins3", 5),
(store_script_param, "$g_sound_and_particle_helper_ins4", 6),
(else_try),
(eq, ":event_type", multiplayer_event_receive4_client2),
(store_script_param, "$g_sound_and_particle_helper_ins5", 3),
(store_script_param, "$g_sound_and_particle_helper_ins6", 4),
(store_script_param, "$g_sound_and_particle_helper_ins7", 5),
(store_script_param, "$g_sound_and_particle_helper_ins8", 6),
#end_mod-----------------------------------------------------------------
#---------------------------------------------------------------------------------------------------------------
#add_script
# script_cf_sound_and_particle_helper_init
("cf_sound_and_particle_helper_init",
[
(multiplayer_is_server),
(init_position, pos0),
(position_set_x, pos0, 0),
(position_set_y, pos0, 0),
(position_set_z, pos0, 0),
(set_spawn_position, pos0),
(spawn_scene_prop, "spr_empty"),
(assign, "$g_sound_and_particle_helper_ins1", reg0),
(spawn_scene_prop, "spr_empty"),
(assign, "$g_sound_and_particle_helper_ins2", reg0),
(spawn_scene_prop, "spr_empty"),
(assign, "$g_sound_and_particle_helper_ins3", reg0),
(spawn_scene_prop, "spr_empty"),
(assign, "$g_sound_and_particle_helper_ins4", reg0),
(spawn_scene_prop, "spr_empty"),
(assign, "$g_sound_and_particle_helper_ins5", reg0),
(spawn_scene_prop, "spr_empty"),
(assign, "$g_sound_and_particle_helper_ins6", reg0),
(spawn_scene_prop, "spr_empty"),
(assign, "$g_sound_and_particle_helper_ins7", reg0),
(spawn_scene_prop, "spr_empty"),
(assign, "$g_sound_and_particle_helper_ins8", reg0),
]),
#---------------------------------------------------------------------------------------------------------------
#add_script
# script_cf_sound_and_particle_helper
("cf_sound_and_particle_helper",
[
(store_script_param_1, ":position"),
(store_script_param_2, ":sound_no"),
(copy_position, pos31, ":position"),
(assign, ":pos_z", ":sound_no",),
(init_position, pos30),
(position_set_x, pos30, 0),
(position_set_y, pos30, 0),
(position_set_z, pos30, ":pos_z"),
(prop_instance_is_animating, ":animating2", "$g_sound_and_particle_helper_ins2"),
(prop_instance_is_animating, ":animating4", "$g_sound_and_particle_helper_ins4"),
(prop_instance_is_animating, ":animating6", "$g_sound_and_particle_helper_ins6"),
(prop_instance_is_animating, ":animating8", "$g_sound_and_particle_helper_ins8"),
(try_begin),
(eq, ":animating2", 0),
(prop_instance_set_position, "$g_sound_and_particle_helper_ins1", pos30),
(prop_instance_animate_to_position, "$g_sound_and_particle_helper_ins2", pos31, 1),
(else_try),
(eq, ":animating4", 0),
(prop_instance_set_position, "$g_sound_and_particle_helper_ins3", pos30),
(prop_instance_animate_to_position, "$g_sound_and_particle_helper_ins4", pos31, 1),
(else_try),
(eq, ":animating6", 0),
(prop_instance_set_position, "$g_sound_and_particle_helper_ins5", pos30),
(prop_instance_animate_to_position, "$g_sound_and_particle_helper_ins6", pos31, 1),
(else_try),
(eq, ":animating8", 0),
(prop_instance_set_position, "$g_sound_and_particle_helper_ins7", pos30),
(prop_instance_animate_to_position, "$g_sound_and_particle_helper_ins8", pos31, 1),
(try_end),
]),
#---------------------------------------------------------------------------------------------------------------
#add_script
# script_cf_sound_and_particle_helper_client
("cf_sound_and_particle_helper_client",
[
(store_script_param_1, ":instance_no"),
(assign, ":true", 0),
(try_begin),
(eq, ":instance_no", "$g_sound_and_particle_helper_ins2"),
(prop_instance_get_position, pos0, "$g_sound_and_particle_helper_ins1"),
(prop_instance_get_position, pos1, "$g_sound_and_particle_helper_ins2"),
(assign, ":true", 1),
(else_try),
(eq, ":instance_no", "$g_sound_and_particle_helper_ins4"),
(prop_instance_get_position, pos0, "$g_sound_and_particle_helper_ins3"),
(prop_instance_get_position, pos1, "$g_sound_and_particle_helper_ins4"),
(assign, ":true", 1),
(else_try),
(eq, ":instance_no", "$g_sound_and_particle_helper_ins6"),
(prop_instance_get_position, pos0, "$g_sound_and_particle_helper_ins5"),
(prop_instance_get_position, pos1, "$g_sound_and_particle_helper_ins6"),
(assign, ":true", 1),
(else_try),
(eq, ":instance_no", "$g_sound_and_particle_helper_ins8"),
(prop_instance_get_position, pos0, "$g_sound_and_particle_helper_ins7"),
(prop_instance_get_position, pos1, "$g_sound_and_particle_helper_ins8"),
(assign, ":true", 1),
(try_end),
(eq, ":true", 1),
(try_begin),
(neg|multiplayer_is_server),
(set_fixed_point_multiplier, 100),
(try_end),
(position_get_z, ":effect_no", pos0),
(try_begin),
(eq, ":effect_no", 1),
(play_sound_at_position, "snd_sound1", pos1),
(else_try),
(eq, ":effect_no", 2),
(play_sound_at_position, "snd_sound2", pos1),
(else_try),
(eq, ":effect_no", 3),
(play_sound_at_position, "snd_sound3", pos1),
(else_try),
(eq, ":effect_no", 4),
(play_sound_at_position, "snd_sound4", pos1),
(else_try),
(eq, ":effect_no", 5),
(play_sound_at_position, "snd_sound5", pos1),
(else_try),
(eq, ":effect_no", 6),
(play_sound_at_position, "snd_sound6", pos1),
(else_try),
(eq, ":effect_no", 7),
(play_sound_at_position, "snd_sound7", pos1),
(else_try),
(eq, ":effect_no", ,
(play_sound_at_position, "snd_sound8", pos1),
(else_try),
(eq, ":effect_no", 9),
(play_sound_at_position, "snd_sound9", pos1),
(else_try),
(eq, ":effect_no", 10),
(play_sound_at_position, "snd_sound10", pos1),
(else_try),
(display_message, "@effect_no_error"),
(try_end),
#for_debug
(assign, reg0, ":effect_no"),
(display_message, "@effect_no: {reg0}"),
]),
#---------------------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------------------
#("empty", 0, "0", "0", []),
#add_mod--------------------------------------------------------------------------------
("empty",0,"0","0",
[
(ti_on_scene_prop_animation_finished,
[
(neg|multiplayer_is_dedicated_server),
(eq, "$g_init_flag", 1),
(store_trigger_param_1, ":instance_no"),
(call_script, "script_cf_sound_and_particle_helper_client", ":instance_no"),
]),
]),
#When a client logs in, "$g_init_flag" prevents animation_finished trigger from running accidentally.
#end_mod--------------------------------------------------------------------------------
#("empty", 0, "0", "0", []),
#add_mod--------------------------------------------------------------------------------
("empty",0,"0","0",
[
(ti_on_scene_prop_animation_finished,
[
(neg|multiplayer_is_dedicated_server),
(eq, "$g_init_flag", 1),
(store_trigger_param_1, ":instance_no"),
(call_script, "script_cf_sound_and_particle_helper_client", ":instance_no"),
]),
]),
#When a client logs in, "$g_init_flag" prevents animation_finished trigger from running accidentally.
#end_mod--------------------------------------------------------------------------------
#server events
multiplayer_event_return_friendly_fire_damage_self_ratio = 100
multiplayer_event_return_friendly_fire_damage_friend_ratio = 101
multiplayer_event_return_allow_player_banners = 102
multiplayer_event_return_force_default_armor = 103
multiplayer_event_return_anti_cheat = 104
multiplayer_event_return_open_game_rules = 105
multiplayer_event_return_max_num_bots = 106
multiplayer_event_return_server_mission_timer_while_player_joined = 107
multiplayer_event_show_duel_request = 108
multiplayer_event_start_duel = 109
multiplayer_event_cancel_duel = 110
multiplayer_event_show_server_message = 111
multiplayer_event_return_disallow_ranged_weapons = 112
#add_mod------------------------------------------------------------
multiplayer_event_receive4_client1 = 113
multiplayer_event_receive4_client2 = 114
#end_mod------------------------------------------------------------
multiplayer_event_return_friendly_fire_damage_self_ratio = 100
multiplayer_event_return_friendly_fire_damage_friend_ratio = 101
multiplayer_event_return_allow_player_banners = 102
multiplayer_event_return_force_default_armor = 103
multiplayer_event_return_anti_cheat = 104
multiplayer_event_return_open_game_rules = 105
multiplayer_event_return_max_num_bots = 106
multiplayer_event_return_server_mission_timer_while_player_joined = 107
multiplayer_event_show_duel_request = 108
multiplayer_event_start_duel = 109
multiplayer_event_cancel_duel = 110
multiplayer_event_show_server_message = 111
multiplayer_event_return_disallow_ranged_weapons = 112
#add_mod------------------------------------------------------------
multiplayer_event_receive4_client1 = 113
multiplayer_event_receive4_client2 = 114
#end_mod------------------------------------------------------------