I have probleme with music
#1

Код:
public OnPlayerUpdate(playerid)
{
	if(GetPlayerInterior(playerid) == 0) {
	    if(IsPlayerInRangeOfPoint(playerid,0.25,-1505.5428,749.1716,7.4059))
        PlayAudioStreamForPlayer(playerid, "http://blackbeats.fm/listen.m3u",-1505.6370,749.1212,7.3586,30,1);
	}
	else {
        StopAudioStreamForPlayer(playerid);
}
	return 1;
}
anny One Correct me this Code B-Cuz When I approached in the place
look
many urls
I want One Url
any One Correct me the Code pls
Reply
#2

OnPlayerUpdate gets called like 40 times in a second I believe, place it under a 1 second timer if you can or perhaps do a little check, like


Код:
 if(!hasInteriorSong[playerid]) PlayAudioblablabla
hasInteriorSong[playerid] = 1;
yet I still suggest you do this under a 1 second looping timer
Reply
#3

i can use
OnPlayerConnect ?
Reply
#4

Try this
Код:
public OnPlayerUpdate(playerid)
{
	if(GetPlayerInterior(playerid) == 0)
	{
	    if(IsPlayerInRangeOfPoint(playerid,0.25,-1505.5428,749.1716,7.4059))
	    {
                PlayAudioStreamForPlayer(playerid, "http://blackbeats.fm/listen.m3u");
            }
	    else StopAudioStreamForPlayer(playerid);
	}
	return 1;
}
Reply
#5

Код:
// ontop of the script, along with all your variables
new _1sectimer[MAX_PLAYERS], hasInteriorSong[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
      hasInteriorSong[playerid] = 0;
      KillTimer(_1sectimer[playerid]);
      _1secTimer[playerid] = SetTimerEx("OnPlayerSecondUpdate", 1000, true, "i", playerid);
}

forward OnPlayerSecondUpdate(playerid); public OnPlayerSecondUpdate(playerid)
{
      if(!hasInteriorSong[playerid] && IsPlayerInRangeOfPoint(playerid,0.25,-1505.5428,749.1716,7.4059) && GetPlayerInterior(playerid) == 0)
      {
            PlayAudioStreamForPlayer(playerid, "http://blackbeats.fm/listen.m3u",-1505.6370,749.1212,7.3586,30,1);
            hasInteriorSong[playerid] = 1;
      }
}
Rest is up to you.

Also, why are you using "else StopAudioStreamForPlayer"? This means that the player can only listen to the stream if he stands still at the spot where the stream plays, once he moves outside of it the stream stops.
Reply
#6

Quote:
Originally Posted by JaydenJason
Посмотреть сообщение
Код:
// ontop of the script, along with all your variables
new _1sectimer[MAX_PLAYERS], hasInteriorSong[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
      hasInteriorSong[playerid] = 0;
      KillTimer(_1sectimer[playerid]);
      _1secTimer[playerid] = SetTimerEx("OnPlayerSecondUpdate", 1000, true, "i", playerid);
}

forward OnPlayerSecondUpdate(playerid); public OnPlayerSecondUpdate(playerid)
{
      if(!hasInteriorSong[playerid] && IsPlayerInRangeOfPoint(playerid,0.25,-1505.5428,749.1716,7.4059) && GetPlayerInterior(playerid) == 0)
      {
            PlayAudioStreamForPlayer(playerid, "http://blackbeats.fm/listen.m3u",-1505.6370,749.1212,7.3586,30,1);
            hasInteriorSong[playerid] = 1;
      }
}
Rest is up to you.

Also, why are you using "else StopAudioStreamForPlayer"? This means that the player can only listen to the stream if he stands still at the spot where the stream plays, once he moves outside of it the stream stops.
Lol, why all of this ?
He wants to play music for the player if he is near the position he sets
And when the player leaves, the music stops
Such a Disco for example, the music is inside the Disco and stops outside of it

OnPlayerUpdate would work without all the news you made
~ 'Just an opinion' ~
Reply
#7

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(!IsPlayerConnected(playerid)) return 0;
    if(IsPlayerNPC(playerid)) return 1;
   
    // Handle playing SomaFM at the alhambra
    if(GetPlayerInterior(playerid) == 17) {
        if(IsPlayerInRangeOfPoint(playerid,70.0,489.5824,-14.7563,1000.6797)) { // alhambra middle
            if(!GetPVarInt(playerid,"alhambra")) {
                SetPVarInt(playerid,"alhambra",1);
                PlayAudioStreamForPlayer(playerid, "http://somafm.com/tags.pls",480.9575,-3.5402,1002.0781,40.0,true);
            }
        }
    }
    else {
        if(GetPVarInt(playerid,"alhambra")) {
            DeletePVar(playerid,"alhambra");
            StopAudioStreamForPlayer(playerid);
        }
    }
   
    return 1;
}
Taken directly from "iradio.pwn" that comes with the SA-MP server distribution.
Reply


Forum Jump:


Users browsing this thread: