Custom Sounds

Started by luchgox, Jul 06, 2017, 09:22 AM

Previous topic - Next topic

luchgox

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.
Strength does not come from wining.Your struggles develop your strengths.

Zone_Killer

#1
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;
}
Bohemia Is God Of Punjabi Rap
Yo Yo Honey Singh tou chutiya hai

luchgox

#2
@Zone_Killer,Sorry bro your snippets does not makes sound
Strength does not come from wining.Your struggles develop your strengths.

Zone_Killer

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?
Bohemia Is God Of Punjabi Rap
Yo Yo Honey Singh tou chutiya hai

luchgox

Sorry I did not get you,but I want like sounds play anytime without any cmd through
Strength does not come from wining.Your struggles develop your strengths.

Zone_Killer

I have tested. The code is working 100%. You are making a mistake in copy paste
Bohemia Is God Of Punjabi Rap
Yo Yo Honey Singh tou chutiya hai

SAzEe21

#6
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.

Xmair

#7
How about just using PlaySound( player.UniqueWorld, 50000 + num, player.Pos );

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

SAzEe21

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.