Barba-negra 117 Posted April 3, 2018 good to all, I'm here again asking for help `please, I'm creating a scripts in which I use a timer of oxygen and carbon dioxide to navigate in water depths, and so far achieved that appears on screen the names and the percentage, but I have an error because the percentage remains static and does not change when immersed, what am I doing wrong, help please //Estado _Submarino = "B_SDV_01_F" createvehicle [15300.707, 15765.22, 11.268]; publicvariable "_Submarino"; oxygen = 100; carbon_monoxide = 0; (oxygen <1), UNO setdamage 1; DOS setdamage 1; TRES setdamage 1; CUATRO setdamage 1; CINCO setdamage 1; (oxygen > 100), oxygen = 100; (carbon_monoxide > 100), carbon_monoxide = 100; (oxygen < 0), oxygen = 0; (carbon_monoxide < 0), carbon_monoxide = 0; _Submarino setVectorUp [0,0,1], oxygen < 100, oxygen = oxygen +2; carbon_monoxide = carbon_monoxide -2; _Submarino setVectorUp [0,0,-2], oxygen = oxygen -0.001, carbon_monoxide = carbon_monoxide +0.001; _Submarino setVectorUp [0,0,-7], oxygen = oxygen -0.002, carbon_monoxide = carbon_monoxide +0.002; _Submarino setVectorUp [0,0,-15], oxygen = oxygen -0.003; carbon_monoxide = carbon_monoxide +0.003; _Submarino setVectorUp [0,0,-30], oxygen = oxygen -0.02; carbon_monoxide = carbon_monoxide +0.01; hintSilent format["oxigeno y dioxido de Carbono, \n\noxygen-status\n%1%2 \n\nmonoxide-status\n%3%4",oxygen,"%",carbon_monoxide,"%"]; goto "status"; Share this post Link to post Share on other sites
pierremgi 4904 Posted April 3, 2018 You mixed sqs and sqf codes. Stay sqf. Your vectorUp have no sense (if I could say) . You probably want a timer with depth incidence on gaz percentages. 0 = [] spawn { _Submarino = "B_SDV_01_F" createvehicle [15300.707, 15765.22, 11.268]; _oxygen = 100; _carbon_monoxide = 0; while {alive _submarino} do { if (underWater _submarino) then { call { if ((getposASLW _submarino select 2) < -30) exitWith { _oxygen = (_oxygen - 0.02) max 0; _carbon_monoxyde = (_carbon_monoxyde + 0.01) min 100; }; if ((getposASLW _submarino select 2) < -15) exitWith { _oxygen = (_oxygen - 0.003) max 0; _carbon_monoxyde = (_carbon_monoxyde + 0.003) min 100; }; if ((getposASLW _submarino select 2) < -7) exitWith { _oxygen = (_oxygen - 0.002) max 0; _carbon_monoxyde = (_carbon_monoxyde + 0.002) min 100; }; if ((getposASLW _submarino select 2) < -2) exitWith { _oxygen = (_oxygen - 0.001) max 0; _carbon_monoxyde = (_carbon_monoxyde + 0.001) min 100; }; }; }; if (_oxygen <=0) then { {_x setdamage 1} forEach [uno,dos,tres,cuatro,cinco] }; if !(underWater _submarino) then { _oxygen = (_oxygen + 0.02) min 100; _carbon_monoxyde = (_carbon_monoxyde - 0.02) max 0; }; hintSilent format ["oxigeno y dioxido de Carbono, \n\noxygen-status\n%1%2 \n\nmonoxide-status\n%3%4",_oxygen,"%",_carbon_monoxide,"%"]; sleep 0.1; }; }; Adjust values and sleep time (timer loop). 1 Share this post Link to post Share on other sites
Barba-negra 117 Posted April 3, 2018 oohh my god what beautiful scripts, you are great friend thank you very much I'm going to incorporate it, Share this post Link to post Share on other sites
Barba-negra 117 Posted April 4, 2018 the scritpts worked perfectly friend thank you very much, I am already using it, but now another problem has occurred, and that is that I can remove the message of oxygen from the screen, it remains permanently, and I would like to see it and that in a few seconds it will be removed or removed with an action close status view, try adding a sleep 20; hint ""; but it did not work, and I even put a separate trigger with the hint ""; but nothing persists in remaining active the message of status, how can I do, help please Share this post Link to post Share on other sites
pierremgi 4904 Posted April 5, 2018 0 = [] spawn { _Submarino = "B_SDV_01_F" createvehicle [15300.707, 15765.22, 11.268]; _oxygen = 100; _carbon_monoxyde = 0; while {alive _submarino} do { if (underWater _submarino) then { call { if ((getposASLW _submarino select 2) < -30) exitWith { _oxygen = (_oxygen - 0.02 * count crew _submarino) max 0; _carbon_monoxyde = (_carbon_monoxyde + 0.02 * count crew _submarino) min 100; }; if ((getposASLW _submarino select 2) < -15) exitWith { _oxygen = (_oxygen - 0.003 * count crew _submarino) max 0; _carbon_monoxyde = (_carbon_monoxyde + 0.003 * count crew _submarino) min 100; }; if ((getposASLW _submarino select 2) < -7) exitWith { _oxygen = (_oxygen - 0.002 * count crew _submarino) max 0; _carbon_monoxyde = (_carbon_monoxyde + 0.002 * count crew _submarino) min 100; }; if ((getposASLW _submarino select 2) < -2) exitWith { _oxygen = (_oxygen - 0.001 * count crew _submarino) max 0; _carbon_monoxyde = (_carbon_monoxyde + 0.001 * count crew _submarino) min 100; }; }; }; if (_oxygen <=0) then { {_x setdamage 1} forEach [uno,dos,tres,cuatro,cinco] }; if !(underWater _submarino) then { _oxygen = (_oxygen + 0.02) min 100; _carbon_monoxyde = (_carbon_monoxyde - 0.02) max 0; }; _msg = ["",format ["oxigeno y dioxido de Carbono, \n\noxygen-status\n%1%2 \n\nmonoxide-status\n%3%4",_oxygen,"%",_carbon_monoxyde,"%"]] select (_oxygen < 100 && player in _submarino); hintSilent _msg; sleep 0.1; }; }; You don't need any trigger. Added 02 consumption depending on crew. 1 Share this post Link to post Share on other sites
Barba-negra 117 Posted April 5, 2018 thank you very much for your help friend, it is of great value, I will try it in a few hours Share this post Link to post Share on other sites
Barba-negra 117 Posted April 5, 2018 Quote Friend worked perfect, really thank you very much I would not know how to thank him: D Share this post Link to post Share on other sites
pierremgi 4904 Posted April 6, 2018 7 hours ago, elthefrank said: I let the kill foreach [uno duo... cinco], without idea of your scenario, but you could just replace this array by: crew _submarino. This way, you'll kill only people inside the sub. Share this post Link to post Share on other sites
Barba-negra 117 Posted April 6, 2018 ok friend is well defined, it has worked for me as I had thought: D Share this post Link to post Share on other sites
Barba-negra 117 Posted April 19, 2018 good afternoon friend pierremgi, Sorry to bother you again, but I would like to know how I can put the bets of several players, call it oxygena.sqf, and place it at the beginning of the mission, and call it as follows: 0 = [] execVM "scripts \ Oxygen.sqf" call BIS_fnc_MP; but it did not work, I do not know why, help please El 6/4/2018 a las 6:26 a.m., pierremgi dijo: Dejé que la muerte foreach [uno duo ... cinco], idea de pecado de su escenario, pero que podría reemplazar esta matriz por: crew _submarino. De esta manera, matarás solo personas dentro del submarino. Share this post Link to post Share on other sites
pierremgi 4904 Posted April 20, 2018 Don't "call bis_fnc_MP" your script. You have two challenges in MP: - a common reference for the gaz values; - a local hint, adapted to player's situation (inside or outside sub for example): One way to do that is to split into 2 scripts: in initServer.sqf (all init are at the mission root!): or, in your specific sqf,then executed from init.sqf (always at the mission root): if (isServer) then {[] execVM "scripts \ Oxygen.sqf"}; // you can choose your folder here As you need to make the variables (O2,CO) public, you have to broadcast these values on your network. One simple way is to assign these variables to the submarine and make them common. See setVariable (alternative syntax) for more info. This can be a little bit network resource consuming, so you should have to damper the loop refresh (more sleep time). The code will run at server (hosted or dedicated) start: [] spawn { submarino = "B_SDV_01_F" createvehicle [15300.707, 15765.22, 11.268]; publicVariable "submarino"; submarino setVariable ["oxygen",100,true]; submarino setVariable ["carbon_monoxyde",0,true]; while {alive submarino} do { if (underWater submarino) then { call { if ((getposASLW submarino select 2) < -30) exitWith { submarino setVariable ["oxygen",((submarino getVariable "oxygen") - 0.02 * count crew submarino) max 0,true]; submarino setVariable ["carbon_monoxyde", ((submarino getVariable "carbon_monoxyde") + 0.02 * count crew submarino) min 100,true]; }; if ((getposASLW submarino select 2) < -15) exitWith { submarino setVariable ["oxygen",((submarino getVariable "oxygen") - 0.003 * count crew submarino) max 0,true]; submarino setVariable ["carbon_monoxyde", ((submarino getVariable "carbon_monoxyde") + 0.003 * count crew submarino) min 100,true]; }; if ((getposASLW submarino select 2) < -7) exitWith { submarino setVariable ["oxygen",((submarino getVariable "oxygen") - 0.002 * count crew submarino) max 0,true]; submarino setVariable ["carbon_monoxyde", ((submarino getVariable "carbon_monoxyde") + 0.002 * count crew submarino) min 100,true]; }; if ((getposASLW submarino select 2) < -2) exitWith { submarino setVariable ["oxygen",((submarino getVariable "oxygen") - 0.001 * count crew submarino) max 0,true]; submarino setVariable ["carbon_monoxyde", ((submarino getVariable "carbon_monoxyde") + 0.001 * count crew submarino) min 100,true]; }; }; }; if ((submarino getVariable "oxygen") <=0) then { {_x setdamage 1} forEach crew submarino; }; if !(underWater submarino) then { submarino setVariable ["oxygen",((submarino getVariable "oxygen") + 0.02) min 100,true]; submarino setVariable ["carbon_monoxyde",((submarino getVariable "carbon_monoxyde") - 0.02) max 0,true]; }; sleep 0.1; }; }; So the server is the reference for the values of gaz. Now, you need to hint the value, along with player's situation: just add in initPlayerLocal.sqf (at the mission root): [] spawn { while {alive submarino} do { if (underwater submarino) then { _msg = ["",format ["oxigeno y dioxido de Carbono, \n\noxygen-status\n%1%2 \n\nmonoxide-status\n%3%4",submarino getVariable "oxygen","%",submarino getVariable "carbon_monoxyde","%"]] select (submarino getVariable "oxygen" < 100 && player in submarino); hintSilent _msg; }; sleep 0.1; }; }; 1 Share this post Link to post Share on other sites
Barba-negra 117 Posted April 21, 2018 12 hours ago, pierremgi said: Don't "call bis_fnc_MP" your script. You have two challenges in MP: - a common reference for the gaz values; - a local hint, adapted to player's situation (inside or outside sub for example): One way to do that is to split into 2 scripts: in initServer.sqf (all init are at the mission root!): or, in your specific sqf,then executed from init.sqf (always at the mission root): if (isServer) then {[] execVM "scripts \ Oxygen.sqf"}; // you can choose your folder here As you need to make the variables (O2,CO) public, you have to broadcast these values on your network. One simple way is to assign these variables to the submarine and make them common. See setVariable (alternative syntax) for more info. This can be a little bit network resource consuming, so you should have to damper the loop refresh (more sleep time). The code will run at server (hosted or dedicated) start: [] spawn { submarino = "B_SDV_01_F" createvehicle [15300.707, 15765.22, 11.268]; publicVariable "submarino"; submarino setVariable ["oxygen",100,true]; submarino setVariable ["carbon_monoxyde",0,true]; while {alive submarino} do { if (underWater submarino) then { call { if ((getposASLW submarino select 2) < -30) exitWith { submarino setVariable ["oxygen",((submarino getVariable "oxygen") - 0.02 * count crew submarino) max 0,true]; submarino setVariable ["carbon_monoxyde", ((submarino getVariable "carbon_monoxyde") + 0.02 * count crew submarino) min 100,true]; }; if ((getposASLW submarino select 2) < -15) exitWith { submarino setVariable ["oxygen",((submarino getVariable "oxygen") - 0.003 * count crew submarino) max 0,true]; submarino setVariable ["carbon_monoxyde", ((submarino getVariable "carbon_monoxyde") + 0.003 * count crew submarino) min 100,true]; }; if ((getposASLW submarino select 2) < -7) exitWith { submarino setVariable ["oxygen",((submarino getVariable "oxygen") - 0.002 * count crew submarino) max 0,true]; submarino setVariable ["carbon_monoxyde", ((submarino getVariable "carbon_monoxyde") + 0.002 * count crew submarino) min 100,true]; }; if ((getposASLW submarino select 2) < -2) exitWith { submarino setVariable ["oxygen",((submarino getVariable "oxygen") - 0.001 * count crew submarino) max 0,true]; submarino setVariable ["carbon_monoxyde", ((submarino getVariable "carbon_monoxyde") + 0.001 * count crew submarino) min 100,true]; }; }; }; if ((submarino getVariable "oxygen") <=0) then { {_x setdamage 1} forEach crew submarino; }; if !(underWater submarino) then { submarino setVariable ["oxygen",((submarino getVariable "oxygen") + 0.02) min 100,true]; submarino setVariable ["carbon_monoxyde",((submarino getVariable "carbon_monoxyde") - 0.02) max 0,true]; }; sleep 0.1; }; }; So the server is the reference for the values of gaz. Ahora, debe indicar el valor, junto con la situación del jugador: solo agregue initPlayerLocal.sqf (en la raíz de la misión): I worked friend, thank you very much, it took me a bit to adapt but I could, thanks really, my friend: D Share this post Link to post Share on other sites