Sound is supposed to be played at a certain position -
ZakuAbumi - 14.07.2011
Title sums it up.
I want a player sound to be played at a certain position(and there should be also a range to it) and don't know how to do it or where to put the whole thing. Seriously, this is driving me crazy.
SAMP wiki says I should only use the cordinates, but I simply don't get the meaning behind it, since "PlayerPlaySound(1130, 0.0, 0.0, 10.0);"(playerid was removed) does not seem to work.
Thanks in advance.
Re: Sound is supposed to be played at a certain position -
Lorenc_ - 14.07.2011
IsPlayerInRangeOfPoint
Re: Sound is supposed to be played at a certain position -
Adil - 14.07.2011
If you mean you want to
PlayerPlaySound in a range of coordinates, then:
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 10, 0.0, 0.0, 0.0))//edit
{
PlayerPlaySound(i)//....
}
}
Re: Sound is supposed to be played at a certain position -
ZakuAbumi - 14.07.2011
Now, where am I supposed to put this to?
So it's like that, right?
Quote:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 10, 1319.1042,1253.9703,14.2731))//edit
{
PlayerPlaySound(i, 1185, 1319.1042,1253.9703,14.2731);//....
}
}
return 1;
}
|
Re: Sound is supposed to be played at a certain position -
Adil - 14.07.2011
Put it where you want to make it function.
OnPlayerCommand,
OnPlayerText or wherever.
Re: Sound is supposed to be played at a certain position -
Toreno - 14.07.2011
https://sampwiki.blast.hk/wiki/SoundID
Try this, and this link is for Sounds ID.
pawn Код:
new SoundTimer[MAX_PLAYERS];
pawn Код:
public OnPlayerConnect(playerid) {
SoundTimer[playerid] = SetTimer("SoundTimer", 1000, true);
return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid) {
KillTimer(SoundTimer[playerid]);
return 1;
}
pawn Код:
forward SoundTimerFunc();
public SoundTimerFunc() {
for(new i; i < MAX_PLAYERS; i++) {
if(IsPlayerInRangeOfPoint(i, DISTANCE, X, Y, Z)) { // Change your X, Y, Z and distance.
PlayerPlaySound(i, SoundID, 0.0, 0.0, 0.0); // Change your SoundID to a specific ID, posted a link.
}
}
return 1;
}
Re: Sound is supposed to be played at a certain position -
Lorenc_ - 14.07.2011
You may put it
OnPlayerUpdate but you need to make a variable.
pawn Код:
new bool:calledSound[MAX_PLAYERS char];
//OnPlayerUpdate
if(IsPlayerInRangeOfPoint(...))
{
if(calledSound{playerid} == false) {
//play sound
calledSound{playerid} = true;
}
}
else
{
if(calledSound{playerid} == true) calledSound{playerid} =false;
}
Re: Sound is supposed to be played at a certain position -
ZakuAbumi - 14.07.2011
Thanks a lot, you two.
Lorenc_'s version works, EliranPesahov's... umm... not so much.
But there's still a problem left: Once the player is out of range, the sound is supposed to stop playing.
Re: Sound is supposed to be played at a certain position -
ZakuAbumi - 12.08.2011
Bump. I still need help.
Re: Sound is supposed to be played at a certain position -
MadeMan - 12.08.2011
Playing soundid 1186 should stop it
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 10, 1319.1042,1253.9703,14.2731))
{
if(calledSound{playerid} == false)
{
PlayerPlaySound(playerid, 1185, 0, 0, 0);
calledSound{playerid} = true;
}
}
else
{
if(calledSound{playerid} == true)
{
PlayerPlaySound(playerid, 1186, 0, 0, 0);
calledSound{playerid} = false;
}
}