Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
doomnet

countdown timer with sound file

Recommended Posts

Hi everybody !

 

i'm working on a new script like battlefield bad company 2 rush game mode, to arm, disarm a bomb.

 

after two days of searching, testing, asking help etc....,

i got now a system that works almost as it needs.

when this script is finished, i will release it to the community as there is now no existing public script at the moment, for this game mode.

and a lot of players ask me this game mode.

 

i have now the script working like this:

 

player can arm a bomb, with player animation, arming sound and messages display correctly (takes 5 seconds to arm)

then it fires a 60 seconds countdown timer.

that's all i got for now.

 

how to ad sound with the countdown timer ? and how to set off a bomb when countdown is finished ?

 

here is my code, called via trigger condition. ( i tried using trigger effects to play sound but, it will play only once, that's not what i want.

i tried also to put the sound call here in the code, but it never plays.

if (!isServer) exitWith {};

_countdown = param [0,60];
countdownFinished = false;

for "_i" from 1 to _countDown do
{
    _timeleft = [_countdown - _i] call BIS_fnc_secondsToString;
    [[[_timeLeft],{hintSilent format ["Time left: %1",_this select 0]}],"BIS_fnc_spawn",true] spawn BIS_fnc_MP;
    sleep 1;
};    

countdownFinished = true;

and this is the sound file:

playSound3D [([str missionConfigFile, 0, -15] call BIS_fnc_trimString) + "music\armed.ogg",_this select 1]

also how to stop sound file if other team disarm it with addaction ?

 

thanks already for helping me !!!

Share this post


Link to post
Share on other sites

playSound3D requires an object as its sound source.

playSound3D [([str missionConfigFile, 0, -15] call BIS_fnc_trimString) + "music\armed.ogg",_this select 1]

Is (_this select 1), firstly, passed and secondly, an object?

 

With regards to stopping a sound from being played, I don't think you can stop a sound playing.

However, you could attach an invisible helipad to the bomb and play the sound from that helipad object. If the bomb is defused, then set the helipad's damage to 1, thus stopping the sound.

  • Like 1

Share this post


Link to post
Share on other sites

playSound3D requires an object as its sound source.

playSound3D [([str missionConfigFile, 0, -15] call BIS_fnc_trimString) + "music\armed.ogg",_this select 1]

Is (_this select 1), firstly, passed and secondly, an object?

 

With regards to stopping a sound from being played, I don't think you can stop a sound playing.

However, you could attach an invisible helipad to the bomb and play the sound from that helipad object. If the bomb is defused, then set the helipad's damage to 1, thus stopping the sound.

ok thanks i understand, did not know it has to be an object top play it

i will try with helipad

 

thanks again for your precious help !!!

Share this post


Link to post
Share on other sites

playSound3D requires an object as its sound source.

playSound3D [([str missionConfigFile, 0, -15] call BIS_fnc_trimString) + "music\armed.ogg",_this select 1]

Is (_this select 1), firstly, passed and secondly, an object?

 

With regards to stopping a sound from being played, I don't think you can stop a sound playing.

However, you could attach an invisible helipad to the bomb and play the sound from that helipad object. If the bomb is defused, then set the helipad's damage to 1, thus stopping the sound.

 

I have another question, everything works fine now on local server, but on dedicated server the countdown timer doesn't show up

i know it has something to do with "if isdedicated" but i'm learning and don't know how to use it.

 

so how to make this timer working on dedicated server MP mission and, also syns on all clients ?

it works perfect on local server.

if (!isServer) exitWith {};

_countdown = param [0,60];
countdownFinished = false;

for "_i" from 1 to _countDown do
{
    _timeleft = [_countdown - _i] call BIS_fnc_secondsToString;
    [[[_timeLeft],{hintSilent format ["Time left: %1",_this select 0]}],"BIS_fnc_spawn",true] spawn BIS_fnc_MP;
    sleep 1;
};    

countdownFinished = true;
mdh_nuke_destruction_zone = 0; nuke_activated = true,this,1,true,true,"","isNil'nuke_activated' "
0 = [] execVM "nuke\nuke.sqf"; sleep 5; deleteVehicle _this
"end1" call BIS_fnc_endMission;

help will be much appreciated cause i cannot find some answers

Share this post


Link to post
Share on other sites
_countdown = param [0,60];
countdownFinished = false;

for "_i" from 1 to _countDown do
{
    _timeleft = [_countdown - _i] call BIS_fnc_secondsToString;
    [[[_timeLeft],{hintSilent format ["Time left: %1",_this select 0]}],"BIS_fnc_spawn",true] spawn BIS_fnc_MP;
    sleep 1;
};    

This code snipped is from one of my scripts which I provided in another thread, and it was working fine for me and also for the other user who requested help.

Are you sure you executed the script correctly?

  • Like 1

Share this post


Link to post
Share on other sites
_countdown = param [0,60];
countdownFinished = false;

for "_i" from 1 to _countDown do
{
    _timeleft = [_countdown - _i] call BIS_fnc_secondsToString;
    [[[_timeLeft],{hintSilent format ["Time left: %1",_this select 0]}],"BIS_fnc_spawn",true] spawn BIS_fnc_MP;
    sleep 1;
};    

This code snipped is from one of my scripts which I provided in another thread, and it was working fine for me and also for the other user who requested help.

Are you sure you executed the script correctly?

 

 

yes you are right i find your topic with this countdwon timer, it works perfect thanks, but only on local server, on dedicated the countdown doesn't show up for me.

Share this post


Link to post
Share on other sites

i use this in a trigger to start the countdown:

 

if (hasInterface) then {nul = [] execVM "scripts\countdown.sqf"};nuke_detonate;

 

works perfect on local server

Share this post


Link to post
Share on other sites

This will not work to my understanding, you are checking if the entiy has an interface, and in the countdown script you check if it's running on the server, however, the server has notinterface.

 

I'd remove the hasInterface check and see if that works, because my countdown script was designed to run on the server, do all the calculations and then publish the coundown data to all clients.

  • Like 1

Share this post


Link to post
Share on other sites

i use this in a trigger to start the countdown:

 

if (hasInterface) then {nul = [] execVM "scripts\countdown.sqf"};nuke_detonate;

 

works perfect on local server

 

Can't claim to have much experience with multiplayer, but it might be something to do with hasInterface with a dedicated server.

 

 

R3vo beat me to it again.. 

Edited by hallyg
  • Like 1

Share this post


Link to post
Share on other sites

ok thanks for your help everybody i give it a try immediatly!

;)

