Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO 3.0] Play music in battle?


Tic Tac 2
 Share

Recommended Posts

I think this works. I'm not sure it wasnt tested i wrote it now without vb6.

Well one way is to convert your .mp3 file to .wav file then paste .wav file in Sound folder, after that you should add new Server enum on server and client side

```
SPlayBattleSound

```
in modConstats(Server) add 

```
Public Const BattleMusic as String = "Battle.wav" 'or whatever filename

```
Then in modServerTCP(Server) add:

```
Sub SendPlayBattleMusic(ByVal Index as Long)
dim buffer as clsbuffer
set buffer = new clsbuffer
buffer.writelong SPlayBattleSound
buffer.writestring BattleMusic
senddatato index,buffer.toarray
set buffer = nothing
end sub

```
Now on client side in modHandleData add 

```
Sub HandlePlayBattleSound (byval index as long,byref Data() as byte,byval StartAddr as long,byval ExtraVar as long)
dim sound as string
dim buffer as clsbuffer
set buffer = new clsbuffer
buffer.writebytes Data
sound = buffer.readstring
playsound sound
set buffer = nothing
end sub

```
Also (client side) in sub initMessages copy last line before end sub and paste it in the same sub then replace SSomething with SPlayBattleSound and HandleSomething with HandlePlayBattleSound

This will play music (sound).To make it in battle  on server side in PlayerAttackPlayer you need to add  

```
Call SendPlayBattleMusic (Attacker)
Call SendPlayBattleMusic (Victim)

```
I dont know line where you should paste this because I dont have VB6 here right now I wrote all this from my head , but I think this should work.

If you want to play music when you attack npc add this (I dont know wich line) in PlayerAttackNPC sub

```
Call SendPlayBattleMusic (Index) 'I'm not sure if its attacker but i think its index

```
Good luck
Link to comment
Share on other sites

> I think this works. I'm not sure it wasnt tested i wrote it now without vb6.
>
>  
>
>  
>
> Well one way is to convert your .mp3 file to .wav file then paste .wav file in Sound folder, after that you should add new Server enum on server and client side
>
> ```
> SPlayBattleSound
>
> ```
> in modConstats(Server) add 
>
> ```
> Public Const BattleMusic as String = "Battle.wav" 'or whatever filename
>
> ```
> Then in modServerTCP(Server) add:
>
> ```
> Sub SendPlayBattleMusic(ByVal Index as Long)
> dim buffer as clsbuffer
> set buffer = new clsbuffer
> buffer.writelong SPlayBattleSound
> buffer.writestring BattleMusic
> senddatato index,buffer.toarray
> set buffer = nothing
> end sub
>
> ```
> Now on client side in modHandleData add 
>
> ```
> Sub HandlePlayBattleSound (byval index as long,byref Data() as byte,byval StartAddr as long,byval ExtraVar as long)
> dim sound as string
> dim buffer as clsbuffer
> set buffer = new clsbuffer
> buffer.writebytes Data
> sound = buffer.readstring
> playsound sound
> set buffer = nothing
> end sub
>
> ```
> Also (client side) in sub initMessages copy last line before end sub and paste it in the same sub then replace SSomething with SPlayBattleSound and HandleSomething with HandlePlayBattleSound
>
>  
>
> This will play music (sound).To make it in battle  on server side in PlayerAttackPlayer you need to add  
>
> ```
> Call SendPlayBattleMusic (Attacker)
> Call SendPlayBattleMusic (Victim)
>
> ```
> I dont know line where you should paste this because I dont have VB6 here right now I wrote all this from my head , but I think this should work.
>
> If you want to play music when you attack npc add this (I dont know wich line) in PlayerAttackNPC sub
>
> ```
> Call SendPlayBattleMusic (Index) 'I'm not sure if its attacker but i think its index
>
> ```
> Good luck

Nice done, but i'm not sure if this is a good way to do it, because map music would play over this. Even if i put some kind of command to stop all music playing before playing the sound, you could walk to another map and music would start playing over it again.

Thanks again for taking your time to write this.

Could you do something like this but with playMusic()?

Maybe tell server to playMusic("battle!!.mid") whenever you deal damage to something.

I want music to start playing when you deal damage to other players or monsters, not when they damage you.
Link to comment
Share on other sites

  • 2 weeks later...
If you want to use various musics then you need add on SendPlayBattleMusic:
```
Sub SendPlayBattleMusic(ByVal Index as Long, Byval BattleMusic as string)
```**Note: When you use this sub, put SendPlayBattleMusic(index,"NameOfMusic.mp3")**

And on Handle change the PlaySound to PlayMusic:
```
playMusic Sound
```

To show only in the first hit to NPC/Player, you need make a TempPlayer var, like .activeMusic. If .activeMusic = false then this change to TRUE. When you kill the NPC this var change to false.
Link to comment
Share on other sites

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
 Share

×
×
  • Create New...