Home   Help Search Login Register  

Author Topic: Play diffeent music for each player.  (Read 1357 times)

0 Members and 2 Guests are viewing this topic.

Offline D.murphy man

  • Members
  • *
  • I'm a llama!
Play diffeent music for each player.
« on: 24 Jun 2005, 12:54:49 »
Hey guys been a long while since i posted here at OFPEC. But i need a answer that despratly needs answering.

Is it possible for differet music to be played via 'playmusic' command on each persons machine. As i have a script that changes the music every time some action is about to happen, and the players for the mijority of the mission will be split up over the island. So for example if one player is being attacked i dont want the other player the other side of the island hearing the 'action' music but the idle music.

cheers,
   Murphy

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Play diffeent music for each player.
« Reply #1 on: 24 Jun 2005, 15:04:06 »
if (player == W1 && boolean)then{run code A}else{run B code}



the above line queries if the player is a unit which you named in the mission editor and you can make the boolean variable true or false which will decide if boolean is true, code A will be run and if not code B will be

you havent given enough info to answer your question fully

other options could be
Place the unit in "Globalarray" when you want code A running

if(player in Globalarray)thenthen{run code A}else{run B code}

lots of different ways of schieving what you want
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline D.murphy man

  • Members
  • *
  • I'm a llama!
Re:Play diffeent music for each player.
« Reply #2 on: 24 Jun 2005, 15:25:57 »
Thanks for your answer, im glad to know its possible.
Sorry that i didnt supply enough info, heres the code from 3 of my scripts that manage the music and when to change. If you can suggest the best possible way to make it play seprately for each unit ill be very greatful  ;D

Init.sqs - sets two improtant varibles, that are used for the scripts to know when to deactivate and reactivate depending on whats happening.
Code: [Select]
0 setfog 1

[] exec "randommusic.sqs"
[] exec "AttackMusic.sqs"
PauseAttackTracks=1
PauseTracks=0


RandomMusic.sqs - This plays a randomly selected track whiles nothing intresting it happening.
Code: [Select]
#loop
?(PauseTracks==0):goto "start"
~1
goto "loop"

#start
?_PauseTracks==1:goto "loop"
_songs = ["DropsofSilence","TheSuicidalClockChime","IntotheDepthsofSelfDiscovery","Betrayal","DustmanSewer"]
_rndsong = random (count _songs)
_rndsong = _rndsong - (_rndsong mod 1)    
_song = _songs select _rndsong
~2
?_rndsong==0:goto "Depths"
~1
?_rndsong==1:goto "Suicidal"
~1
?_rndsong==2:goto "Drops"
~1
?_rndsong==3:goto "Bet"
~1
?_rndsong==4:goto "Dust"
~1
?_rndsong==5:goto "Dust"
hint "Exit!"
exit

#Drops
playmusic _song
0 fademusic 0.5
_backtoloop=0
#lilloop
_backtoloop=_backtoloop+1
?_backtoloop==164:5 fademusic 0;PauseTracks==1;goto"Start"
?(PauseTracks==1):5 fademusic 0;goto "loop"
~1
goto "lilloop"



#Suicidal
playmusic _song
0 fademusic 0.5
_backtoloop=0
#lilloop5
_backtoloop=_backtoloop+1
?_backtoloop==60:5 fademusic 0;PauseTracks==1;goto"Start"
?(PauseTracks==1):5 fademusic 0;goto "loop"
~1
goto "lilloop5"

#Depths
playmusic _song
0 fademusic 0.5
_backtoloop=0
#lilloop2
_backtoloop=_backtoloop+1
?_backtoloop==165:5 fademusic 0;PauseTracks==1;goto"Start"
?(PauseTracks==1):5 fademusic 0;goto "loop"
~1
goto "lilloop2"

#Bet
playmusic _song
0 fademusic 0.5
_backtoloop=0
#lilloop3
_backtoloop=_backtoloop+1
?_backtoloop==140:5 fademusic 0;PauseTracks==1;goto"Start"
?(PauseTracks==1):5 fademusic 0;goto "loop"
~1
goto "lilloop3"

