SetPlayerCheckpoint
#7

pawn Код:
forward checkpointUpdate();
public checkpointUpdate()
{
    for(new i = 0; i < GetMaxPlayers(); i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(!pInfo[i][pSpawn]) continue;
        new j = GetClosestCheckpoint(i);
        if(j)
        {
            if(pInfo[i][pCheckpoint] != j)
            {
                pInfo[i][pCheckpoint] = j;
                SetPlayerCheckpoint(i, HouseInfo[j][h_cpx], HouseInfo[j][h_cpy], HouseInfo[j][h_cpz], HouseInfo[j][h_cpsize]);
                //format(string, sizeof(string), "Checkpoint %d",j);
                //SendClientMessage(i, COLOR_YELLOW, string);
            }
        }
        else
        {
            if(pInfo[i][pCheckpoint])
            {
                pInfo[i][pCheckpoint] = 0;
                DisablePlayerCheckpoint(i);
            }
        }
    }
    return 1;
}

stock GetClosestCheckpoint(playerid)
{
    new Float:tmpdis, Float:curdis = 9000.0, cpid = 0;
    for(new i = 0; i < sizeof(HouseInfo); i++)
    {
        GetDistanceToPoint(playerid, HouseInfo[i][h_cpx], HouseInfo[i][h_cpy], HouseInfo[i][h_cpz], tmpdis);
        if(tmpdis < HouseInfo[i][h_cp_radius])
        {
            if(tmpdis < curdis)
            {
                curdis = tmpdis;
                cpid = i;
            }
        }
    }
    return cpid;
}
I don't actually know if this will help, but this looks right to me.
Reply


Messages In This Thread
SetPlayerCheckpoint - by AroseKhanNiazi - 20.05.2014, 14:50
Re: SetPlayerCheckpoint - by AroseKhanNiazi - 21.05.2014, 03:26
Re: SetPlayerCheckpoint - by Threshold - 21.05.2014, 04:39
Re: SetPlayerCheckpoint - by AroseKhanNiazi - 21.05.2014, 05:09
Re: SetPlayerCheckpoint - by MacT - 21.05.2014, 05:21
Re: SetPlayerCheckpoint - by AroseKhanNiazi - 21.05.2014, 05:37
Re: SetPlayerCheckpoint - by Threshold - 22.05.2014, 09:37
Re: SetPlayerCheckpoint - by AroseKhanNiazi - 22.05.2014, 09:54
Re: SetPlayerCheckpoint - by Threshold - 22.05.2014, 11:00
Re: SetPlayerCheckpoint - by AroseKhanNiazi - 22.05.2014, 11:15

Forum Jump:


Users browsing this thread: 1 Guest(s)