IsPlayerNearTeamMate
#1

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...
Reply
#2

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)