Welcome, Guest. Please login or register.

What openbor you prefer: Double dragon,battletoads or final fight !? by lirexpatrio
[December 07, 2012, 07:15:27 pm]


what are your favorite games OpenBOR?! by lirexpatrio
[December 07, 2012, 07:09:46 pm]


Post Some Awesome Videos by maxman
[December 07, 2012, 05:51:39 pm]


Can @cmd playmusic "aaaa" 1 also increse music sound ? by BeasTie
[December 07, 2012, 05:24:38 pm]


Streets of Rage: Silent Storm by mtrain
[December 07, 2012, 03:45:05 pm]


Site will be down for maintenance on 12/8/2012 thru 12/10/2012 by Damon Caskey
[December 07, 2012, 07:42:42 am]


Cancelled SOR 3d Remake by riccochet
[December 07, 2012, 03:58:33 am]


Dungeon Fighter: B.O.R. by msmalik681
[December 07, 2012, 03:24:27 am]


[TUTORIAL] How to create 4 Games of OpenBOR in 1 CD (650 MB) by magggas
[December 06, 2012, 09:46:25 pm]


custknife by Bloodbane
[December 06, 2012, 09:34:09 pm]


blockfx help by B.Kardi
[December 06, 2012, 04:09:14 pm]


street of age 4 hd by corradlo
[December 06, 2012, 01:41:36 pm]


ClaFan - Classic Fantasy ver 1.17 by soniczxblade
[December 06, 2012, 05:01:20 am]


Bug Archive by Bloodbane
[December 06, 2012, 02:00:44 am]


"Bio-Doom" and "Gears of Doom" by BulletBob
[December 05, 2012, 10:07:21 pm]


Contra Locked 'N' Loaded v2 by Bloodbane
[December 05, 2012, 09:39:43 pm]


Downloadable OpenBoR Manual by BeasTie
[December 05, 2012, 08:31:24 pm]


Having trouble testing changes by B.Kardi
[December 05, 2012, 03:05:53 pm]


DragonBall Absalon by msmalik681
[December 05, 2012, 02:52:13 pm]


[Hi-Res] Swamp by Vibrant
[December 05, 2012, 10:47:14 am]


  • Dot Guests: 129
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.



Author Topic: Playing Sounds via Script + Script Reference  (Read 1023 times)

0 Members and 1 Guest are viewing this topic.

Offline CTAwesome

  • Jr. Member
  • **
  • Posts: 43
Playing Sounds via Script + Script Reference
« on: April 07, 2010, 01:30:10 pm »
Hi there! It seems you guys have finally infected me with scripting. Now I'm trying to find ways of doing things via script rather than hackarounds in the entity animations. :laughing:

Couple quick questions though. Firstly, I was wondering if there was a command to play sounds through script? I'm assuming there is, but I the only thing I can find in the Script Reference is "playsample", which according to the explanation only lets you play an OpenBoRconstant defined sample ("SAMPLE_BEAT", "SAMPLE_GO", etc...) rather than play any sound file in the data directory. What would the command be to play a path defined sound file?

Also, along that same vein, it looks like the Script Reference/Manual may be out of date. It was last updated in September of 2008. This detail first struck me when DC helped me out with the tosstime function (thanks again, DC!). The only thing in the entire thread that seems to be up to date is the Script Events reference, which seems to be the only script reference in the Wiki. Yes, there is a Script Introduction tutorial (which is extremely helpful, by the by), but there isn't an updated Script Reference/Manual like the one utunnels had posted. Is there an update for that in the works?

Offline Damon Caskey

  • Hero Member
  • *****
  • Posts: 5335
    • The Gorge
Re: Playing Sounds via Script + Script Reference
« Reply #1 on: April 07, 2010, 02:01:41 pm »
As you've discovered, playsample plays sounds by index, not by path. So to play a sample, you need its index. Use the loadsample() function. Loadsample will check to see if the sound path you provide is already loaded and returns the index if it is. Otherwise, it loads the sample, gives it an index then passes it.

int iSnd = loadsample({path});

playsample(iSnd,.......)

One thing to note though, you'll want to preload sounds played in game. Else wise the game will freeze for a second or two for the sample to load on the first time it gets played. An easy way to preload sounds is to create  and load a dummy entity that includes whatever sounds you need using the standard sound command.

DC

« Last Edit: April 07, 2010, 02:03:51 pm by Damon Caskey »
OpenBOR Wiki.

Coming Soon:
Spoiler
Fatal Fury Chronicals


Offline MatMan

  • Hero Member
  • *****
  • Posts: 1320
Re: Playing Sounds via Script + Script Reference
« Reply #2 on: September 23, 2012, 01:29:37 pm »
Do the sounds unload automatically once the stage ends?

Offline slash128

  • Jr. Member
  • **
  • Posts: 41
Re: Playing Sounds via Script + Script Reference
« Reply #3 on: September 23, 2012, 04:42:55 pm »
if anyone has a script to do that, please post it.
« Last Edit: September 23, 2012, 04:45:21 pm by slash128 »
bah...werebers...

Offline MatMan

  • Hero Member
  • *****
  • Posts: 1320
Re: Playing Sounds via Script + Script Reference
« Reply #4 on: September 23, 2012, 05:21:10 pm »
check http://lavalit.com:8080/index.php/topic,4477.msg63287.html#msg63287 for a random play script but all you need is...

Code: [Select]
void playsound(int t)
{
    int SFX1 = loadsample("data/sounds/attack1.wav");

    playsample(SFX1, 0, 120, 120, 100, 0);
 
}

Anim idle
   ....
   @cmd playsound 1
   frame .....

Offline slash128

  • Jr. Member
  • **
  • Posts: 41
Re: Playing Sounds via Script + Script Reference
« Reply #5 on: September 26, 2012, 09:16:15 am »
there any way to load any sound sounds folder without implementing it in the script? >:(
bah...werebers...

Offline volcanic

  • Hero Member
  • *****
  • Posts: 706
  • Nobody
Re: Playing Sounds via Script + Script Reference
« Reply #6 on: September 28, 2012, 02:55:21 am »
Strictly, this is the right way to play sound.

void playSound(void file)
{
   if(file&&file!=""){
      void sfx=loadsample(file);
      void vol=openborvariant("effectvol");
      playsample(sfx, 0, vol,vol, 100, 0);
   }
}

Don't forget the system SFX volumn....

Offline slash128

  • Jr. Member
  • **
  • Posts: 41
Re: Playing Sounds via Script + Script Reference
« Reply #7 on: October 30, 2012, 06:38:30 pm »
how i call the script? :(
i try @cmd playsound and @cmd play sample but not work
bah...werebers...

 



 0%




SimplePortal 2.3.3 © 2008-2010, SimplePortal