Adding audio stream
#1

Ok so, I want to add a fire station tone. I want only the people in and around the fire station to hear the tone when a medic call (when some one calls /911 and ask for medics) or when a fire call comes in.
Reply
#2

Use IsPlayerInRangeOfPoint
You just need fire station coordinates (/save or /rs ingame)

e.g
pawn Код:
CMD:call911( playerid, params[ ] ) // Example command
{
    // Your commands go here, e.g :
    SendClientMessage( playerid, -1, "You have called 911. Paramedics on building will hear your call. Please wait for respond." );
    // Other things ...
   
    // Now, add this (loop to check players inside 911 building)
    for ( new i, j = GetMaxPlayers( ); i < j; ++ i )
    {
        if ( !IsPlayerConnected( i ) )
            continue;
           
        if ( !IsPlayerInRangeOfPoint( i, 10.0, POSITION_X, POSITION_Y, POSITION_Z ) ) // Change this positions
            continue;
           
        // Passed all checks, play audio stream
        PlayAudioStreamForPlayer( i, "http://example_audio/911.wav" ); // Change to your audio stream
    }
    return true;
}
Reply
#3

Quote:
Originally Posted by greentarch
Посмотреть сообщение
Use IsPlayerInRangeOfPoint
You just need fire station coordinates (/save or /rs ingame)

e.g
pawn Код:
CMD:call911( playerid, params[ ] ) // Example command
{
    // Your commands go here, e.g :
    SendClientMessage( playerid, -1, "You have called 911. Paramedics on building will hear your call. Please wait for respond." );
    // Other things ...
   
    // Now, add this (loop to check players inside 911 building)
    for ( new i, j = GetMaxPlayers( ); i < j; ++ i )
    {
        if ( !IsPlayerConnected( i ) )
            continue;
           
        if ( !IsPlayerInRangeOfPoint( i, 10.0, POSITION_X, POSITION_Y, POSITION_Z ) ) // Change this positions
            continue;
           
        // Passed all checks, play audio stream
        PlayAudioStreamForPlayer( i, "http://example_audio/911.wav" ); // Change to your audio stream
    }
    return true;
}
So where do I put this code.. under my /call 911?
Reply
#4

Yes, under /call 911, put this
You'll have to edit the parts where there are comments saying you must edit it, includes:
POSITION_X, POSITION_Y, POSITION_Z and the stream website.

pawn Код:
for ( new i, j = GetMaxPlayers( ); i < j; ++ i )
    {
        if ( !IsPlayerConnected( i ) )
            continue;
           
        if ( !IsPlayerInRangeOfPoint( i, 25.0, POSITION_X, POSITION_Y, POSITION_Z ) ) // Change this positions
            continue;
           
        // Passed all checks, play audio stream
        PlayAudioStreamForPlayer( i, "http://example_audio/911.wav" ); // Change to your audio stream
    }
(edited the code above for a better range, if you have issues with the my before-post, use this one. It has a bigger range detection)
Reply
#5

I dont have a call 911, This is my call.

