Problem with my code.. Maybe somebody knows better
#8

Edit: I've just tested your code, and I don't get soemthing
I've modefided it alittle bit, and that's what I got:
Код:
forward AudioUpdate();public AudioUpdate()
{
	CheckPlayers=0;
	new string[256];
	new MaxPlayers=GetMaxPlayers();
	new Float:X[2],Float:Y[2],Float:Z[2];
	//GetPlayerPos(playerid,X[0],Y[0],Z[0];
	X[0] = -1935.770019;
    Y[0] = 228.789993;
    Z[0] = 34.156250;
	for(new ID=0;ID<MaxPlayers;ID++)//loop1: collect all connected players
	{
		if(IsPlayerConnected(ID) && !IsPlayerNPC(ID))
		{
			CheckPlayerID[CheckPlayers]=ID;
			CheckPlayers++;
		}
	}
	ListenPlayers=0;
	ShutUpPlayers=0;
	for(new ID=0;ID<CheckPlayers;ID++)//loop2: estimate the distance
	{
		if(IsPlayerInRangeOfPoint(CheckPlayerID[ID],100.0,X[0],Y[0],Z[0])==1)
		{
			ListenID[ListenPlayers]=CheckPlayerID[ID];
			ListenPlayers++;
		}
		else
		{
			ShutUpID[ShutUpPlayers]=CheckPlayerID[ID];
			ShutUpPlayers++;
		}
	}
	for(new ID=0;ID<ListenPlayers;ID++)//loop3a: ListenID[] array gets played
	{
		                GetPlayerPos(ID,X[1],Y[1],Z[1]);
        	            new distance = 100 - floatround(floatsqroot(floatpower(floatabs(X[1] - X[0]), 2) + floatpower(floatabs(Y[1] - Y[0]), 2) + floatpower(floatabs(Z[1] - Z[0]), 2)), floatround_ceil);
        	            format(string, sizeof(string), "Distance: %d", distance);
        	            SendClientMessage(ID,0xFFFFFFAA,string);
        				Audio_SetVolume(ID, soundID_siren[ID], distance);
	}
	for(new ID=0;ID<ShutUpPlayers;ID++)//loop3b: ShutUpID[] array gets stopped indeed ^^
	{
		Audio_SetVolume(ID, soundID_siren[ID], 0);
	}
	return 1;
}
How can I check if any player turned on his siren? (Siren Public whitch changes the siren[playerid] to 0/1)?

I don't understand how should I use it.


Edit: I tried to use this function which checks if any player has his siren on, still doesn't work:
Код:
forward AudioUpdate();public AudioUpdate()
{
	CheckPlayers=0;
	new string[256];
	new MaxPlayers=GetMaxPlayers();
	new Float:X[2],Float:Y[2],Float:Z[2];
	for(new ID=0;ID<MaxPlayers;ID++)//loop1: collect all connected players
	{
		if(IsPlayerConnected(ID) && !IsPlayerNPC(ID))
		{
			CheckPlayerID[CheckPlayers]=ID;
			CheckPlayers++;
		}
	}
	for(new tID=0;tID<CheckPlayers;tID++)
	{
		if(siren[CheckPlayerID[tID]] == 1)
		{
        	//GetPlayerPos(playerid,X[0],Y[0],Z[0];
        	X[0] = -1935.770019;
            Y[0] = 228.789993;
            Z[0] = 34.156250;
            
            ListenPlayers=0;
        	ShutUpPlayers=0;
        	for(new ID=0;ID<CheckPlayers;ID++)//loop2: estimate the distance
        	{
        		if(IsPlayerInRangeOfPoint(CheckPlayerID[ID],100.0,X[0],Y[0],Z[0])==1)
        		{
        			ListenID[ListenPlayers]=CheckPlayerID[ID];
        			ListenPlayers++;
        		}
        		else
        		{
        			ShutUpID[ShutUpPlayers]=CheckPlayerID[ID];
        			ShutUpPlayers++;
        		}
        	}
        	for(new ID=0;ID<ListenPlayers;ID++)//loop3a: ListenID[] array gets played
        	{
        		                GetPlayerPos(ID,X[1],Y[1],Z[1]);
                	            new distance = 100 - floatround(floatsqroot(floatpower(floatabs(X[1] - X[0]), 2) + floatpower(floatabs(Y[1] - Y[0]), 2) + floatpower(floatabs(Z[1] - Z[0]), 2)), floatround_ceil);
                	            format(string, sizeof(string), "Distance: %d", distance);
                	            SendClientMessage(ID,0xFFFFFFAA,string);
                				Audio_SetVolume(ID, soundID_siren[ID], distance);
        	}
        	for(new ID=0;ID<ShutUpPlayers;ID++)//loop3b: ShutUpID[] array gets stopped indeed ^^
        	{
        		Audio_SetVolume(ID, soundID_siren[ID], 0);
        	}
		}
	}
	///////////
	
	////////////////
	return 1;
}

Anyone?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)