Jump to content
XxAsathorxX

Can someone help me with that Script?

Recommended Posts

Can someone help me please?

I have he followig problem with a script that i found in the forums. Original Script: https://forums.bistudio.com/forums/topic/170735-wilhelm-scream/ .
My customized Version:
//resistancecheck.sqf
{
if (side _x == resistance) then {
KilledUnit = _x addeventhandler ["killed", {_soundPath = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString; _randscream = ["sounds\death_scream_1.wav","sounds\death_scream_2.wav","sounds\death_scream_3.wav","sounds\death_scream_4.wav","sounds\death_scream_5.wav",
"sounds\death_scream_6.wav","sounds\death_scream_7.wav","sounds\death_scream_8.wav","sounds\death_scream_9.wav","sounds\death_scream_10.wav",
"sounds\death_scream_11.wav","sounds\death_scream_12.wav","sounds\death_scream_13.wav","sounds\death_scream_14.wav"];
_soundToPlay = _soundPath + (_randscream call BIS_fnc_selectRandom); playSound3D [_soundToPlay, (_this select 0), false, getPos (_this select 0), 10, 1, 50];}];
KilledUnit = _x addeventhandler ["killed", {nul = _this execVM "scripts\resistancekilled.sqf"}];
};
} forEach allUnits;

I can´t get it to work. The script should work as following:
check if unit of side resistance was killed,
then play a random "deathscream".
Second script works without problems just the screams don´t work.

Share this post


Link to post
Share on other sites

Pretty clumsy integration, on top of that this won't work with spawned units.

Since playSound3d will automatically be broadcast to all clients execute this on server only, best place to put it would be initServer.sqf.

To take care of dynamically spawned units use a mission eventhandler, so you won't need any loops if that's the case.

Your KilledUnit variable is a bit misleading, since the addEventhandler command returns the event ID, not the unit object, in case that's not intentional.

 

Would look like this:

//initServer.sqf

addMissionEventHandler ["entityKilled",{
params ["_unit"];

if !(side group _unit isEqualTo resistance) exitWith {false};

_soundPath = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString; _randscream = ["sounds\death_scream_1.wav","sounds\death_scream_2.wav","sounds\death_scream_3.wav","sounds\death_scream_4.wav","sounds\death_scream_5.wav",
"sounds\death_scream_6.wav","sounds\death_scream_7.wav","sounds\death_scream_8.wav","sounds\death_scream_9.wav","sounds\death_scream_10.wav",
"sounds\death_scream_11.wav","sounds\death_scream_12.wav","sounds\death_scream_13.wav","sounds\death_scream_14.wav"];
_soundToPlay = _soundPath + (_randscream call BIS_fnc_selectRandom); playSound3D [_soundToPlay, _unit, false, getPos _unit, 10, 1, 50];

nul = _this execVM "scripts\resistancekilled.sqf"

}];

Small issue could be the side of the dead unit, so I'm using the group of the unit to detect the side, since all dead units belong to the civilian side.

You could handle the side detection differently, maybe pull the units side out of the config or with a setVariable/getVariable approach, but this should work just fine.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

set the volume to 1, not 10 and increase the distance.

With the distance set to 50 this means that's the furthest the sound will be played, so at 50 meters the sound will be almost inaudible.

Try setting the distance to 300-400 and go from there.

 

Cheers

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×