#Dust
playmusic _song
0 fademusic 0.5
_backtoloop=0
#lilloop4
_backtoloop=_backtoloop+1
?_backtoloop==287:5 fademusic 0;PauseTracks==1;goto"Start"
?(PauseTracks==1):5 fademusic 0;goto "loop"
~1
goto "lilloop4"

MultiSpawner.sqs - this spawns zombies, when zombies are spawned the varibles 'pausetracks' = 1 and 'pauseAttackTracks' = 0. activating the fade out of the idle music and the fade in of the scary attack music.
Code: [Select]
;Script orginially from the 'Zombie Mod FAQ' in the mission editing section of the BI forums.Topic can befound at http://www.flashpoint1985.com/cgi-bin/ikonboard311/ikonboard.cgi?s=b4c8ddb3d187b8119df98fed18cf525c;act=ST;f=7;t=42005;st=0
;Script edited to spawn waves of zombies by D.Murphy man (AkA Shell_Sh0ck) from the BI forums.

;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

;Dont Change these!
_timetoexit=0
_zombiesleft=1
_ZombieGroupLeader=leader _zombiegroup
;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

;Activate the following with [object,Group,numberofwaves,Delay,Playername,startdistance,Distanceexit] exec "Multispawner.sqs" In the activation line of a trigger or Init of an object in your mission.

;object=put a name,The location where the zombies spawn

;Group=put a group name,The group the zombies join when spawned (place a soldier on a far of island and name him)

;Numberofwaves=put a real number 0 to infinite OR type Forever..Number of times a zombie group will spawn each time the last group dies, Typeing 'Forever' will spawn zombie waves at an unlimited amount intill player moves out of set 'distanceexit'.

;Delay=Put a real number 0 to infinite..number of seconds to wait inbetween each wave.

;PlayerName=Put a players or AI name that will be activating the script

;startdistance=real number 0 to infite.. Number of meters away from PlayerName has to be from Object intill zombies spawn

;Distanceexit=Real number 0 to infinite.. Number of meters away playerName has to be from object intill allzombies are deleted and scripts exits (handy for keeping lag down)

;Example: [GameLogicName1,ZombieGroup1,5,4,player1,200,200] exec "Multispawner.sqs"



_trig=_this select 0

_zombiegroup=_this select 1

_spawnwaves=_this select 2

_Delay=_this select 3

_playerTarget=_this select 4

_startdistance=_this select 5

_ExitDistance=_this select 6
;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

;Check too see if player is within range to start spawning.
#checkattack
? _playertarget distance _trig < _startdistance :PauseAttackTracks=0;goto "attack"
~1
goto "checkattack"

;Sets the types and number of units to spawn (maximum of 11 zombies only, due to OFPs units in squad limit of 12), also adds 1 to _timetoexit varible if 'Forever' isint active, when this varible is equal to the previously set amount of zombie waves it will exit
#Attack
~_Delay
_timetoexit=_timetoexit+1
_zombiesIwannaspawn = ["zombieex1", "zombieex2", "zombieex3", "zombieex4", "zombieex5", "zombieex6", "Zombieexwoman1", "zombieexwoman4", "zombieexwoman3", "zombieex7", "Zombieex8", "Zombieex9"]

;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
_AllSpawned = 0
;Loops over and over intill all zombies in the array above are created.Also checks to see if _timetoexit is greater to _Spawnwaves, if so it jumps to check2.
#loop
?_timetoexit>_spawnwaves:PauseAttackTracks=1;goto "check2"
? _AllSpawned >= count _zombiesIwannaspawn: goto "check"
_Zombie = _zombiesIwannaspawn select _AllSpawned
?local Server:_Zombie CreateUnit [getpos _trig, _zombiegroup]
~1
_AllSpawned = _AllSpawned + 1
goto "loop"

;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

