Alarm System with PlayAudioStreamForPlayer. -
Dokins - 22.02.2015
pawn Код:
forward HouseAlarm();
public HouseAlarm()
{
foreach(i, Player)
{
if(NearAlarm[playerid] > 0 && HouseAlarm[NearAlarm[playerid]] == 1)
{
PlayAudioStreamForPlayer(i, "http://yourlisten.com/GrantAlexander/burglar-intruder-alarm-sound-effect", HouseEntX[NearAlarm[playerid]], HouseEntY[NearAlarm[playerid]], HouseEntZ[NearAlarm[playerid]], 50, 1);
}
if(NearAlarm[playerid] > 0 && HouseAlarm[NearAlarm[playerid]] == 2)
{
PlayAudioStreamForPlayer(i, "http://yourlisten.com/GrantAlexander/burglar-intruder-alarm-sound-effect", HouseEntX[NearAlarm[playerid]], HouseEntY[NearAlarm[playerid]], HouseEntZ[NearAlarm[playerid]], 100, 1);
}
if(NearAlarm[playerid] > 0 && HouseAlarm[NearAlarm[playerid]] == 3)
{
PlayAudioStreamForPlayer(i, "http://yourlisten.com/GrantAlexander/burglar-intruder-alarm-sound-effect", HouseEntX[NearAlarm[playerid]], HouseEntY[NearAlarm[playerid]], HouseEntZ[NearAlarm[playerid]], 150, 1);
}
}
}
Doing this will cause lag and I want the system for anyone who is near the house to hear, running a loop for each player every 2 or 3 seconds would cause lag.
How can I do it so I can make the sound play for any player when they are near the co-ordinates of the house without looping through all the players?
Re: Alarm System with PlayAudioStreamForPlayer. -
Maximus0 - 22.02.2015
I suggest making a checkpoint or pickup?
Re: Alarm System with PlayAudioStreamForPlayer. -
Dokins - 22.02.2015
The idea is that if you're driving around you might hear it
Re: Alarm System with PlayAudioStreamForPlayer. -
zT KiNgKoNg - 22.02.2015
Could you provide the code that changes the NearAlarm state?
Re: Alarm System with PlayAudioStreamForPlayer. -
Dokins - 22.02.2015
I was going to use onplayerupdate but I'd have to run a loop and that would cause lag
Re: Alarm System with PlayAudioStreamForPlayer. -
zT KiNgKoNg - 22.02.2015
I'd suggest using Tasks, and running everything in there related to the player, every 1,2,3,4,5 seconds. I've used a one-second timer in the past with players upto 25 for testing.
Re: Alarm System with PlayAudioStreamForPlayer. -
Dokins - 22.02.2015
What do you mean?
Re: Alarm System with PlayAudioStreamForPlayer. -
Kenway - 22.02.2015
You can do it simply by using OnPlayerEnterDynamicArea callback..Hope i helped you