SA-MP Forums Archive
IsPlayerNearTeamMate - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: IsPlayerNearTeamMate (/showthread.php?tid=460018)



IsPlayerNearTeamMate - SwisherSweet - 25.08.2013

how do i do this, i have a explosion function for my zombie server and people are abusing the explosion so i need to make the explosion smaller, yet the radius between zombies a little longer...
so far i have this
Код:
	if(newkeys & KEY_SECONDARY_ATTACK) {
		if(pTeam[playerid] == ZOMBIE) {
		
			if(Player[playerid][CLASS_ZOMBIE] == 7 && Player[playerid][canexplode]) {
            	
			    new Float:P[3];
			    GetPlayerPos(playerid, P[0], P[1], P[2]);
				CreateExplosion(P[0], P[1], P[2], 7, 3.0);
				SetPlayerHealth(playerid, 0);
				Player[playerid][canexplode] = 0;
				SetTimerEx("AllowExplode", 60000, false, "i", playerid);
			}
		}
	}
but this just creates explosion not checks if team mate is near...
I think you would need to use this to detect how far away player from player
if(pTeam[playerid] == ZOMBIE)
but i have no idea how to do this...


Re: IsPlayerNearTeamMate - ViruZz - 25.08.2013

Have you ever thought about using IsPlayerInRangeOfPoint of the teammates coordinates? Just make a function and inside that function loop through all the players and see who's near and who isn't.

EDIT:

pawn Код:
#include <a_samp>

#undef MAX_PLAYERS
#define MAX_PLAYERS (500)

stock IsInRangeOfZombies(playerid)
{
    new Float: mypos[3];
    GetPlayerPos(playerid, mypos[0], mypos[1], mypos[2]);
   
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(Player[i][CLASS_ZOMBIE] > 0)
        {
            if(IsPlayerInRangeOfPoint(i, 5.0, mypos[0], mypos[1], mypos[2]))
            {
                break;
                return true; // You're in range of a zombie so break the loop and return true
            }
        }
    }      
    return false;
}
Wasn't tested but it compiles fine and should work.