[BUG]PlaySoundForWorld

Started by KAKAN, Mar 01, 2017, 08:18 AM

Previous topic - Next topic

KAKAN

Subject: [Bug]PlaySoundForWorld not working as expected


Description
For ex: I play the sound at world 400, then teleport the player to world 400 and then teleport him/her to world 1. The problem is that the sound still continues to play even if the player is in world 1.

Reproducible
Always

What you were doing when the bug happened
trying to copy SAMP's spawn sound( BABA's request :D )

What you think caused the bug
Scripting skills of the devs


Take this code for ex:
player.World = 400;
PlaySoundForWorld( 400, soundID );
player.World = 1;
Here, the sound still plays even if the player is in world 1.
NOTE: My sound is 24s long, that's why I could find this bug.

I actually change the world after 2 secs, but that's not needed. For debugging my code, I added print statements to print the world. It showed 400 and 1 respectively, so, my code is fine.
oh no

vito

Once sound started to play nothing in script can stop it, so I think its not a bug. Just its nature of sounds system of vcmp.
Quote from: KAKAN on Mar 01, 2017, 08:18 AM24s long
of .wav? It's masochism.

KAKAN

Quote from: vito on Mar 01, 2017, 09:43 AMOnce sound started to play nothing in script can stop it, so I think its not a bug. Just its nature of sounds system of vcmp.
Quote from: KAKAN on Mar 01, 2017, 08:18 AM24s long
of .wav? It's masochism.
I gave a code too. See that if you can't understand my english. PlaySoundForWorld should play for only 1 world, not 2 worlds.
About 24s, using audacity, I compressed it to 700KB from 4.2MB :D
oh no

Eva

what if you made a silent soundfile for world 1? would it stop the world 400 sound?
i know im silly :D

.

#4
This is quite understandable. Playing sounds in a certain world is the same as iterating every player and then playing the sound for each player that has a certain world. Therefore, this acts as a filtering method of some sort.

The player world is not some other game world different from the loaded world. In reality, this concept is called a channel. But they seem to have rename it to a misleading name.

This feature comes from the networking library (RakNet) (and most other networking libraries for that matter). And all it does is to simply send packets only to players on a certain channel (could be named differently here though). Anyone else not on that channel does not see those packages and (in this case for example) do not know they have to play that sound.

Think of it in therms of IRC channels if you've ever used one. If you're not on a particular channel then you don't know what was said there and how you should've reacted to it.

So you should stop thinking that the player world is a game world different from other ones. Kinda like a multi-dimensional game world. Because in reality, this is just a misleading name to a feature in the networking library.

Whoever thought of renaming it to this should be slapped with a rotten fish.
.

vito

Quote from: KAKAN on Mar 01, 2017, 10:04 AMI gave a code too. See that if you can't understand my english. PlaySoundForWorld should play for only 1 world, not 2 worlds.
I agree with happymint, this function has not good name to explain what it doing. Actually it will select players from world to play sound for them, and once it started to play it can not be stopped. It just how sounds works in vc-mp. 

KAKAN

Then the devs should provide a way to stop it.
And @Eva, if you play another sound, they will just mix and play like 1 sound. I've tried that too.
And thanks happymint for explaining that.
oh no

Sebastian

It says nowhere that it should stop if the player is no more in that world.
But yes, it had to stop when world's changing.

KAKAN

Quote from: sseebbyy on Mar 01, 2017, 01:59 PMIt says nowhere that it should stop if the player is no more in that world.
That's common sense, I'm playing the song for that world not for that player.
But as happymint explained, its partly devs fault and partly not.
oh no

vito

Maybe worng name of function, but this is very tiny problem of sounds.