05.02.2015, 20:06
How to get Nearby players like
when player do /kill
you can't sucide, when your Enemy nearby
sorry for english
when player do /kill
you can't sucide, when your Enemy nearby
sorry for english
foreach(Player, i)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(IsPlayerInRangeOfPoint(i, 10.0, x, y, z) && GetPlayerTeam(i) != GetPlayerTeam(playerid))
{
return SendClientMessage(playerid, -1, "Enemy Near You!");
}
}
make a loop between players and check their position and team
i'll give you a simple example script pawn Код:
|
c(kill)
{
foreach(Player, i)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(IsPlayerInRangeOfPoint(i, 20.0, x, y, z) && gTeam[i] != gTeam[playerid])
{
SetPlayerHealth(playerid,0.0);
return SendClientMessage(playerid, -1, "Error : You can not use this command when an enemy is near you!");
}
}
return 1;
}
c(kill)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
foreach(Player, i)
{
if((IsPlayerInRangeOfPoint(i, 20.0, x, y, z)) && (gTeam[i] != gTeam[playerid]))
{
return SendClientMessage(playerid, -1, "Error : You can not use this command when an enemy is near you!");
}
}
SetPlayerHealth(playerid,0.0);
return 1;
}