Where should i put my code
#1

Код:
	new Float:X, Float:Y, Float:Z, Float:Distance = 5.0;
	GetPlayerPos(playerid, X, Y, Z);
	PlayAudioStreamForPlayer(playerid, "http://.........", 816.2269,-1386.7910,13.6079, Distance, 1);
If player is in the range it just plays the sound... It works under Onplayerconnect... Is there other way to make it work
Reply
#2

mhm, you could set a timer to 1sec to check the players position and the use it.
Reply
#3

Create a stock function; then you can use the function at any place in your script!
Reply
#4

I did it like this

Код:
stock DiscoMusic(playerid)
{
	new Float:X, Float:Y, Float:Z, Float:Distance = 5.0;
	GetPlayerPos(playerid, X, Y, Z);
	PlayAudioStreamForPlayer(playerid, "http://*******", 816.2269,-1386.7910,13.6079, Distance, 1);
}
but it dont works.. Anyone can help ?
Reply
#5

What's the point in getting the X,Y,Z co-ordinates of the player? You're not using them as far as I can tell.

Also how are you trying to call that function?
Reply
#6

I did this now

Код:
public PlayAudioStreamForPoint(playerid, url[], Float:range, Float:xx, Float:yy, Float:zz)
{
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(IsPlayerInRangeOfPoint(i, 5.0, 816.2269,-1386.7910,13.6079))
			{
				PlayAudioStreamForPlayer(i, "http://*****");
			}
		}
	}
	return 1;
}
dont works ^^

I want if a player gets near vinewood(example) he can listen to the song
Reply
#7

anyone can help ?
Reply
#8

IsPlayerInRangeOfPoint has a set x,y,z
you should use the ones in your function xx, yy, zz

pawn Код:
forward PlayAudioStreamForPoint(url[], Float:range, Float:xx, Float:yy, Float:zz);
public PlayAudioStreamForPoint(url[], Float:range, Float:xx, Float:yy, Float:zz)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInRangeOfPoint(i, range, xx,yy,zz))
            {
                PlayAudioStreamForPlayer(i, url);
            }
        }
    }
    return 1;
}

//use it in a timer
SetTimerEx("PlayAudioStreamForPoint",1000,true,"sffff",url,xx,yy,zz);
I removed the playerid argument as your looping threw all the players,
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)