;Checks to see how many units are alive in the group, when it reaches 1 it spawns the zombies again (as the last one will be the unit on a far off location with the group name, and thus should not be gettin killed)
;Also checks too see if the player distance from the spawning object is greater then _ExitDistance. If so the script will jump back to 'Attack'
#check
? _zombiesleft == count units _zombiegroup:goto "Attack"
? _trig distance _PlayerTarget > _ExitDistance:{_x setdammage 1} foreach units _ZombieGroup;PauseAttackTracks=1;PauseTrack=0;goto "checkattack"
~1
goto "check"

;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
;checks too see if the player distance from the spawning object is greater then _ExitDistance. If so the script will jump back to 'Attack'
#Check2
? _trig distance _PlayerTarget > _ExitDistance:{_x setdammage 1} foreach units _ZombieGroup;PauseTrack=0;PauseAttackTracks=1;goto "checkattack";
~1
goto "check2"

AttackMusic.sqs-this plays the attacking music, when the varible 'pauseattacktracks' = 0.
Code: [Select]
#start
?(PauseAttackTracks==0):goto "begin"
~1
goto "start"
#begin
_PauseTracks=1
5 fademusic 0
_Asongs = ["AshesandGhost","TheDarknessThatLurksInOurMinds","SilentHeaven","BlackFairy"]
_Arndsong = random (count _Asongs)
_Arndsong = _Arndsong - (_Arndsong mod 1)    
_Asong = _Asongs select _Arndsong
~4
?_Arndsong==0:goto "Ash"
~1
?_Arndsong==1:goto "Dark"
~1
?_Arndsong==2:goto "Silent"
~1
?_Arndsong==3:goto "Black"
~1
?_Arndsong==4:goto "Ash"
hint "Exit2!"
exit

#Ash
playmusic _Asong
5 fademusic 1
_backtoloop=0
#lilloop
?_timetoexit>_spawnwaves:5 fademusic 0;PauseTracks=0;Goto "start"
_backtoloop=_backtoloop+1
?_backtoloop==175:5 fademusic 0;goto"begin"
?(PauseAttackTracks==1):5 fademusic 0;PauseTracks=0;goto "start"
~1
goto "lilloop"


#Dark
playmusic _Asong
5 fademusic 1
_backtoloop=0
#lilloop2
?_timetoexit>_spawnwaves:5 fademusic 0;PauseTracks=0;Goto "start"
_backtoloop=_backtoloop+1
?_backtoloop==71:5 fademusic 0;goto"begin"
?(PauseAttackTracks==1):5 fademusic 0;PauseTracks=0;goto "start"
~1
goto "lilloop2"

#silent
playmusic _Asong
0 fademusic 0.5
playmusic _Asong
5 fademusic 1
_backtoloop=0
#lilloop3
?_timetoexit>_spawnwaves:5 fademusic 0;PauseTracks=0;Goto "start"
_backtoloop=_backtoloop+1
?_backtoloop==130:5 fademusic 0;goto"begin"
?(PauseAttackTracks==1):5 fademusic 0;PauseTracks=0;goto "start"
~1
goto "lilloop3"

#black
playmusic _Asong
0 fademusic 0.5
playmusic _Asong
5 fademusic 1
_backtoloop=0
#lilloop4
?_timetoexit>_spawnwaves:5 fademusic 0;PauseTracks=0;Goto "start"
_backtoloop=_backtoloop+1
?_backtoloop==68:5 fademusic 0;goto"begin"
?(PauseAttackTracks==1):5 fademusic 0;PauseTracks=0;goto "start"
~1
goto "lilloop4"

hope that isint too much to digest.
thanks,
    Murphy

RedHouse

  • Guest
Re:Play diffeent music for each player.
« Reply #3 on: 03 Jul 2005, 18:33:01 »
no offense, but i couldnt be bothered to read all that code, but maybe just try putting

0 setfog 1

player exec "randommusic.sqs"
player exec "AttackMusic.sqs"
PauseAttackTracks=1
PauseTracks=0