Getclosest issue
#7

Quote:
Originally Posted by TwinkiDaBoss
Посмотреть сообщение
Yes thanks but I want to check if the player is ONLY in the beagle rustler
Okay use this

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;
}
Or add the check inside the function..
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;
}
Reply


Messages In This Thread
Getclosest issue - by TwinkiDaBoss - 01.08.2015, 14:27
AW: Getclosest issue - by Macronix - 01.08.2015, 14:45
Re: Getclosest issue - by Vince - 01.08.2015, 14:46
Re: Getclosest issue - by TwinkiDaBoss - 01.08.2015, 15:15
Re: Getclosest issue - by xVIP3Rx - 01.08.2015, 15:31
Re: Getclosest issue - by TwinkiDaBoss - 01.08.2015, 15:36
Re: Getclosest issue - by xVIP3Rx - 01.08.2015, 15:40
Re: Getclosest issue - by TwinkiDaBoss - 01.08.2015, 15:55
Re: Getclosest issue - by xVIP3Rx - 01.08.2015, 15:57
Re: Getclosest issue - by TwinkiDaBoss - 01.08.2015, 15:59

Forum Jump:


Users browsing this thread: 3 Guest(s)