15.01.2011, 14:18
I will try using your code, but take a look at that:
Siren Public: (getting called on each /siren cmd
The next public getting called each 0.1 seconds. It should set the level of each audio(for now there is only one audio(audioID_Siren), but there should be more.
Maybe you misunderstood what should the code do.
The siren should be heard in the positions:
siren[playerid] = 0; On player connect.
Siren Public: (getting called on each /siren cmd
Код:
public Siren(playerid) { new Float: pPos[3][2]; GetPlayerPos(playerid, pPos[0][0], pPos[1][0], pPos[2][0]); pPos[0][1] = -1935.770019; pPos[1][1] = 228.789993; pPos[2][1] = 34.156250; new tempSiren = 0; if(siren[playerid] == 0) { for(new i=0; i<MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && !IsPlayerNPC(i)) { //GetPlayerPos(i, pPos[0][1], pPos[1][1], pPos[2][1]); soundID_siren[i] = Audio_Play(i, 1, false, true, false); //Audio_SetVolume(i, soundID_siren[i], 0); SendClientMessage(i,0xFFFFFFAA,"Siren started volumu 0"); } } tempSiren = 1; //return 1; } else if(siren[playerid] == 1) { for(new i=0; i<MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && !IsPlayerNPC(i)) { Audio_Stop(i,soundID_siren[i]); SendClientMessage(i,0xFFFFFFAA,"Siren stopped for you"); } } tempSiren = 0; //return 1; } siren[playerid] = tempSiren; return 1; }
Код:
public AudioUpdate() { new Float: pPos[3][2]; new string[256]; for(new j=0; j<MAX_PLAYERS; j++) { if(siren[j] == 1) // check if soembody has his siren On { pPos[0][0] = -1935.770019; pPos[1][0] = 228.789993; pPos[2][0] = 34.156250; //GetPlayerPos(j, pPos[0][0], pPos[1][0], pPos[2][0]); for(new i=0; i<MAX_PLAYERS; i++)// { if(IsPlayerConnected(i) && !IsPlayerNPC(i)) { if(IsPlayerInRangeOfPoint(i, 100.0, pPos[0][0], pPos[1][0], pPos[2][0])) { GetPlayerPos(i, pPos[0][1], pPos[1][1], pPos[2][1]); new distance = 100 - floatround(floatsqroot(floatpower(floatabs(pPos[0][1] - pPos[0][0]), 2) + floatpower(floatabs(pPos[1][1] - pPos[1][0]), 2) + floatpower(floatabs(pPos[2][1] - pPos[2][0]), 2)), floatround_ceil); format(string, sizeof(string), "Distance: %d", distance); SendClientMessage(i,0xFFFFFFAA,string); Audio_SetVolume(i, soundID_siren[i], distance); //Audio_Resume(i, soundID_siren[i]); //return 1; } else { Audio_SetVolume(i, soundID_siren[i], 0); //Audio_Pause(i, soundID_siren[i]); //return 1; } } } } } return 1;//the value what function returning }
The siren should be heard in the positions:
Код:
pPos[0][0] = -1935.770019; pPos[1][0] = 228.789993; pPos[2][0] = 34.156250;