Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: calling game sounds?

  1. #1
    Developer Todesengel's Avatar
    Join Date
    Dec 2013
    Location
    St. Louis, Missouri, USA
    Posts
    276

    Default calling game sounds?

    I've never had to put sound in one of my (server-side) mods, and I am attempting to do that. I've read lots of docs but am coming up short in my understanding.

    It seems that if I use something like "playsound bombtick1" for example... that all players (based on distance, etc. etc.) will hear the sound as well as the player it is intended for. What I would like is for the sound to be ONLY heard by the local.player, no one else.

    Can anyone offer some knowledge? Thanks in advance!

    Tode

  2. #2

    Default

    self playsound bombtick1 or whatever sound you want them to hear when it is triggered as long as the sound is from stock game sounds client will not need it.
    Last edited by easymeat; January 26th, 2018 at 11:33 AM.

  3. #3
    Developer Todesengel's Avatar
    Join Date
    Dec 2013
    Location
    St. Louis, Missouri, USA
    Posts
    276

    Default

    Ok, as I understand it... $player is for singleplayer mode, and local.player is multiuser, whatever user entity has been passed to the reborn event.

    So how does "self" relate to that as far as scope and intended use go?

    I guess what I'm trying to ask is, what is the difference between self and player.local, or more specifically "self playsound bombtick1" and "player.local playsound bombtick1" ?

  4. #4
    Developer Todesengel's Avatar
    Join Date
    Dec 2013
    Location
    St. Louis, Missouri, USA
    Posts
    276

    Default

    self doesn't work at all, no sound is heard.
    local.player does work, but everyone (other players) can hear the sound.

    Looking in ubersound, it looks like I could fiddle with the max distance and maps list. It seems the local channel STILL can be heard by everyone, but might try the menu channel - maybe that will be unheard by other players. But then this gets in to - no one can hear the sounds unless I distribute an overwriting ubersound file.

    Surely there is an easy way for the server to play a stock in-game sound to one specific player and no one else?

  5. #5

    Default

    what kind of sound you want the player to hear?
    like a menu sound or something very close in 3d space?


    look at this code, you can get an idea of the difference between local.player and self.


    getPlayers:
    for (local.i = 1; local.i <= $player.size; local.i++) {
    local.player = $player[local.i];
    local.player thread playerSound;
    }
    end;

    playerSound:
    self playsound bombtick1;
    end


    basically self is the name an entity (not just a player) get when is called to a new thread in this way: local.entity thread newThread;

  6. #6
    Purple Developer Purple Elephant1au's Avatar
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    1,269

    Default

    Few things first.

    Self definition and examples >> http://gronnevik.se/rjukan/index.php...Language#toc25
    Code:
    The self object
    
     There is a special object called "self". 
     The "self" object has its value set at the creation of a group of threads. The following are some such situations: 
     Automatically started scripts 
     self is NULL for level scripts. Self is the character for animation scripts. 
     Command: thread label 
     Since the new thread has the same group as the original thread, self in the new thread is equal to self in the original thread. 
     Command: object thread label 
     self in the new thread is set equal to object. 
     Event threads 
     If a thread is initiated in response to an event of an object, then self is set equal to this object.
    Example:
    Code:
    If the thread move was called like 
    $player[1] thread move
    
    self would be $player[1].
    $player refers to an array of all players in the server, so in single player it would be just the one person, in multiplayer, it would be all players, $player[1] would be player 1.

    local.player is NOT a predefined MOHAA variable. It is just a very common variable modders use to describe the player they are using. local. being the scope.
    local.player MUST be defined in the specific scope to be used, most commonly it is defined like
    local.player = parm.other // Mainly used by triggers as parm.other refers to the entity which triggered it.
    local.player = self // Mainly used when scripts are called using that player entity, ie state_files, self is the player.


    Now to your problem.
    NB: Sounds have to be on client-side aswell to be heard.

    Sounds are loaded into a aliascache (see ubersound/ubersound.scr) on mapload.
    Each sound which is used for that particular map or gametype is loaded into the cache.
    It is there that the settings for those sounds are then set. Settings such as sound file, pitch, min and max distance, loaded maps etc.
    Example:
    Code:
    // UBER SOUND FILE
    // Current Format:
    // aliascache (?alias?) snd wavfile soundparms basevol volmod basepitch pitchmod minDist maxDist channel loaded|streamed maps "mapstr1 mapstring2 mapstring3 ..."
    aliascache bombtick1 sound/items/Item_Timer_01.wav soundparms 0.7 0.0 1.0 0.0 10000 10000 local loaded maps "m1l2a m2 m3 m4l3 m5 m6l1 m6l3d dm moh obj train"
    The alias for that sound file is bombtick1. Note how the min and max are set quite high, that is what makes all players be able to hear it. Distance is set from the object the sound is playing from.

    An example of a way to *kinda* make it play for one person is
    https://www.x-null.net/forums/showth...1313-Playsound

    So instead of distributing a new ubersound.scr, you just need to create a new sound alias with your settings and use that.
    Code:
    local.master = spawn ScriptMaster
    local.master aliascache beep sound/items/final_countdown.wav soundparms 0.1 0.0 1.0 0.0 100 100 voice loaded maps "m dm obj"
    local.player playsound beep
    If you read Veers comment on that thread, is that it can still sometimes get bugged. AFAIK that is the only way to make it play for one person. Maybe it is something we can add to the patch?, maybe.
    Last edited by Purple Elephant1au; January 26th, 2018 at 04:29 PM.

    Purple's Playground
    OBJ :
    103.29.85.127:12203
    xfire: purpleelephant1au
    email: purpleelephant1au@gmail.com
    skydrive: PurpleElephantSkydrive




  7. #7

    Default

    using "local" instead of voice is better suited for local sounds.

  8. #8
    Developer Todesengel's Avatar
    Join Date
    Dec 2013
    Location
    St. Louis, Missouri, USA
    Posts
    276

    Default

    Purple - I know how the ubersound files work, but I never would have thought of setting an aliascache in my own code so I don't have to distribute (ie. conflict) with someone elses mod or the base game version. Sweet. And i can set my own maplist and sound parameters too. Perfect!

    I'm going to experiment with the xDist settings, but will also experiment with local and menu channels. Sounds I saw that were using local I am pretty sure I hear from other players. I am curious if sounds using the 'menu' channel are automagically strictly local.

    Thanks so much for your sage advice... and teaching a guy to fish Very much appreciated.

    T

  9. #9
    Developer Todesengel's Avatar
    Join Date
    Dec 2013
    Location
    St. Louis, Missouri, USA
    Posts
    276

    Default

    This is about the same mod I am writing, so I'm putting it in the same thread. "Life" pulled me away from mohaa for a few weeks, but I'm trying to get back to it. Still need to test the above sound setup, as it doesn't seem to get aliascache set properly - I think a scope issue again But while I'm working on that....

    Does anyone know where example code lurks as to how the flags (axis vs. allies) are attached above a player, and follow them around (and how to remove them during a map)? I believe I saw an example a while back when looking for something else, but now that I'm looking for it I can't find it. Specifically, I'd like to replace the flag with a different graphic.....

    Thanks in advance for any tips or pointers!

    T

  10. #10
    Developer RyBack's Avatar
    Join Date
    Apr 2014
    Location
    In Front of the screen
    Posts
    1,603

    Default

    it's a func_beam IIRC.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •