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.
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;
}
@Zone_Killer,Sorry bro your snippets does not makes sound
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?
Sorry I did not get you,but I want like sounds play anytime without any cmd through
I have tested. The code is working 100%. You are making a mistake in copy paste
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.
How about just using PlaySound( player.UniqueWorld, 50000 + num, player.Pos );
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.