ATGSS 0 Posted December 9, 2019 Hi, sry for my bad english, i have a script with a effect on players in multiplayer ,it is loaded with a Addaction, but i want run again the same script only if the effect is over. I have a water dispenser, then you can drink water, and got a long effect, but if you drink 3 times , you got 3 times the effect at the same time. I want only drink 1 time , and only can drink again if the effect is over, for example, if you try drink again before the effect is over, you got a hint, " you drank recently", or the AddAction "drink water", ist not available , dissapear or something. ¿Can anyone help me pls?, thank you very much. Here is the script if you need more information : titleText ["Ya estas hidratado y listo para el combate, tu aguante durara ahora mas tiempo.","PLAIN DOWN"]; titleFadeOut 15; sleep 400; titleText ["Estas empezando a sentirte mal.","PLAIN DOWN"]; titleFadeOut 15; sleep 200; titleText ["El agua que bebiste antes estaba adulterada con algun tipo de sustancia. No te encuentras bien.","PLAIN DOWN"]; titleFadeOut 15; sleep 6; addCamShake [10, 200, 50] ; //Activate ppEffects we need "chromAberration" ppEffectEnable true; "radialBlur" ppEffectEnable true; "DynamicBlur" ppEffectEnable true; //Let's go for 45secs of effetcs for "_i" from 0 to 126 do { "chromAberration" ppEffectAdjust [random 0.04,random 0.04,true]; "chromAberration" ppEffectCommit 1; "radialBlur" ppEffectAdjust [random 0.01,random 0.01,0.01,0.01]; "radialBlur" ppEffectCommit 1; "DynamicBlur" ppEffectAdjust [random 0.1]; "DynamicBlur" ppEffectCommit 1; sleep 1; }; for "_i" from 126 to 228 do { "chromAberration" ppEffectAdjust [random 1,random 1,true]; "chromAberration" ppEffectCommit 1; "radialBlur" ppEffectAdjust [random 0.02,random 0.02,0.15,0.15]; "radialBlur" ppEffectCommit 1; "DynamicBlur" ppEffectAdjust [random 0.6]; "DynamicBlur" ppEffectCommit 1; sleep 1; }; for "_i" from 228 to 410 do { "chromAberration" ppEffectAdjust [random 0.20,random 0.20,true]; "chromAberration" ppEffectCommit 1; "radialBlur" ppEffectAdjust [random 0.01,random 0.02,0.10,0.10]; "radialBlur" ppEffectCommit 1; "DynamicBlur" ppEffectAdjust [random 0.4]; "DynamicBlur" ppEffectCommit 1; sleep 1; }; for "_i" from 410 to 510 do { "chromAberration" ppEffectAdjust [random 0.10,random 0.10,true]; "chromAberration" ppEffectCommit 1; "radialBlur" ppEffectAdjust [random 0.01,random 0.01,0.07,0.06]; "radialBlur" ppEffectCommit 1; "DynamicBlur" ppEffectAdjust [random 0.3]; "DynamicBlur" ppEffectCommit 1; sleep 1; }; for "_i" from 510 to 720 do { "chromAberration" ppEffectAdjust [random 0.06,random 0.06,true]; "chromAberration" ppEffectCommit 1; "radialBlur" ppEffectAdjust [random 0.01,random 0.01,0.04,0.03]; "radialBlur" ppEffectCommit 1; "DynamicBlur" ppEffectAdjust [random 0.2]; "DynamicBlur" ppEffectCommit 1; sleep 1; }; for "_i" from 720 to 860 do { "chromAberration" ppEffectAdjust [random 0.04,random 0.04,true]; "chromAberration" ppEffectCommit 1; "radialBlur" ppEffectAdjust [random 0.01,random 0.01,0.01,0.01]; "radialBlur" ppEffectCommit 1; "DynamicBlur" ppEffectAdjust [random 0.1]; "DynamicBlur" ppEffectCommit 1; sleep 1; }; for "_i" from 860 to 990 do { "chromAberration" ppEffectAdjust [random 0.04,random 0.04,true]; "chromAberration" ppEffectCommit 1; "radialBlur" ppEffectAdjust [random 0.01,random 0.01,0.01,0.01]; "radialBlur" ppEffectCommit 1; "DynamicBlur" ppEffectAdjust [random 0.1]; "DynamicBlur" ppEffectCommit 1; sleep 1; }; //Stop effects "chromAberration" ppEffectAdjust [0,0,true]; "chromAberration" ppEffectCommit 5; "radialBlur" ppEffectAdjust [0,0,0,0]; "radialBlur" ppEffectCommit 5; "DynamicBlur" ppEffectAdjust [0]; "DynamicBlur" ppEffectCommit 5; sleep 6; //Deactivate ppEffects "chromAberration" ppEffectEnable false; "radialBlur" ppEffectEnable false; "DynamicBlur" ppEffectEnable false; Share this post Link to post Share on other sites
pierremgi 4739 Posted December 10, 2019 You need to set a variable on player. Player setVariable ["thirst",0] in example. Then, this variable must have a max value, for death, and intermediate ones for warnings. Of course this variable is function of time, linear or accelerated The mean to reduce it to 0 is your addAction on specific objects, by "drinking" some quantities. Thirst vs Water remaining can also have their related function. The simplest is: x thirst = x water except if water is an unlimited source. The quantity available / remaining on object is another variable set to object (then publicVariable in MP) Thirst is a variable on player , so local. You just have to monitor it in a loop. The addAction needs a condition for water >0. Drinking on an object in inventory needs some other code , not an addAction. Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted December 10, 2019 8 hours ago, ATGSS said: Hi, sry for my bad english, i have a script with a effect on players in multiplayer ,it is loaded with a Addaction, but i want run again the same script only if the effect is over. I have a water dispenser, then you can drink water, and got a long effect, but if you drink 3 times , you got 3 times the effect at the same time. I want only drink 1 time , and only can drink again if the effect is over, for example, if you try drink again before the effect is over, you got a hint, " you drank recently", or the AddAction "drink water", ist not available , dissapear or something. ¿Can anyone help me pls?, thank you very much. Here is the script if you need more information : Two commonly used methods, a time based lockout that displays a text based on timeout state: //time based lockout player addAction ["Drink",{ params ["_object","_caller","_ID"]; _timeOut = _object getVariable ["TAG_fnc_timeOut",0]; if (time < _timeOut) exitWith {hint "You drank recently"}; hint "You drink"; _object setVariable ["TAG_fnc_timeOut",time + 10];//only allows drinking every 10s }]; And the second one which hides the action until the timeout is up (10s for both examples). //hide action during timeout player addAction ["Drink",{ params ["_object","_caller","_ID"]; hint "You drink"; _object setVariable ["TAG_fnc_timeOut",time + 10];//only allows drinking every 10s },nil,1.5,true,true,"","_this getVariable ['TAG_fnc_timeOut',0] < time"]; Should get you started. Cheers 1 Share this post Link to post Share on other sites
ATGSS 0 Posted December 10, 2019 Thank you very much for your response, at ende , yesterday i was looking for this, and got this code from another post. It is exactly that i need. Thank you very much again! this addAction [ "<t color='#ff9900'>Beber agua!</t>", { execVM "agua.sqf"; (_this select 0) setVariable ["Aguasucia",false]; uiSleep 950; (_this select 0) setVariable ["Aguasucia",true] }, [],1,false,true,"", "_this distance _target < 2 && sunOrMoon > 0.5 && _target getVariable ['Aguasucia',true]" ]; Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted December 12, 2019 On 12/10/2019 at 10:59 AM, ATGSS said: Thank you very much for your response, at ende , yesterday i was looking for this, and got this code from another post. It is exactly that i need. Thank you very much again! this addAction [ "<t color='#ff9900'>Beber agua!</t>", { execVM "agua.sqf"; (_this select 0) setVariable ["Aguasucia",false]; uiSleep 950; (_this select 0) setVariable ["Aguasucia",true] }, [],1,false,true,"", "_this distance _target < 2 && sunOrMoon > 0.5 && _target getVariable ['Aguasucia',true]" ]; This is bound to be exploited by players, since uiSleep continues even when the game is paused. Depending on what you do with your addAction (restore health/thirst etc.) this would allow players to consume something, pause the game, freezing the entire simulation including AI etc, still uiSleep continues to run, making the entire duration of the effect meaningless in terms of gameplay. Better use regular sleep there, if that's what you intend to do. Also I wouldn't use sleep within an addAction, even if it's possible, can open a can of worms pretty quickly once your addActions get a bit more complex. You can pass all objects related to the addAction towards your aqua.sqf and handle all sleep and variable related stuff from there on, prevents unnecessary clutter. Cheers Share this post Link to post Share on other sites
ATGSS 0 Posted December 13, 2019 Ok, thanks very much for the explanation!! . I started recently with the scripts and i'm still learning. I want this script for a coop mission on my clan, (40 players), no pause for you if you go to toilet 😁 . At the beginning , there is a water dispenser to ""hydrate "",ajajajajajaj, then go to combat, and after few minuts , they will feel bad. Normally nobody drinks 2 times. Share this post Link to post Share on other sites