Results 1 to 6 of 6

Thread: No revives left for leader = end mission?

  1. #1

    No revives left for leader = end mission?

    I thought I would throw this out there for the scripters - I figure you will know answer b4 I figure it out.

    I want mission to end when leader (called p1) has no revives left.

    thanx in advance

    Lighty

  2. #2
    Staff Sergeant Acelondoner's Avatar
    Join Date
    Apr 8 2010
    Location
    The clue is in my username ;)
    Posts
    296
    Are you using Norrins revive script?

  3. #3
    yes that is correct

  4. #4
    shk found the answer for me - damn good scripter he is - got it right first go and in about 5 minutes.


    place this in the init file -
    Code:
    //end when leader dead
    [] spawn {
      [] spawn {
        TheEnd = false;
        waituntil {TheEnd};
        endmission "END1";
      };
      waituntil {!isnull player};
      if (player == leader group player) then {
        player setvariable ["SHK_reviveCount",0];
        while {(player getvariable "SHK_reviveCount") < 3} do {
          waituntil {(player getvariable "NORRN_unconscious")};
          player setvariable ["SHK_reviveCount",(player getvariable "SHK_reviveCount") + 1];
          waituntil {!(player getvariable "NORRN_unconscious")};
        };
        TheEnd = true;
        publicvariable "TheEnd";
      };
    };
    you can adjust the number 3 to reduce number of revives.

    thanx mate
    Last edited by Lightspeed_aust; Jan 28 2011 at 07:04.

  5. #5
    Are you still going with that high command thing? Because I have to say my experiences with high command weren't very positive. AI don't seem to really do what you want/expect them to. When you are their group leader it's much easier to tell them exactly what to do, which is probably more suitable for the missions you're trying to make.

    In any case, for mission ending, in order to have the mission correctly end on all machines without occasional bugs, you should use something like this:
    Code:
    if (!isServer) then
    {
    	"end1" addPublicVariableEventHandler
    	{
    		if (dialog) then
    		{
    			closeDialog 0;
    		};
    		endMission "END1";
    	};
    	
    	"end2" addPublicVariableEventHandler
    	{
    		if (dialog) then
    		{
    			closeDialog 0;
    		};
    		endMission "END2";
    	};
    	
    	"end3" addPublicVariableEventHandler
    	{
    		if (dialog) then
    		{
    			closeDialog 0;
    		};
    		endMission "END3";
    	};	
    	
    	"end4" addPublicVariableEventHandler
    	{
    		if (dialog) then
    		{
    			closeDialog 0;
    		};
    		endMission "END4";
    	};
    }
    else
    {
    	// initialize global variables here, so you don't get undefined variable errors
    	
    	[] spawn
    	{
    		waitUntil {/*condition for 1st ending here*/};
    		end1=true;
    		publicVariable "end1";
    		if (dialog) then
    		{
    			closeDialog 0;
    		};
    		sleep 5;
    		endMission "END1";
    	};
    	[] spawn
    	{
    		waitUntil {/*condition for 2nd ending here*/};
    		end2=true;
    		publicVariable "end2";
    		if (dialog) then
    		{
    			closeDialog 0;
    		};
    		sleep 5;
    		endMission "END2";
    	};
    	[] spawn
    	{
    		waitUntil {/*condition for 3nd ending here*/};
    		end3=true;
    		publicVariable "end3";
    		if (dialog) then
    		{
    			closeDialog 0;
    		};
    		sleep 5;
    		endMission "END3";
    	};
    	[] spawn
    	{
    		waitUntil {/*condition for 4th ending here*/};
    		end4=true;
    		publicVariable "end4";
    		if (dialog) then
    		{
    			closeDialog 0;
    		};
    		sleep 5;
    		endMission "END4";
    	};
    };
    And then run this script on all machines (easiest is to just execVM it from init.sqf).

    Also, the method you are using will not work for JIP, since the revive count is only saved on the player's machine, so leader could die twice, reconnect, and then die again. The revive script might realize he's out of lives, not sure how the revive script is made, but your mission ending script will lose count. So instead, make that counting only happen on the server, since the server can't JIP
    Last edited by galzohar; Jan 28 2011 at 11:06.

  6. #6
    thanx Gal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •