Kurewe

Having trouble with playing a sound

5 posts in this topic

So, I had this silly idea to customize the ExileServer_object_player_event_onMpKilled.sqf so that a sound would play on a Bambi kill as well as a Team kill. My initial test is not going as well as I had hoped. I do not receive any errors or warnings in my RPT. I even setup a diag_log to to verify that the proper variable was being passed through and that the IF statement itself was working. The diag_log entry appears in the RPT and it is giving me the correct variable values. So, that tells me that the IF statement is working. However, the sound just doesn't play. I've also made sure that my .ogg files were under 50k. Could it be volume? I'm stumped...

Added to my description.ext

Spoiler

class CfgSounds
{
  sounds[] = {bambikill,teamkill};
    class bambikill
    {
        name = "bambikill";
        sound[] = {"bk.ogg", 1, 1};
        titles[] = {};
    };
    class teamkill
    {
        name = "teamkill";
        sound[] = {"tk.ogg", 1, 1};
        titles[] = {};
    };
};


This is my ExileServer_object_player_event_onMpKilled.sqf
I added _killCase on line 12.
I assigned _killCase a value of 0 on line 22.
I added _killcase values for each of the _killType cases on lines 65, 74, 83, 94, 102, 112 & 123.
I added my IF statement at line 237

Spoiler

