Jump to content

Recommended Posts

Hello All,

 

I made this surrender script so players can surrender I'm sure people can find a use for it in their mission.

 

NOTE: There is no point in installing this script if you use ACE3.

 

Installation:

Step 1: Put the following into your description.ext, should be ok at the top of the file. If you don't have that file in your mission create it.

#include "Configs\Config_Master.hpp"

 

Step 2: Make the following folder in your mission root Configs\Config_Master.

NOTE: If you changed the path put it into that path

/*
    Author - BradApex
    Description:

    Master config so my scripts know which scripts of mine you are running,
    I will be relasing my bleedout script when it's done stay tuned :)
*/

class cfgMaster {
    UsingBleedoutScript = false;
};

 

Step 3: Put the following Files into your init.sqf, If you don't have that file in your mission create it.

_fnc_surrender = {
  /*
      Author - BradApex
      Description:

      Lets the player surrender
  */

  if (player getVariable ["surrender", false]) exitWith {
      hint "You are already surrendering";
  };

  //-- Config Checks
  _usingBleedout = getText(missionConfigFile >> "cfgMaster" >> "UsingBleedoutScript");

  player setVariable ["surrender", true, true];
  player setCaptive true;

  player playMove "amovpercmstpsnonwnondnon_amovpercmstpssurwnondnon";
  
  ["SURRENDER_HANDLER", "onEachFrame", {		
      params [
          ["_player",objNull,[objNull]],
          ["_usingBleedout", false, [false]]
      ];

      if (_usingBleedout isEqualTo true) then {
          if (_player getVariable ["incapacitated", false]) then {
              _player setVariable ["surrender", nil, true];
              _player setCaptive false;

              ["SURRENDER_HANDLER", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
              SURRENDER_HANDLER = nil;
          };
      } else {
          if (!(alive _player)) then {		
              _player setVariable ["surrender", nil, true];
              _player setCaptive false;

              ["SURRENDER_HANDLER", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
              SURRENDER_HANDLER = nil;
          };
      };

      if (_player getVariable ["surrender", false]) then {
          _player setVariable ["surrender", false, true];
          _player setCaptive false;

          _player playMoveNow "AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon";

          ["SURRENDER_HANDLER", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
          SURRENDER_HANDLER = nil;
      };
  }, [player, _usingBleedout]] call BIS_fnc_addStackedEventHandler;
};

 

_fnc_keyDown = {
	params["_ctrl","_dikCode","_shift","_ctrlKey", "_alt", ["_handled",false], ["_display", displayNull, [displayNull]]];

    _code = _this select 1;
    _speed = speed cursorObject;
    _curObject = cursorObject;

    switch(_dikCode) do
    {
        //-- Shift + 6
        case 7:
        {
            if (_shift) then { _handle = true; };
            if (_shift) then
            {
                if (isNull objectParent player) then
                {
                    if (player getVariable ["surrender", false]) then
                    {
                        player setVariable ["surrender", false, false];
                    } else
                    {
                        [] spawn _fnc_surrender;
                    };
                };
            };
        };
    };
};

 

Last Step: Now the last step put this code below into your initPlayerLocal.sqf

waitUntil {!isNull (findDisplay 46)};
(findDisplay 46) displayAddEventHandler ["KeyDown",{_this spawn _fnc_keyDown}];

 

Leave a comment on this post if you install this i'm interested to see and if there is any issues or bugs let me know.

  • Like 4

Share this post


Link to post
Share on other sites

V1.0: Changed while true loop to onEachFrame and updated KeyDown script

  • Like 1

Share this post


Link to post
Share on other sites

V1.1: Changed Install and added a master config

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

×