Jump to content
Sign in to follow this  
mikemhz

End Mission When a Side's Tickets are Spent

Recommended Posts

Hi,

http://community.bistudio.com/wiki/BIS_fnc_respawnTickets

This page states:

When player runs out of the tickets, his respawn is disabled. If you use also EndMission respawn template, the mission will automatically end once tickets in all name spaces are exhausted.

I'm looking for a way to end the mission once only one side's tickets are spent. Anybody know how this can be achived? A trigger?

I imagine it would go something like:

eastTickets = [east] call BIS_fnc_respawnTickets;
westTickets = [west] call BIS_fnc_respawnTickets;

if (eastTickets == 0){endMission "LOSER"};
if (westTickets == 0){endMission "LOSER"};

What would be the correct syntax? What about informing the winning team they won? Preferably this would be done in-editor via trigger or game logic.

Share this post


Link to post
Share on other sites

First, you need to continuously update the ticket count variables and check for the conditions. A trigger would work, but it will check very often (every frame if I remember correctly). I suggest a loop like this:

private ["_eastTickets", "_westTickets"];
while {true} do {
   sleep 10;

   _eastTickets = [east] call BIS_fnc_respawnTickets;
   _westTickets = [west] call BIS_fnc_respawnTickets;

   if (_eastTickets == 0) exitWith {
       if (side player == east) then {
           "OpforLose" call BIS_fnc_endMission;
       } else {
           "BluforWin" call BIS_fnc_endMission;
       }
   };
   if (_westTickets == 0) exitWith {
       if (side player == east) then {
           "OpforWin" call BIS_fnc_endMission;
       } else {
           "BluforLose" call BIS_fnc_endMission;
       }
   };
};

I changed the variables to local ones, as I would run this from the init.sqf as a separate thread. You could run it like this:

0 = [] spawn {<code here>};

I have also used BIS_fnc_endMission, so that you can set up better ending screens for the four possible outcomes. This code should run on all client machines and the server, as BIS_fnc_endMission has local effect. Depending on your init.sqf and mission, the clients should be running this code in synch, so the mission ends at the same time for everyone.

http://community.bistudio.com/wiki/BIS_fnc_endMission

http://community.bistudio.com/wiki/Debriefing

Based upon the side of the client, a different ending will display. I do not know if there is any way to do this all in the editor, as I greatly prefer to use external functions. Also, I have not tested this in any way, so this is just a rough example for doing this.

Alternatively, you could run everything on the server and force an ending on the clients using BIS_fnc_MP. This is more efficient, clearer, and easier to maintain, but requires more up-front work and understanding of client and server communication.

Share this post


Link to post
Share on other sites

Thanks, that works great. I decided to use your implementation through the init.sqf. Will add your name to the credits :)

Share this post


Link to post
Share on other sites

I have also used BIS_fnc_endMission, so that you can set up better ending screens for the four possible outcomes. This code should run on all client machines and the server, as BIS_fnc_endMission has local effect. Depending on your init.sqf and mission, the clients should be running this code in synch, so the mission ends at the same time for everyone.

http://community.bistudio.com/wiki/BIS_fnc_endMission

http://community.bistudio.com/wiki/Debriefing

Based upon the side of the client, a different ending will display. I do not know if there is any way to do this all in the editor, as I greatly prefer to use external functions. Also, I have not tested this in any way, so this is just a rough example for doing this.

Alternatively, you could run everything on the server and force an ending on the clients using BIS_fnc_MP. This is more efficient, clearer, and easier to maintain, but requires more up-front work and understanding of client and server communication.

I"m guessing you also need to end the mission for the server, correct ?

As this code is all local to the client, the clients will all end their mission, but the server will continue to run ?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×