Help please ;) -
BarFix - 07.01.2014
Hey guys, i have a question.
How to do something like, if i stand near this POS: 1529.6,-1691.2,13.3
then its will play the music?
PlayAudioStreamForPlayer(playerid,"MUSIC HERE");
Re: Help please ;) -
ScRipTeRi - 07.01.2014
use PlayerToPoint
Re: Help please ;) -
AIped - 07.01.2014
good question, there must be several ways to do that but one thing you do need is
IsPlayerInRangeOfPoint then let the audio stream like this;
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 5.0 ,1529.6,-1691.2,13.3 ))//5.0 or any range you prefer
{
PlayAudioStreamForPlayer(playerid,"MUSIC HERE");
}
a bigger problem is how are you going to call IsPlayerInRangeOfPoint..a timer is realy buggy i guess
Re: Help please ;) -
BarFix - 07.01.2014
Quote:
Originally Posted by ScRipTeRi
use PlayerToPoint
|
Quote:
Originally Posted by AIped
good question, there must be several ways to do that but one thing you do need is
IsPlayerInRangeOfPoint then let the audio stream
a bigger problem is how are you going to call IsPlayerInRangeOfPoint..a timer is realy buggy i guess
|
Thats works like this?
if(IsPlayerInRangeOfPoint(playerid, 7.0, 2695.6880, -1704.6300, 11.843
)
{
PlayAudioStreamForPlayer(playerid,"https://dl.dropboxusercontent.com/s/z834k2bgngbcmm6/kbgdHubwVdkG.128.mp3");
}
also, where should i put this? in the script? i want it to work auto when the player at that POS
Re: Help please ;) -
ScRipTeRi - 07.01.2014
try this
pawn Код:
#include <a_samp>
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
forward PlayMuzic(playerid);
public OnGameModeInit()
{
SetTimer("PlayMuzic", 999, true);
return 1;
}
public PlayMuzic(playerid)
{
if(PlayerToPoint(1, playerid, x, y, z)
{
PlayAudioStreamForPlayer(playerid,"MUSIC HERE");
}
return 1;
}
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
if(IsPlayerConnected(playerid))
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
}
return 0;
}
its not tested.
EDIT: To late
Re: Help please ;) -
AIped - 07.01.2014
Quote:
Originally Posted by ScRipTeRi
try this
pawn Код:
#include <a_samp>
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z); forward PlayMuzic(playerid);
public OnGameModeInit() { SetTimer("PlayMuzic", 999, true); return 1; }
public PlayMuzic(playerid) { if(PlayerToPoint(1, playerid, x, y, z) { PlayAudioStreamForPlayer(playerid,"MUSIC HERE"); } return 1; } public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z) { if(IsPlayerConnected(playerid)) { new Float:oldposx, Float:oldposy, Float:oldposz; new Float:tempposx, Float:tempposy, Float:tempposz; GetPlayerPos(playerid, oldposx, oldposy, oldposz); tempposx = (oldposx -x); tempposy = (oldposy -y); tempposz = (oldposz -z); if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) { return 1; } } return 0; }
its not tested.
EDIT: To late
|
Why using playertopoint ? isnt that outdated ? IsPlayerInRangeOfPoint would be better as it is a more regular function
Re: Help please ;) -
BarFix - 07.01.2014
Quote:
Originally Posted by ScRipTeRi
try this
pawn Код:
#include <a_samp>
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z); forward PlayMuzic(playerid);
public OnGameModeInit() { SetTimer("PlayMuzic", 999, true); return 1; }
public PlayMuzic(playerid) { if(PlayerToPoint(1, playerid, x, y, z) { PlayAudioStreamForPlayer(playerid,"MUSIC HERE"); } return 1; } public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z) { if(IsPlayerConnected(playerid)) { new Float:oldposx, Float:oldposy, Float:oldposz; new Float:tempposx, Float:tempposy, Float:tempposz; GetPlayerPos(playerid, oldposx, oldposy, oldposz); tempposx = (oldposx -x); tempposy = (oldposy -y); tempposz = (oldposz -z); if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) { return 1; } } return 0; }
its not tested.
EDIT: To late
|
Hmm, for what i need that "PlayerToPoint"? how that helps me? i just want the music playing when i'm at that point..
Re: Help please ;) -
offon - 07.01.2014
Код:
if(IsPlayerInRangeOfPoint(playerid, range, x, y, z) return PlayAudioStreamForPlayer(playerid, "url");
Try to put this into a timer or OnPlayerUpdate. Don't forget to change the range, the coordinates and the URL.
Re: Help please ;) -
Konstantinos - 07.01.2014
Quote:
Originally Posted by AIped
Why using playertopoint ? isnt that outdated ? IsPlayerInRangeOfPoint would be better as it is a more regular function
|
AIped is correct, there isn't any reason to use PlayerToPoint when IsPlayerInRangeOfPoint already exists.
However, there's a better option than a timer or OPU and IsPlayerInRangeOfPoint and that is dynamic areas.
pawn Код:
#include <streamer>
// global:
new
Area_Music;
// OnGameModeInit/OnFilterScriptInit (depends on the mode):
Area_Music = CreateDynamicSphere(x, y, z, size); // Edit the arguments
public OnPlayerEnterDynamicArea(playerid, areaid)
{
if (areaid == Area_Music) PlayAudioStreamForPlayer(playerid,"MUSIC HERE");
return 1;
}
public OnPlayerLeaveDynamicArea(playerid, areaid)
{
if (areaid == Area_Music) StopAudioStreamForPlayer(playerid);
return 1;
}
If you don't want to stop the music when the player is not anymore in the area, remove the last callback.
Re: Help please ;) -
AIped - 07.01.2014
Quote:
Originally Posted by Konstantinos
AIped is correct, there isn't any reason to use PlayerToPoint when IsPlayerInRangeOfPoint already exists.
However, there's a better option than a timer or OPU and IsPlayerInRangeOfPoint and that is dynamic areas.
pawn Код:
#include <streamer>
// global: new Area_Music;
// OnGameModeInit/OnFilterScriptInit (depends on the mode): Area_Music = CreateDynamicSphere(x, y, z, size); // Edit the arguments
public OnPlayerEnterDynamicArea(playerid, areaid) { if (areaid == Area_Music) PlayAudioStreamForPlayer(playerid,"MUSIC HERE"); return 1; }
public OnPlayerLeaveDynamicArea(playerid, areaid) { if (areaid == Area_Music) StopAudioStreamForPlayer(playerid); return 1; }
If you don't want to stop the music when the player is not anymore in the area, remove the last callback.
|
Thanks Konstantinos i didnt know that such things as ' CreateDynamicSphere ' was in a streamer...
I would use this too instead of a timer...and OnPlayerUpdate is a real no go for just this