Jump to content

Recommended Posts

I have a script that starts a bank robbery

 

/*
    File: fn_bankdrill.sqf  Creator . HomeUser
    Description:
    Starts the bank process.
*/





_unit = [_this,0,Objnull,[Objnull]] call BIS_fnc_param; 
if (isNull _unit) exitWith {}; 
if (life_bank_drilling) exitWith {}; 


life_bank_drilling = true;
publicVariable "life_bank_drilling"; 
 
 

createMarker ["bankMarker", position life_bank_building]; 
"bankMarker" setMarkerShape "ICON"; 
"bankMarker" setMarkerType "mil_dot"; 
"bankMarker" setMarkerColor "ColorRed"; 
"bankMarker" setMarkerText "Robbery in Progress"; 

hint "You have begun drilling the vault door! Drilling will complete in 10 minutes and will fail if you are killed or restrained within that time.";

_success = false; 
_elapsed = 0; 
while {life_bank_drilling} do 
{ 
sleep 1; 
_elapsed = _elapsed + 1; 
if (!alive _unit || _unit getVariable ["restrained",false] || _unit distance (getPos life_bank_building) > 60) exitWith {_success = false}; 
if (_elapsed >= 10) exitWith {_success = true};
}; 

if (_success) then {  
[[[0,1,2],"The vault door has finished drilling and is now open FOR FIVE MINUTES."],"life_fnc_broadcast",_unit,false] spawn life_fnc_MP; 
sleep (5*60); 
life_bank_building setVariable ["bis_disabled_Door_4", 1, true]; 
life_bank_building animate ["door_4_rot", 0]; 
life_bank_drilling = false;
[[[0,1,2],"The Bank of Altis is no longer being robbed."],"life_fnc_broadcast",west,false] spawn life_fnc_MP; 
"bankMarker" setMarkerText "Elevated Security"; 
sleep 60; 
deleteMarker "bankMarker"; 
};

if (!_success) then 
{ 
"bankMarker" setMarkerText "Elevated Security"; 
[[[0,1,2],"The Bank of Altis is no longer being robbed."],"life_fnc_broadcast",west,false] spawn life_fnc_MP; 
life_bank_drilling = false;
sleep 60; 
deleteMarker "bankMarker"; 
};

When i run the script through an add action

this addAction ["Begin Drilling Vault", life_fnc_bankDrill,false,4,true,true,"",' player distance (getMarkerPos "life_bank_door") < 5 && life_inv_drill > 0 && !life_bank_drilling'];

I get to the part where its _elapsed = _elapsed +1 and it doesn't trigger the

if (_elapsed >= 10) exitWith {_success = true};
Edited by HomeUser

Share this post


Link to post
Share on other sites

I may be wrong but i believe exitwith means terminate the script. Best thing to do is

while {life_bank_drilling && _success == false} do 
{ 
sleep 1; 
_elapsed = _elapsed + 1; 
if (!alive _unit || _unit getVariable ["restrained",false] || _unit distance (getPos life_bank_building) > 60) exitWith {_success = false}; 
if (_elapsed >= 10) then {_success = true};
}; 

Alternatively there is https://community.bistudio.com/wiki/breakOut. However this is how i would do it ^

Share this post


Link to post
Share on other sites
On 7/8/2019 at 9:17 AM, john123 said:

I may be wrong but i believe exitwith means terminate the script. 

exitWith exits the current scope, not the entire file/function unless that is the current scope when it is used.

For the script, diag_log the values and markers for how far it got and figure out where it gets stuck.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...