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;
}
Use IsPlayerInRangeOfPoint
You just need fire station coordinates (/save or /rs ingame) e.g 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
}
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; }