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

Still learning, couple questions…


Hazard153-1
 Share

Recommended Posts

Hello! I am sort of familar with scripting. Another game I used to play has an almost identical script system, although somewhat antiquated by today's standards…

Here is my overall goal... When a player kills an NPC, a sound plays to everyone on the map. When player is KILLED by said NPC, another sound plays on the map. I don't know what I'm doing wrong, but I can't get PlaySoundToMap working for the life of me... So I substituted PlaySound for now... Here's what I have so far.

```
Sub OnNPCDeath(Index, Map, NPCNum, NPCIndex)
    Call PlaySound(Index,"monsterdie.wav")
Call BattleMsg(Index, "You killed a " & getnpcname(NPCNum) & ".", BRIGHTRED, 0)
End Sub
```
This works perfectly, but again, PlaySoundToMap does not work for me.

```
Sub OnDeath(index)
Dim mapnum
Dim x
Dim y
Dim i
i = GetPlayerClass(index)

mapnum = GetVar("Classes\Class" & i & ".ini", "CLASS", "Map")
y = GetVar("Classes\Class" & i & ".ini", "CLASS", "y")
x = GetVar("Classes\Class" & i & ".ini", "CLASS", "x")

Call PlaySound(Index, "death.wav")
Call PlayerWarp(index, 1, 4, 2)
End Sub
```
For OnDeath, the warp works correctly, but I hear no sound… Death.wav is indeed in the SFX folder, so it's not that. If anyone could help me with my problems, I would greatly appreciate it. Thank you!
Link to comment
Share on other sites

```
Sub MapSound(Map, Sound)
For x = 1 to GetVar("data.ini", "Max", "MAX_PLAYERS")
If IsPlaying(x) and Map = GetPlayerMap(x) Then
Call PlaySound(x, Sound)
End If
Next
End Sub
```
Try throwing that at the bottom of your main.txt and using it instead of PlaySoundToMap. Temp fix, but should work.

As for death.wav, I have no idea why that isn't working. It looks good. Like you said, the file is in the right folder, so it should work…The only thing I might suggest is to make sure you've reloaded the scripts.

EDIT: A quick look through the source may have illuminated the PlaySoundToMap problem for me. It uses index as the first parameter, not the map (personally, I'd never have done it that way). Not sure if you were using **PlaySoundToMap(GetPlayermap(index), "monsterdie.wav")**, but if you were, just try **PlaySoundToMap(index, "monsterdie.wav")**
Link to comment
Share on other sites

@Balliztik:

> A quick look through the source may have illuminated the PlaySoundToMap problem for me. It uses index as the first parameter, not the map (personally, I'd never have done it that way). Not sure if you were using **PlaySoundToMap(GetPlayermap(index), "monsterdie.wav")**, but if you were, just try **PlaySoundToMap(index, "monsterdie.wav")**

PlaySoundToMap(GetPlayermap(index), "monsterdie.wav")

That works, thank you. Now just gotta get the other sound to work..
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...