I need to call script on mission end .

Users who are viewing this thread

Hey . I would like to ask you for help with my problem.

I need to  call the script to everyone on server when multiplayer mission ends.


In that way this script work well :

Code:
		 (ti_on_player_exit, 0, 0, [],
       [
          (store_trigger_param_1, ":player_no"),
		  
          (call_script, "script_save_player_gold", ":player_no"),
      ]),



But If I want call this script on ti_on_multiplayer_mission_end  nothing usefull happens . Acces logs for my database is empty.



      (ti_on_multiplayer_mission_end, 0, 0, [],
      [   
    (get_max_players, ":num_players"),
    (try_for_range, ":player_no", 1, ":num_players"),
                (player_is_active, ":player_no"),
        (call_script, "script_save_player_gold", ":player_no"),
        (try_end),
##MB CODE
        (call_script, "script_multiplayer_event_mission_end"),
        (assign, "$g_multiplayer_stats_chart_opened_manually", 0),
        (start_presentation, "prsnt_multiplayer_stats_chart"),
        ]),



Anyone can help me? There is code from script_save_player_gold (work)


Code:
("save_player_gold",[
        (store_script_param_1, reg0),#must be active
        
        (player_get_unique_id, reg1, reg0),
        (player_get_gold, reg2, reg0),
        (str_store_player_username, s0, reg0),
        (send_message_to_url, "@http://secret/example.php?unique%5Fid={reg1}&local%5Fid={reg0}&event=2&username={s0}&gold={reg2}"),
		(display_message, "@Debug"),
    ]),


Also I can't use try_for_players.


Thanks for reading, Pitch

 
PitchPL said:
(try_for_range, ":player_no", 1, ":num_players"),

Also I can't use try_for_players.

couple comments:

1) try_for_range
Code:
try_for_range           =    6  # (try_for_range, <destination>, <lower_bound>, <upper_bound>),
                                # Runs a cycle, iterating the value in the <lower_bound>..<upper_bound>-1 range.
you count from zero (0), not 1 (if ID 0 is valid for your case), and it stops at max-1. Say you have 30 players.
(try_for_range, reg0, 1, 30) => 1, 2, 3, ..., 29
(try_for_range, reg0, 0, 30) => 0, 1, 2, ..., 29

2) try_for_players requires version around 1.165. You can find this info on header_operations.py
Code:
try_for_players         =   17  # (try_for_players, <destination>, [skip_server]),
                                # Version 1.165+. Iterates through all players in a multiplayer game. Set optional parameter to 1 to skip server player entry.
Version 1.165+
 
kalarhan said:
PitchPL said:
(try_for_range, ":player_no", 1, ":num_players"),

Also I can't use try_for_players.

couple comments:

1) try_for_range
Code:
try_for_range           =    6  # (try_for_range, <destination>, <lower_bound>, <upper_bound>),
                                # Runs a cycle, iterating the value in the <lower_bound>..<upper_bound>-1 range.
you count from zero (0), not 1 (if ID 0 is valid for your case), and it stops at max-1. Say you have 30 players.
(try_for_range, reg0, 1, 30) => 1, 2, 3, ..., 29
(try_for_range, reg0, 0, 30) => 0, 1, 2, ..., 29


Thanks for advice . Now I understand much better try_for_range  . And I still do not understand why it does not work.


I set "1" because modsys says " #0 is server so starting from 1"  . I tried once setting "0"



Finally I fix my issue with editing my code like this



Code:
(ti_on_multiplayer_mission_end, 0, 0, [],
       [    
	   	   (get_max_players, ":num_players"),
		   (store_trigger_param_1, ":player_no"),
		   (store_trigger_param_2, ":num_players"),
	    (try_for_range, ":player_no", 0, ":num_players"), #0 is server so starting from 1
                (player_is_active, ":player_no"),
         (call_script, "script_save_player_gold", ":player_no"),	
         (try_end),		 
         (call_script, "script_multiplayer_event_mission_end"),
         (assign, "$g_multiplayer_stats_chart_opened_manually", 0),
         (start_presentation, "prsnt_multiplayer_stats_chart"),
         ]),
 
Back
Top Bottom