ROTAHOE 3 Posted May 13, 2017 I'm not sure how to implement a waitUntil crew == o but with a sleep of 5 min (300 seconds) . I would like to add this to this script. Please help Cheers private _price = 50; if([_price] call HG_fnc_hasEnoughMoney) then { if (!player_boatcooldown) then { //Take $50 From Player [50,1] call HG_fnc_addOrSubCash; // Start cooldown player_boatcooldown = true; // Create Jet Ski _veh = createVehicle ["C_Scooter_Transport_01_F",getpos player,[], 0, ""]; _veh setpos (player modelToWorld [0,6,0]); _veh setDir ([_veh, player] call BIS_fnc_dirTo); // Move Player Into Jet Ski player moveInDriver _veh; // Start cooldown timer sleep 5; hint format ["%1 \nJet ski cooldown is 5min!",name player]; sleep 300; player_boatcooldown = false; // Player Still On Cooldown } else {hint format ["%1 \nYou are still on cooldown!",name player];}; }; Also can someone tell me why this is not working? Its creating it facing North (0). I want it creating facing the players Dir on call. I guess I need getDir player; ? _veh setDir ([_veh, player] call BIS_fnc_dirTo); I got that part from a armaholic forum. Thank you in advance Share this post Link to post Share on other sites
7erra 629 Posted May 14, 2017 5 hours ago, ROTAHOE said: waitUntil crew == o but with a sleep of 5 min (300 seconds) I'm not sure what you mean by that. Here are some options: Sleep 5mins and then evaluate statement: sleep 300; waitUntil {{alive _x} count (crew vehicle _veh) == 0}; Either 5mins passed or vehicle is empty: _timer = 300; waitUntil { sleep 1; _timer = _timer -1; _timer <= 0 OR {alive _x} count (crew vehicle _veh) == 0; }; And yes, use getDir player to return the direction the player is facing. BIS_fnc_dirTo gives the relative direction between two objects. Btw to get the same result faster you can use the alternative syntax of getDir: obj1 getDir obj2; // Same as: [obj1,obj2] call BIS_fnc_dirTo; 1 Share this post Link to post Share on other sites
ROTAHOE 3 Posted May 14, 2017 Yeah mate that's what I'm look for. Bar I want the sleep after waitUntil {{alive _x} count (crew vehicle _veh) == 0}; For if the vehicle is left empty for 5min it will deleteVehicle _veh;. waitUntil { if ({alive _x} count (crew vehicle _veh) == 0) exitWith { sleep 300; deleteVehicle _veh; }; will this work ? Share this post Link to post Share on other sites
HallyG 239 Posted May 14, 2017 This will delete the vehicle if it has been empty, and continues to be, for 5 minutes. waitUntil { if (count ((crew vehicle _veh) select {alive _x}) isEqualTo 0) then { _time = diag_tickTime + 300; waitUntil { diag_tickTime > _time || count (crew vehicle _veh select {alive _x}) > 0 }; if (diag_tickTime > _time && {count (crew vehicle _veh select {alive _x}) isEqualTo 0}) exitWith { deleteVehicle _veh; }; }; !isNull _veh }; 1 1 Share this post Link to post Share on other sites
ROTAHOE 3 Posted May 14, 2017 How to add this to script? Its giving me trouble cheers Share this post Link to post Share on other sites
HallyG 239 Posted May 14, 2017 You need to spawn or execVM the code since waitUntil requires script suspension. For example, using some of your code above: ... bla bla earlier script bla bla ... _veh = createVehicle ["C_Scooter_Transport_01_F", getPos player, [], 0, "CAN_COLLIDE"]; _veh setPos (player modelToWorldVisual [0,6,0]); _veh setDir (player getDir _veh); [_veh] spawn { private _vehicle = param [0, objNull, [objNull]]; waitUntil { if (count ((crew vehicle _vehicle) select {alive _x}) isEqualTo 0) then { _time = diag_tickTime + 15; waitUntil { diag_tickTime > _time || count (crew vehicle _vehicle select {alive _x}) > 0 }; if (diag_tickTime > _time && {count (crew vehicle _vehicle select {alive _x}) isEqualTo 0}) exitWith { deleteVehicle _vehicle; }; }; !isNull _vehicle }; }; Share this post Link to post Share on other sites
ROTAHOE 3 Posted May 14, 2017 Testing in editor and will not work ? if (!player_boatcooldown) then { // Start cooldown player_boatcooldown = true; // Create Jet Ski _veh = createVehicle ["C_Scooter_Transport_01_F", getPos player, [], 0, "CAN_COLLIDE"]; _veh setPos (player modelToWorldVisual [0,6,0]); _veh setDir (player getDir _veh); // Move Player Into Jet Ski player moveInDriver _veh; // Delete In 15 Seconds If Empty [_veh] spawn { private _vehicle = param [0, objNull, [objNull]]; waitUntil { if (count ((crew vehicle _vehicle) select {alive _x}) isEqualTo 0) then { _time = diag_tickTime + 15; waitUntil { diag_tickTime > _time || count (crew vehicle _vehicle select {alive _x}) > 0 }; if (diag_tickTime > _time && {count (crew vehicle _vehicle select {alive _x}) isEqualTo 0}) exitWith { deleteVehicle _vehicle; }; }; !isNull _vehicle }; }; // Start cooldown timer sleep 5; hint format ["%1 \nJet ski cooldown is 5min!",name player]; sleep 300; player_boatcooldown = false; // Player Still On Cooldown } else {hint format ["%1 \nYou are still on cooldown!",name player]; }; Share this post Link to post Share on other sites
HallyG 239 Posted May 14, 2017 You need to spawn your code since you are using sleep, which requires script suspension. Additionally I had the vehicle command in there when I didn't need to. [] spawn { if (!player_boatcooldown) then { player_boatcooldown = true; _veh = createVehicle ["C_Scooter_Transport_01_F", getPos player, [], 0, "CAN_COLLIDE"]; _veh setPos (player modelToWorldVisual [0,6,0]); _veh setDir (player getDir _veh); [_veh] spawn { private _vehicle = param [0, objNull, [objNull]]; waitUntil { if (count ((crew _vehicle) select {alive _x}) isEqualTo 0) then { _time = diag_tickTime + 300; waitUntil { diag_tickTime > _time || count (crew vehicle _vehicle select {alive _x}) > 0 }; if (diag_tickTime > _time && {count (crew vehicle _vehicle select {alive _x}) isEqualTo 0}) exitWith { deleteVehicle _vehicle; true }; }; false }; }; player moveInDriver _veh; sleep 5; hint format ["%1 \nJet ski cooldown is 5min!", name player]; sleep 300; player_boatcooldown = false; } else { hint format ["%1 \nYou are still on cooldown!", name player]; }; }; 1 Share this post Link to post Share on other sites
ROTAHOE 3 Posted May 14, 2017 Thank you very much mate ! I was told earlier to spawn my codes in a old thread but forgot LOL Also started to think it was not working then noticed you changed 15 back to 300 hahaha cheers ! [] spawn { if (!player_boatcooldown) then { player_boatcooldown = true; _veh = createVehicle ["C_Scooter_Transport_01_F", getPos player, [], 0, "CAN_COLLIDE"]; _veh setPos (player modelToWorldVisual [0,6,0]); _veh setDir (player getDir _veh); [_veh] spawn { private _vehicle = param [0, objNull, [objNull]]; waitUntil { if (count ((crew _vehicle) select {alive _x}) isEqualTo 0) then { _time = diag_tickTime + 300; waitUntil { diag_tickTime > _time || count (crew vehicle _vehicle select {alive _x}) > 0 }; if (diag_tickTime > _time && {count (crew vehicle _vehicle select {alive _x}) isEqualTo 0}) exitWith { deleteVehicle _vehicle; true }; }; false }; }; player moveInDriver _veh; sleep 5; hint format ["%1 \nJet ski cooldown is 5min!", name player]; sleep 300; player_boatcooldown = false; } else { hint format ["%1 \nYou are still on cooldown!", name player]; }; }; Share this post Link to post Share on other sites