PlayAudioStreamForPlayer

From SA-MP Wiki

Jump to: navigation, search


PlayAudioStreamForPlayer was added in SA-MP 0.3d This function was added in SA-MP 0.3d and will not work in earlier versions!


Description:

Play an 'audio stream' for a player. Normal audio files also work (e.g. MP3).


Parameters:
(playerid, url[], Float:posX = 0.0, Float:posY = 0.0, Float:posZ = 0.0, Float:distance = 50.0, usepos = 0)
playeridThe ID of the player to play the audio for.
url[]The url to play. Valid formats are mp3 and ogg/vorbis. A link to a .pls (playlist) file will play that playlist.
Float:PosXThe X position at which to play the audio. Default 0.0. Has no effect unless usepos is set to 1.
Float:PosYThe Y position at which to play the audio. Default 0.0. Has no effect unless usepos is set to 1.
Float:PosZThe Z position at which to play the audio. Default 0.0. Has no effect unless usepos is set to 1.
Float:distanceThe distance over which the audio will be heard. Has no effect unless usepos is set to 1.
useposUse the positions and distance specified. Default disabled (0).


Return Values:

  • 1: The function executed successfully.
  • 0: The function failed to execute. The player specified does not exist.


Example Usage:

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/radio", cmdtext, true) == 0) 
    {
        PlayAudioStreamForPlayer(playerid, "http://somafm.com/tags.pls");
        return 1;
    }
    if (strcmp("/radiopos", cmdtext, true) == 0)
    {
        new Float:X, Float:Y, Float:Z, Float:Distance = 5.0;
        GetPlayerPos(playerid, X, Y, Z);
	PlayAudioStreamForPlayer(playerid, "http://somafm.com/tags.pls", X, Y, Z, Distance, 1);
	return 1;
    }
    return 0;
}

Related Functions

The following functions may be useful, as they are related to this function in one way or another.

Personal tools
In other languages