01.08.2015, 15:40
Quote:
Yes thanks but I want to check if the player is ONLY in the beagle rustler
|
pawn Код:
public GetClosestPlayerToPlayer(playerid)
{
new targetid = INVALID_PLAYER_ID;
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
for(new Float:closestdist = 999.0, Float:Dis, i; i<MAX_PLAYERS; i++) // You should use foreach or GetPlayerPoolSize
{
vmodel = GetVehicleModel(GetPlayerVehicleID(i));
if(i == playerid || !IsPlayerConnected(i) || pInfo[i][Team] == pInfo[playerid][Team] || vmodel != 511 || vmodel != 476) continue;
Dis = GetPlayerDistanceFromPoint(playerid, x, y, z);
if(Dis < closestdist)
{
closestdist = Dis;
targetid = i;
}
}
return targetid;
}
public CheckPlayersInRangeOfAA(playerid)
{
new id = GetClosestPlayerToPlayer(playerid),
Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(id != INVALID_PLAYER_ID && IsPlayerInRangeOfPoint(id, 200, x, y, z))
{
AAC = CreateObject(18647,x,y,z,0,0,0,0);
GetPlayerPos(id, x, y, z);
SetObjectToFaceCords(AAC, x, y, z);
MoveObject(AAC,x, y, z, 100);
new string[128];
format(string,sizeof(string),"Send a rocket towards %s",GetName(id));
}
return true;
}
pawn Код:
public CheckPlayersInRangeOfAA(playerid)
{
new id = INVALID_PLAYER_ID,
Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
for(new Float:closestdist = 200.0, Float:Dis, vmodel, i; i<MAX_PLAYERS; i++) // You should use foreach or GetPlayerPoolSize
{
vmodel = GetVehicleModel(GetPlayerVehicleID(i));
if(i == playerid || !IsPlayerConnected(i) || pInfo[i][Team] == pInfo[playerid][Team] || vmodel != 511 || vmodel != 476) continue;
//If he's not in a Rustler/Beagle we're not checking him
Dis = GetPlayerDistanceFromPoint(playerid, x, y, z);
if(Dis < closestdist)
{
closestdist = Dis;
id = i;
}
}
if(id != INVALID_PLAYER_ID)
{
AAC = CreateObject(18647,x,y,z,0,0,0,0);
GetPlayerPos(id, x, y, z);
SetObjectToFaceCords(AAC, x, y, z);
MoveObject(AAC,x, y, z, 100);
new string[128];
format(string,sizeof(string),"Send a rocket towards %s",GetName(id));
}
return true;
}