Vice City: Multiplayer

VC:MP Discussion => Support => Bugs and Crashes => Topic started by: KAKAN on Mar 01, 2017, 08:18 AM

Title: [BUG]PlaySoundForWorld
Post by: KAKAN on Mar 01, 2017, 08:18 AM
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.
Title: Re: [BUG]PlaySoundForWorld
Post by: vito on Mar 01, 2017, 09:43 AM
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.
Title: Re: [BUG]PlaySoundForWorld
Post by: KAKAN on Mar 01, 2017, 10:04 AM
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
Title: Re: [BUG]PlaySoundForWorld
Post by: Eva on Mar 01, 2017, 10:23 AM
what if you made a silent soundfile for world 1? would it stop the world 400 sound?
i know im silly :D
Title: Re: [BUG]PlaySoundForWorld
Post by: . on Mar 01, 2017, 11:51 AM
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.
Title: Re: [BUG]PlaySoundForWorld
Post by: vito on Mar 01, 2017, 12:35 PM
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. 
Title: Re: [BUG]PlaySoundForWorld
Post by: KAKAN on Mar 01, 2017, 01:11 PM
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.
Title: Re: [BUG]PlaySoundForWorld
Post by: Sebastian on Mar 01, 2017, 01:59 PM
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.
Title: Re: [BUG]PlaySoundForWorld
Post by: KAKAN on Mar 01, 2017, 02:20 PM
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.
Title: Re: [BUG]PlaySoundForWorld
Post by: vito on Mar 01, 2017, 03:30 PM
Maybe worng name of function, but this is very tiny problem of sounds.