Multiplayer message to players?

Users who are viewing this thread

I am trying to create a code that sends a message to all players on my server. I have created this code:

                (try_for_players, ":player_no", 1),
                (player_is_active, ":player_no"),
                (multiplayer_send_string_to_player, ":player_no", multiplayer_event_return_admin_chat, "@test message"),

This appears to work fine, other than that it only seems to send the message to one player. Does anyone know what I have done wrong, or need to do to get a message to be sent to all the players in the server?
Thanks.
 
Show off the entire script, trigger, whatever.

Posting just 3 lines of code isn't gonna tell much about it's functionality, especially if there's just an incomplete try-block.
 
Here is the full trigger:

(1, 0, ti_after_mission_start, [
(multiplayer_is_server),
                (eq, "$g_round_ended", 0),
                (store_mission_timer_a, ":current_time"),
                (store_sub, ":seconds_past_in_round", ":current_time", "$g_round_start_time"),
                (eq, ":seconds_past_in_round", 4),
                (neq, ":seconds_past_in_round", "$g_multiplayer_round_max_seconds"),
                (try_for_players, ":player_no", 1),
                (player_is_active, ":player_no"),
                (multiplayer_send_string_to_player, ":player_no", multiplayer_event_return_admin_chat, "@test message"),
                ],
      [ ]),
 
As I expected you didn't close the try-block.
Code:
(try_for_players, ":player_no", 1),
	(multiplayer_send_string_to_player, ":player_no", multiplayer_event_return_admin_chat, "@test message"),
(try_end),
Players within the try_for_players loop are always active, no need to check for it.
 
I have run into an issue, where it appears the message keeps spamming. To the players it shows up just once, but after pressing L in game I can see it has been sending a lot of times: e.g.

test message
test message
test message
test message
and so on.....
This appears to be making it impossible to send normal chat messages in game. Do you have any idea how I could fix this?
 
Code:
(1, 0, ti_after_mission_start,

to

Code:
(ti_after_mission_start,0,ti_once,

read the trigger comments to understand what is means
Code:
####################################################################################################################
#   Each mission-template is a tuple that contains the following fields:
#  1) Mission-template id (string): used for referencing mission-templates in other files.
#     The prefix mt_ is automatically added before each mission-template id
#
#  2) Mission-template flags (int): See header_mission-templates.py for a list of available flags
#  3) Mission-type(int): Which mission types this mission template matches.
#     For mission-types to be used with the default party-meeting system,
#     this should be 'charge' or 'charge_with_ally' otherwise must be -1.
#
#  4) Mission description text (string).
#  5) List of spawn records (list): Each spawn record is a tuple that contains the following fields:
#    5.1) entry-no: Troops spawned from this spawn record will use this entry
#    5.2) spawn flags.
#    5.3) alter flags. which equipment will be overriden
#    5.4) ai flags.
#    5.5) Number of troops to spawn.
#    5.6) list of equipment to add to troops spawned from here (maximum 8).
#  6) List of triggers (list).
#     See module_triggers.py for infomation about triggers.
#
#  Please note that mission templates is work in progress and can be changed in the future versions.
#
####################################################################################################################
Code:
####################################################################################################################
#  Each trigger contains the following fields:
# 1) Check interval: How frequently this trigger will be checked
# 2) Delay interval: Time to wait before applying the consequences of the trigger
#    After its conditions have been evaluated as true.
# 3) Re-arm interval. How much time must pass after applying the consequences of the trigger for the trigger to become active again.
#    You can put the constant ti_once here to make sure that the trigger never becomes active again after it fires once.
# 4) Conditions block (list). This must be a valid operation block. See header_operations.py for reference.
#    Every time the trigger is checked, the conditions block will be executed.
#    If the conditions block returns true, the consequences block will be executed.
#    If the conditions block is empty, it is assumed that it always evaluates to true.
# 5) Consequences block (list). This must be a valid operation block. See header_operations.py for reference.
####################################################################################################################
 
Back
Top Bottom