Share this post


Link to post
Share on other sites

This will not work to my understanding, you are checking if the entiy has an interface, and in the countdown script you check if it's running on the server, however, the server has not interface (correct me if I'm wrong).

 

I'd remove the hasInterface check and see if that works, because my countdown script was designed to run on the server, do all the calculations and then publish the coundown data to all clients.

 

i removed hasinterface in trigger on Action and Condition, and replaced with :

 

Condition:

(isServer) && {bomb_detonationTime < 999999}

on Action:

if (isServer) then {nul = [] execVM "scripts\countdown.sqf"};nuke_detonate

still works on local server but not on dedicated ?!

is this correct what i'm doing ?

if you want mission test files i can send you np

Share this post


Link to post
Share on other sites

You are checking 3 times if it's running on the server.

 

1. Trigger condition

2. Trigger on activation

3. in the script itself

 

Remove 1 & 2, that won't make the script work but removes some clutter.

 

 

Edit: Is there a reason you are using a trigger ? Because right now you are not using any of the trigger's condition and {bomb_detonationTime < 999999} seems to be something that will always be true. Also, can you check if bomb_detonationTime and countdownFinished return any value via the debug console?

  • Like 1

Share this post


Link to post
Share on other sites

You are checking 3 times if it's running on the server.

 

1. Trigger condition

2. Trigger on activation

3. in the script itself

 

Remove 1 & 2, that won't make the script work but removes some clutter.

 

 

Edit: Is there a reason you are using a trigger ? Because right now you are not using any of the trigger's condition and {bomb_detonationTime < 999999} seems to be something that will always be true. Also, can you check if bomb_detonationTime and countdownFinished return any value via the debug console?

the trigger is part of the countdown script, i did not made it, and its works when i host locally my mission

how to check in debug console ?

countdownFinished is to terminate the countdown and to call a variable for nuke script that uses also other triggers.

 

sometimes i don't know what i'm doing, but why does it work on local host ? and on dedicated ?

its seems its something else causing this in my mission scripts, if you want to help me, i can send you my mission

to look at it better and try it.

because i have no idea to fix this, i'm a noob learning.

 

thanks

Share this post


Link to post
Share on other sites
the trigger is part of the countdown script, i did not made it, and its works when i host locally my mission

The trigger is defintely not part of the script I wrote.

 

 

You can check variables via the debug console. Press escape, you'll see for field which say "watch". Write each variable you want to check in of the fields.

  • Like 1

Share this post


Link to post
Share on other sites
the trigger is part of the countdown script, i did not made it, and its works when i host locally my mission

The trigger is defintely not part of the script I wrote.

 

 

You can check variables via the debug console. Press escape, you'll see for field which say "watch". Write each variable you want to check in of the fields.

 

Look at the topic starter, where you came in to help, grollig placed the triggers like this, with countdown.sqf (https://forums.bistudio.com/topic/184475-jip-dedi-compatible-bombtimer-how-to/).

again i repeat myself but it works perfect on local server. not on dedicated server.

what should i have to look for variables ? because i can look but that will not help me understanding why and what to look for.

If you want to help me check what's going on with variables and how i setup everything in mission i can send you the mission,

that will be easier i think, if you want to off course

 

 

thanks for helping me ! ;)

Share this post


Link to post
Share on other sites
(isServer) && {bomb_detonationTime < 999999}

There is a small mistake in this condition, though, I don't know if it will make any difference

Replace the {} with () brackets

isServer && (bomb_detonatonTime < 999999)
  • Like 1

Share this post


Link to post
Share on other sites

×