Jump to content
  • 0

Fatigue script+sound


bombajack

Question

Hello.

 

 

Im total noob in scripting.This is my first try of script...where have i mistake?

 

In init i have this : [] execVM "scripts\tired.sqf";

 

 

Can anyone help with this?

 

 

getFatigue player;

if (getFatigue player > 25) 
Then { 

playSound "sounds\heartBeat.ogg";
player sideChat "I'm very tired,need break!" 

};

 

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

It need a loop function.

and need define sound file to description.ext.

 

description.ext :

class cfgSounds
{
    sounds[] =
    {
	heartBeat
    };
	class heartBeat
	{
        	name = "heartBeat";
        	sound[] = {"sounds\heartBeat.ogg",0.2,1}; 
		titles[] = {};
	};
};

tired.sqf :

waitUntil {!isNull (findDisplay 46)};	
waitUntil {typeOf player != "VirtualMan_EPOCH"};

while {alive player} do {
	if (getFatigue player > 0.25) then {
		playSound "heartBeat";
		systemChat "I'm very tired. Need break!";
	};
	
	sleep 10;
};
Link to comment
Share on other sites

  • 0

 

It need a loop function.

and need define sound file to description.ext.

 

description.ext :

class cfgSounds
{
    sounds[] =
    {
	heartBeat
    };
	class heartBeat
	{
        	name = "heartBeat";
        	sound[] = {"sounds\heartBeat.ogg",0.2,1}; 
		titles[] = {};
	};
};

tired.sqf :

waitUntil {!isNull (findDisplay 46)};	
waitUntil {typeOf player != "VirtualMan_EPOCH"};

while {alive player} do {
	if (getFatigue player > 0.25) then {
		playSound "heartBeat";
		systemChat "I'm very tired. Need break!";
	};
	
	sleep 10;
};

maybe  must be 

sound[] = {"\sounds\heartBeat.ogg",0.2,1};

right?

Link to comment
Share on other sites

  • 0

 

It need a loop function.

and need define sound file to description.ext.

 

description.ext :

class cfgSounds
{
    sounds[] =
    {
	heartBeat
    };
	class heartBeat
	{
        	name = "heartBeat";
        	sound[] = {"sounds\heartBeat.ogg",0.2,1}; 
		titles[] = {};
	};
};

tired.sqf :

waitUntil {!isNull (findDisplay 46)};	
waitUntil {typeOf player != "VirtualMan_EPOCH"};

while {alive player} do {
	if (getFatigue player > 0.25) then {
		playSound "heartBeat";
		systemChat "I'm very tired. Need break!";
	};
	
	sleep 10;
};

 

nice idea, but ... im not sure why you want all these waituntil's also this will spam the chat when the player is tierd.

perhaps set a timer, something like this:

_msg = true;
_nextmsgtime = 300;

_diag_tickTime = 0;
while {alive player} do {
	if (getFatigue player > 0.25) then {
		playSound "heartBeat";
​		if(_msg || (diag_tickTime - _diag_tickTime) > _nextmsgtime)then{
			systemChat "I'm very tired. Need break!";
			_msg = false;
			_diag_tickTime = diag_tickTime;
		};
	}else{
		_msg = true;
	};
	sleep 10;
};

also, when you use alive player, you might want to add some way to re-execute the loop if the player is revived

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...