Not working, timer
#1

top of the script
Quote:

forward musicstall(playerid);

OnGamemodeInit
Quote:

SetTimer("musicstall", 1000, false);

Quote:

public musicstall(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0,1478.8761,-1666.3502,14.5532))
{
PlayAudioStreamForPlayer(playerid, "http://lackofstyle.com/mp3s/bing_lookalotlikexmas.mp3");
}
}

It doesn't play the music when near the point?
I have tried doing it on a command like.

Код:
if(strcmp("/startmusicnearpoint", cmdtext, true, 10) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	    	if(IsPlayerInRangeOfPoint(playerid, 5.0,1478.8761,-1666.3502,14.5532))
	        {
	        PlayAudioStreamForPlayer(playerid, "http://lackofstyle.com/mp3s/bing_lookalotlikexmas.mp3");
	        }
	    }
        return 1;
}
and it works when i type it near the point.
But i want it to play automatically..

Can you help? +rep
Reply
#2

SetTimer("musicstall", 1000, false);

make it

SetTimer("musicstall", 1000, true);

EDIT : Sorry, its wrong. Don't mind it.
Reply
#3

Use SetTimerEx for functions with parameters
pawn Код:
SetTimerEx("musicstall", 1000, false,"d", playerid);
Reply
#4

i put this under OnGameModeInit
Quote:

SetTimerEx("musicstall", 1000, false,"d", playerid);

said that it doesn't recognize the "playerid".
so i put it OnPlayerConnect and it still doesn't work?

what now? thanks btw
Reply
#5

Am i doing it right?
Reply
#6

No, try this.
pawn Код:
SetTimerEx("musicstall", 1000, true,"d", playerid);
Reply
#7

Or you can use what you did with a for loop.
pawn Код:
public OnGameModeInit( )
{
    SetTimer( "musicstall", 1000, false );
    return 1;
}

forward musicstall( );
public musicstall( )
{
    for( new p = 0; p < MAX_PLAYERS; p++ )
    {
        if( IsPlayerConnected( p ) && !IsPlayerNPC( p ) && IsPlayerInRangeOfPoint( p, 5.0,1478.8761, -1666.3502, 14.5532 ) )
        {
            PlayAudioStreamForPlayer( p, "http://lackofstyle.com/mp3s/bing_lookalotlikexmas.mp3" );
        }
    }
    return 1;
}
Reply
#8

Okay Thanks, i found another guide which helped me

But now when i go near the point it spams the audio stream? How can i stop this?

Quote:

SetTimer("musicstall", 1500, true);

I have tried changing the "True" to "false" but then it just doesn't work atall. :/

thats my public if you need it?
Quote:

public musicstall()
{
for(new i = 1; i < MAX_PLAYERS; i++) {
if(IsPlayerInRangeOfPoint(i, 5.0,1478.8761,-1666.3502,14.5532))
{
PlayAudioStreamForPlayer(i, "http://adstorage.jamba.net/storage/view/325/0/ha/Have_Yourself_A_Merry_Litt1.mp3");
}
}
return 1;
}

Reply
#9

pawn Код:
new
    bool:Play_Audio[ MAX_PLAYERS ]
;

public OnGameModeInit( )
{
    SetTimer( "musicstall", 1000, true );
    return 1;
}

public OnPlayerConnect( playerid )
{
    Play_Audio[ playerid ] = false;
    return 1;
}

forward musicstall( );
public musicstall( )
{
    for( new p = 0; p < MAX_PLAYERS; p++ )
    {
        if( IsPlayerConnected( p ) && !IsPlayerNPC( p ) && IsPlayerInRangeOfPoint( p, 5.0,1478.8761, -1666.3502, 14.5532 ) )
        {
            if( Play_Audio[ p ] == true ) continue;
            PlayAudioStreamForPlayer( p, "http://lackofstyle.com/mp3s/bing_lookalotlikexmas.mp3" );
            Play_Audio[ p ] = true;
        }
        if( !IsPlayerInRangeOfPoint( p, 5.0,1478.8761, -1666.3502, 14.5532 ) ) Play_Audio[ p ] = false;
    }
    return 1;
}
Reply
#10

Ahh yey works. Thanks so much! +rep
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)