Код:
CMD:call(playerid, params[])
{
	new string[128], phonenumb;

	if(sscanf(params, "d", phonenumb)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /call [phonenumber]");

	if (PlayerInfo[playerid][pJailTime] > 0)
	{
		SendClientMessageEx(playerid,COLOR_GREY,"You can't use your phone while in jail.");
		return 1;
	}
	if(PlayerTied[playerid] != 0 || PlayerCuffed[playerid] != 0)
	{
		SendClientMessageEx(playerid,COLOR_GREY,"You can't use your phone whilist restrained.");
		return 1;
	}
	if(PlayerInfo[playerid][pPnumber] == 0)
	{
		SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have a cell phone.");
		return 1;
	}
	if(PhoneOnline[playerid] > 0)
	{
		SendClientMessageEx(playerid, COLOR_GREY, "Your phone is off.");
		return 1;
	}
	format(string, sizeof(string), "* %s takes out a cellphone.", GetPlayerNameEx(playerid));
	ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
	if(phonenumb == 911)
	{
		if(PlayerInfo[playerid][pJailed] == 4 || PlayerInfo[playerid][pJailed] == 1000)
		{
			SendClientMessageEx(playerid, COLOR_WHITE, "Cannot use this whilist in admin prison!");
			return 1;
		}
		SendClientMessageEx(playerid, COLOR_WHITE, "HINT: You now use T to talk on your cellphone, type /hangup to hang up.");
		SendClientMessageEx(playerid, COLOR_ALLDEPT, "EMERGENCY: Which service do you require, Sheriff or paramedic?");
		Mobile[playerid] = 911;
		return 1;
	}
	if(phonenumb == PlayerInfo[playerid][pPnumber])
	{
		SendClientMessageEx(playerid, COLOR_GRAD2, "  You just get a busy tone...");
		return 1;
	}
	if(Mobile[playerid] != INVALID_PLAYER_ID)
	{
		SendClientMessageEx(playerid, COLOR_GRAD2, "  You are already on a call...");
		return 1;
	}
	foreach(Player, i)
	{
		if(PlayerInfo[i][pPnumber] == phonenumb && phonenumb != 0)
		{
			new giveplayerid = i;
			Mobile[playerid] = giveplayerid; //caller connecting
			if(IsPlayerConnected(giveplayerid))
			{
				if(giveplayerid != INVALID_PLAYER_ID)
				{
					if(PhoneOnline[giveplayerid] > 0)
					{
						SendClientMessageEx(playerid, COLOR_GREY, "That player's phone is switched off.");
						Mobile[playerid] = INVALID_PLAYER_ID;
						return 1;
					}
					if(Mobile[giveplayerid] != INVALID_PLAYER_ID)
					{
						SendClientMessageEx(playerid, COLOR_GRAD2, "You just get a busy tone...");
						Mobile[playerid] = INVALID_PLAYER_ID;
						return 1;
					}
					if(Spectating[giveplayerid]!=0)
					{
						SendClientMessageEx(playerid, COLOR_GRAD2, "You just get a busy tone...");
						Mobile[playerid] = INVALID_PLAYER_ID;
						return 1;
					}
					if (Mobile[giveplayerid] == INVALID_PLAYER_ID)
					{
						format(string, sizeof(string), "Your mobile is ringing - type /p to answer it. [Caller ID: %s]", GetPlayerNameEx(playerid));
						SendClientMessageEx(giveplayerid, COLOR_YELLOW, string);
						RingTone[giveplayerid] = 10;
						format(string, sizeof(string), "* %s's phone begins to ring.", GetPlayerNameEx(i));
						SendClientMessageEx(playerid, COLOR_WHITE, "HINT: You now use T to talk on your cellphone, type /hangup to hang up.");
						ProxDetector(30.0, i, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
						new Float:rX, Float:rY, Float:rZ;
						GetPlayerPos(giveplayerid, rX, rY, rZ);
   						SendAudioToRange(6802, 100, 0, rX, rY, rZ, 30.0);
		    			SendAudioToPlayer(playerid, 6148, 100, 0);
						CellTime[playerid] = 1;
						return SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
					}
				}
			}
		}
	}
	SendClientMessageEx(playerid, COLOR_GRAD2, "Your call can not be completed as dialed, please check the number and try again.");
	return 1;
}
Reply
#6

So where can I put it since I don't have a /call911?
Reply
#7

You do have a /call command, from there it is likely to be continued under OnPlayerText. Search for "== 911" or something similiar. Also, there is a good sound for a fire alarm for a fire station already in SA:MP. 3401. By using a sound in SAMP it suits the environment better and also doesn't post a message. You would still loop through the player's positions and check if they were in the range of said point.

Hello Patrick. It is I - Nate.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)