Jump to content
  • 0
Sign in to follow this  
ftshill

Start music only as new spawn

Question

Currently on my server I have added start music. Every time you load into the server you are greeted by the start music which play for around 10-20 seconds. Some players have been complaining that the music can be distracting if they are loading into a sticky situation. Therefore I have been trying to find a way to only make the music play when the player is a new spawn. E.g. has no gear and is at one of the starting spawn.

If anyone has any ideas how to achieve this, please help me out!  :)

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

In your init.sqf;

if (!isNil "playersLoaded") then { playersLoaded = [];};

In your script that executes the sound;

if (!((getPlayerUID player) in playersLoaded)) then {
    //play sound code goes here
    playersLoaded = playersLoaded + [(getPlayerUID player)];
    publicVariable "playersLoaded";
};

In your publicvariable.txt add to the first line (The one that has 5 "");

!="playersLoaded"

This SHOULD work, but is untested as I just wrote it now :)

 

ALTERNATIVELY!

 

You could also optimise this to be more friendly on network traffic by using publicVariableServer calls.

 

In your server_functions.sqf;

if (isNil "serverPlayersLoaded") then { serverPlayersLoaded = [];};

fnc_HandleLoadedPlayers = {
    private ["_vars","_uid","_owner"];
    _vars = _this select 1;
    _uid = _vars select 0;
    _owner = _vars select 1;
    if (!(_uid in serverPlayersLoaded)) then {
        serverPlayersLoaded = serverPlayersLoaded + [_uid];
        serverHasUID = true;
        _owner publicVariableClient "serverHasUID";
    };
};

"serverCheckUID" addPublicVariableEventHandler fnc_HandleLoadedPlayers;

In your script that spawns the sounds;

if (isNil "serverHasUID") then { serverHasUID = false; };

serverCheckUID = [(getPlayerUID player),owner player];
publicVariableServer "serverCheckUID";

if (!serverHasUID) then {
    // play sound
};

This will make sure that the server only sends the network message to the client requesting it, instead of all clients simultaneously. Dont forget to add this in your publicvariable.txt;

!="serverCheckUID" !="serverHasUID"

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Similar Content

    • By palladiumm
      I have been able to add zombie spawners and such to epoch, so i have had success adding items in mission.sqm.  I am trying to make an area trigger that plays music when players enter it. I have created it in the editor and it works fine. I just cannot seem to get it to work on the epoch server. I placed code into the description.ext and i think that code is bad, and maybe the copied code for mission.sqm needs to be changed.
      Can someone please post a complete one? (Just the parts I need, not a complete mission.sqm, or description.ext, unless you want to) So I can study it? I wont be able to modify an existing "safe zone dome" code or other code, as i have worked on this for 3 days. I have seen multiple posts, most of which were for "Arma2" Epoch. I have really worked at this and just cant get it. Please help.
      Also, i did make an intro music for my epoch server, and it works great. So, i have a CfgSounds area in description.ext, and i was putting the trigger into a Sensors area below Items in mission.sqm.
      Thank You for any help
    • By Fabian Mueller
      Hello Community,
      today i updated the Server to the 0.3.8.0 and now i have this error:
      Warning Message: Script \x\addons\a3_epoch_code\init\fn_init.sqf not found
      I tryed a fresh Installation but the same error.
      I hope you can help me :)
       
      Sorry for my Englisch ;)
      Hello from Germany ;)
    • By turtles
      Hello Epoch Community,
       
      I do not know much about scripting besides the basics. I am trying to add music that will play when AI hunt down players. I want the music to be played global, and I don't want the music to overlap every time an additional AI patrol joins in to hunt a player. 
      Now, I have tried using tons of scripts on the internet which show the basics of how to play sounds, but no matter what I do I cannot get them to play with AI reinforcements.
      I have a private server for me and just a few friends, so I want the music to be global. I have the AI as police so I was thinking something like PayDay music to play when cops start chasing the players. I have tried tons of different code but nothing happens. If anyone could help that would be great. If you could also give a step by step guide that would be incredible, because I know little to nothing about where to put the lines of code and stuff.
    • By rav009
      In my server,I only install the epoch mod and DZMS mod.
      But no missions were started or showed on map after I entered the game. Is it necessary to start a mission by the server admin manually?Or it will start automatically, so I need be patient?
       
      Please help, thanks.
    • By unerground2
      Hello i would like to bring back the random scenery sounds from arma2 Dayz to my epoch server.
       
      https://www.youtube.com/watch?v=WicdjM0aE5w
       
      Does anyone have a script that plays sound files randomly???
       
  • Advertisement
  • Supporters
  • Discord

×
×
  • Create New...