/**
 * ExileServer_object_player_event_onMpKilled
 *
 * Exile Mod
 * exile.majormittens.co.uk
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_victim","_killer","_countDeath","_countKill","_killSummary","_killingPlayer","_killType","_oldVictimRespect","_newVictimRespect","_oldKillerRespect","_newKillerRespect","_killCase","_systemChat","_modifyVictimRespect","_respectLoss","_perks","_minRespectTransfer","_respectTransfer","_perkNames","_killerStatsNeedUpdate","_newKillerFrags","_victimStatsNeedUpdate","_newVictimDeaths","_victimPosition","_weapon","_txt"];
_victim = _this select 0;
_killer = _this select 1;
if (!isServer || hasInterface || isNull _victim) exitWith {};
_victim setVariable ["ExileDiedAt", time];
if !(isPlayer _victim) exitWith {};
_victim setVariable ["ExileIsDead", true]; 
_victim setVariable ["ExileName", name _victim, true]; 
_countDeath = false;
_countKill = false;
_killCase = 0;
_killSummary = [];
_killingPlayer = _killer call ExileServer_util_getFragKiller;
_killType = [_victim, _killer, _killingPlayer] call ExileServer_util_getFragType;
_oldVictimRespect = _victim getVariable ["ExileScore", 0];
_newVictimRespect = _oldVictimRespect;
_oldKillerRespect = 0;
if !(isNull _killingPlayer) then 
{
    _oldKillerRespect = _killingPlayer getVariable ["ExileScore", 0];
};
_newKillerRespect = _oldKillerRespect;
switch (_killType) do 
{
    default 
    {
        _countDeath = true;
        _systemChat = format ["%1 died for an unknown reason!", name _victim];
        _newVictimRespect = _oldVictimRespect - round ((abs _oldVictimRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "unlucky")));
    };
    case 1:
    {
        private["_zombieKill"];
        _victimPosition = position _victim;
        _bystanders = _victimPosition nearEntities ['Man',5];
        _zombieKill = false;
        {
            _zombieKill = getText(configFile >> 'CfgVehicles' >> typeOf _x >> 'author') isEqualTo 'Ryan';
        } forEach _bystanders;
        
        if(_zombieKill) then
        {
        _countDeath = true;
        _modifyVictimRespect = true;
        _zombieDeath = selectRandom ["was killed", "was eaten"]; //Add more messages here to change the killed text
        _systemChat = format ["%1 %2 by a zombie!", name _victim, _zombieDeath];
        _newVictimRespect = _oldVictimRespect - round ((abs _oldVictimRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "suicide")));
        }
        else
        {
        
        _countDeath = true;
        _modifyVictimRespect = true;
        _killCase = 0;
        _systemChat = format ["%1 commited suicide!", name _victim];
        _newVictimRespect = _oldVictimRespect - round ((abs _oldVictimRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "suicide")));
        };
    };
    case 2:
    {
        _countDeath = true;
        _countKill = false;
        _killCase = 0;
        _systemChat = format ["%1 died while playing Russian Roulette!", name _victim];
        _newVictimRespect = _oldVictimRespect; 
        _victim call ExileServer_system_russianRoulette_event_onPlayerDied;
    };
    case 3:
    {
        _countDeath = true;
        _countKill = false;
        _killCase = 0;
        _systemChat = format ["%1 crashed and died!", name _victim];
        _newVictimRespect = _oldVictimRespect - round ((abs _oldVictimRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "crash")));
    };
    case 4:
    {
        _countDeath = true;
        _countKill = false;
        _weapon = currentWeapon _killer;
    _txt = (gettext (configFile >> 'cfgWeapons' >> _weapon >> 'displayName'));
        _npcDeath = selectRandom ["was killed", "was murdered", "got wrecked", "got owned", "was smoked"]; //Add more messages here to change the killed text
        _killCase = 0;
        _systemChat = format ["%1 %2 by %3 with a %4 from %5 meters away!", name _victim, _npcDeath, name _killer, _txt,  floor(_victim distance _killer)];
        _newVictimRespect = _oldVictimRespect - round ((abs _oldVictimRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "npc")));
    };
    case 5:
    {
        _countDeath = false;
        _countKill = false;
        _killCase = 1;
        _systemChat = format ["%1 was team-killed by %2!", name _victim, name _killingPlayer];
        _respectLoss = round ((abs _oldKillerRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "friendyFire")));
        _newKillerRespect = _oldKillerRespect - _respectLoss;
        _killSummary pushBack ["FRIENDLY FIRE", -1 * _respectLoss];
    };
    case 6:
    {
        _countDeath = false;
        _countKill = false;
        _killCase = 1;
        _systemChat = format ["%1 was killed by %2! (BAMBI SLAYER)", name _victim, name _killingPlayer];
        _respectLoss = round ((abs _oldKillerRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "bambiKill")));
        _newKillerRespect = _oldKillerRespect - _respectLoss;
        _killSummary pushBack ["BAMBI SLAYER", -1 * _respectLoss];
    };
    case 7:
    {
        private["_weapon","_weaponDisplayName","_weaponScope","_weaponScopeDisplayName"];
        _countDeath = true;
        _countKill = true;
        _killCase = 0;
        _perks = [_victim, _killer, _killingPlayer] call ExileServer_util_getFragPerks;
        _minRespectTransfer = getNumber (configFile >> "CfgSettings" >> "Respect" >> "minRespectTransfer");
        _respectTransfer = round ((abs _oldVictimRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "frag")));
        _weapon = currentWeapon _killer;
        _weaponDisplayName = getText (configfile >> "CfgWeapons" >> _weapon >> "displayName");
        _weaponScope = ""; 
        _weaponScope = (_killer weaponAccessories currentMuzzle _killer) select 2;
        if!(_weaponScope isEqualTo "") then 
        { 
            _weaponScopeDisplayName = getText (configfile >> "CfgWeapons" >> _weaponScope >> "displayName"); 
        } 
        else 
        { 
        _weaponScopeDisplayName = "Iron Sights"; 
        };
        if (_respectTransfer < _minRespectTransfer) then
        {
            _respectTransfer = _minRespectTransfer;
        };
        _newVictimRespect = _oldVictimRespect - _respectTransfer;
        _newKillerRespect = _oldKillerRespect + _respectTransfer;
        _killSummary pushBack ["ENEMY FRAGGED", _respectTransfer];
        if (_perks isEqualTo []) then 
        {
            _systemChat = format ["%1 was killed by %2 with a %3 from %4 meters away!", name _victim, name _killingPlayer, _weaponDisplayName, floor(_victim distance _killer)];
        }
        else 
        {
            _perkNames = [];
            {
                _perkNames pushBack (_x select 0);
                _killSummary pushBack _x;
                _newKillerRespect = _newKillerRespect + (_x select 1);
            } 
            forEach _perks;
            _systemChat = format ["%1 was killed by %2 with a %3 from %4 Meters! (%5)", name _victim, name _killingPlayer, _weaponDisplayName, floor(_victim distance _killer), _perkNames joinString ", "];
        };
    };
};

if !(isNull _killingPlayer) then 
{
    if !(_killSummary isEqualTo []) then 
    {    
        [_killingPlayer, "showFragRequest", [_killSummary]] call ExileServer_system_network_send_to;
    };
};

if !(isNull _killingPlayer) then 
{
    _killerStatsNeedUpdate = false;
    if (_countKill) then
    {
        _newKillerFrags = _killingPlayer getVariable ["ExileKills", 0];
        _newKillerFrags = _newKillerFrags + 1;
        _killerStatsNeedUpdate = true;
        _killingPlayer setVariable ["ExileKills", _newKillerFrags];
        format["addAccountKill:%1", getPlayerUID _killingPlayer] call ExileServer_system_database_query_fireAndForget;
    };
    if !(_newKillerRespect isEqualTo _oldKillerRespect) then 
    {
        _killingPlayer setVariable ["ExileScore", _newKillerRespect];
        _killerStatsNeedUpdate = true;
        format["setAccountScore:%1:%2", _newKillerRespect, getPlayerUID _killingPlayer] call ExileServer_system_database_query_fireAndForget;
    };
    if (_killerStatsNeedUpdate) then 
    {
        _killingPlayer call ExileServer_object_player_sendStatsUpdate;
    };
};

_victimStatsNeedUpdate = false;

if (_countDeath) then
{
    _newVictimDeaths = _victim getVariable ["ExileDeaths", 0];
    _newVictimDeaths = _newVictimDeaths + 1;
    _victim setVariable ["ExileDeaths", _newVictimDeaths];
    _victimStatsNeedUpdate = true;
    format["addAccountDeath:%1", getPlayerUID _victim] call ExileServer_system_database_query_fireAndForget;
};

if !(_newVictimRespect isEqualTo _oldVictimRespect) then 
{
    _victim setVariable ["ExileScore", _newVictimRespect];
    _victimStatsNeedUpdate = true;
    format["setAccountScore:%1:%2", _newVictimRespect, getPlayerUID _victim] call ExileServer_system_database_query_fireAndForget;
};

if (_victimStatsNeedUpdate) then 
{
    _victim call ExileServer_object_player_sendStatsUpdate;
};

if ((vehicle _victim) isEqualTo _victim) then 
{
    if !(underwater _victim) then 
    {
        if !(_victim call ExileClient_util_world_isInTraderZone) then 
        {
            _victim call ExileServer_object_flies_spawn;
        };
    };
};

if !(_systemChat isEqualTo "") then 
{
    if ((getNumber (configFile >> "CfgSettings" >> "KillFeed" >> "showKillFeed")) isEqualTo 1) then 
    {
        ["systemChatRequest", [_systemChat]] call ExileServer_system_network_send_broadcast;
    };
};

if (_killCase > 0) then
{
    playSound "bambikill";
    diag_log format ["### COG: The Shame sound should have played if this message is here. killCase Value Was: %1. killType Value Was: %2. ###", _killCase, _killType];
};

if !(_systemChat isEqualTo "") then 
{
    if ((getNumber (configFile >> "CfgSettings" >> "Logging" >> "deathLogging")) isEqualTo 1) then
    {
        "extDB2" callExtension format["1:DEATH:%1", _systemChat];
    };
};

_victimPosition = getPos _victim;
format["insertPlayerHistory:%1:%2:%3:%4:%5", getPlayerUID _victim, name _victim, _victimPosition select 0, _victimPosition select 1, _victimPosition select 2] call ExileServer_system_database_query_fireAndForget;
format["deletePlayer:%1", _victim getVariable ["ExileDatabaseId", -1]] call ExileServer_system_database_query_fireAndForget;
true

 

Share this post


Link to post
Share on other sites

I think the issue you're having is that this file is a serverside file so you're effectively trying to play that sound on the server, not the client.

Share this post


Link to post
Share on other sites
Advertisement
17 hours ago, kuplion said:

I think the issue you're having is that this file is a serverside file so you're effectively trying to play that sound on the server, not the client.

I was doing some digging and found a post from someone who was having trouble getting a triggered sound to play for the clients. The suggested fix, which seemed to work for him was to change his playsound line to "soundclass" remoteExec ["playSound"];

Can't hurt to try that in this case. However, am I over-thinking this? 

Share this post


Link to post
Share on other sites

@kuplion I just tested  "bambikill" remoteExec ["playSound"]; as opposed to the playsound "bambikill"; that I used originally and IT WORKED!
The volume was very low, but I heard the sound. Now, I am just going to adjust the volume in the description.ext until the volume is right.

  • Like 1

Share this post


Link to post
Share on other sites
4 minutes ago, Kurewe said:

@kuplion I just tested  "bambikill" remoteExec ["playSound"]; as opposed to the playsound "bambikill"; that I used originally and IT WORKED!
The volume was very low, but I heard the sound. Now, I am just going to adjust the volume in the description.ext until the volume is right.

Nicely done! :D

  • Like 1

Share this post


Link to post
Share on other sites
Advertisement

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

  • Recently Browsing   0 members

    No registered users viewing this page.