Vice City: Multiplayer

Server Development => Scripting and Server Management => Script and Content Requests => Topic started by: luchgox on Jul 06, 2017, 09:22 AM

Title: Custom Sounds
Post by: luchgox on Jul 06, 2017, 09:22 AM
Hey,I though is there's anyway to play custom sounds at random time (any time) by server,I know how to load custom sounds.

I'm to get some examples,like server plays a sound at random time.
Title: Re: Custom Sounds
Post by: Zone_Killer on Jul 06, 2017, 10:00 AM
function onPlayerJoin( player )
{
local ran = Random(1000,5000); //You can also change it. 1000 of 1 second
NewTimer("RandomTimerSound", ran, 1, player.Name);
}

function RandomTimerSound( player )
{
local player = FindPlayer( player )
if(player){
PlaySound( player.UniqueWorld , 30 , player.Pos );
}
}

// Random Function
function Random(from, to){
return (rand()*(to+1-from)) / (RAND_MAX+1)+from;
}
Title: Re: Custom Sounds
Post by: luchgox on Jul 07, 2017, 02:12 AM
@Zone_Killer,Sorry bro your snippets does not makes sound
Title: Re: Custom Sounds
Post by: Zone_Killer on Jul 07, 2017, 04:35 AM
Quote from: luchgox on Jul 07, 2017, 02:12 AM@Zone_Killer,Sorry bro your snippets does not makes sound

Do you want sounds become Randomly?
Title: Re: Custom Sounds
Post by: luchgox on Jul 07, 2017, 10:07 AM
Sorry I did not get you,but I want like sounds play anytime without any cmd through
Title: Re: Custom Sounds
Post by: Zone_Killer on Jul 08, 2017, 04:08 AM
I have tested. The code is working 100%. You are making a mistake in copy paste
Title: Re: Custom Sounds
Post by: SAzEe21 on Jul 15, 2017, 03:33 PM
function Random(min=0, max=RAND_MAX)
 {
 local r = rand();
 srand(GetTickCount() * r);
 return (r % ((max + 1) - min)) + min;
 }

function Randomsounds()
{
if ( GetPlayers() >= 1 )     
 {       
 local num = Random( 1, 3 ); // Note: There are only 3 sounds added currently you can add more by copy paste but note that change the numbers you added below Random( 1, 3here )       
 if ( num == 1 )
{
PlaySound( player.UniqueWorld , 50001 , player.Pos ); // Play your sound which you want to play for the first time
}
else if ( num == 2 )
{
PlaySound( player.UniqueWorld , 50002 , player.Pos ); // Play your sound which you want to play for the second time
}
else if ( num == 3 )
{
PlaySound( player.UniqueWorld , 50003 , player.Pos ); // Play your sound which you want to play for the third time
}
}

Add this NewTimer( "Randomsounds", 10000, 0 ); in onScriptLoad this will play the random sound in every 10 seconds you can change whatever time you want to add to play on.
Title: Re: Custom Sounds
Post by: Xmair on Jul 15, 2017, 05:29 PM
How about just using PlaySound( player.UniqueWorld, 50000 + num, player.Pos );
Title: Re: Custom Sounds
Post by: SAzEe21 on Jul 16, 2017, 10:09 AM
Quote from: Xmair on Jul 15, 2017, 05:29 PMHow about just using PlaySound( player.UniqueWorld, 50000 + 3, player.Pos );

Not aware of this :) Btw this one is more better than mine.