Something wrong with this array?
#1

pawn Код:
new Float:BusStop[16][3] = {
{1832.73242, -1880.88342, 12.36594},
{1832.60999, -1690.59460, 13.73497},
{1520.96875, -1583.72754, 13.91397},
{1364.55237, -1423.36169, 13.65808},
{1179.68799, -1386.72290, 13.86295},
{771.32434, -1386.78711, 13.86283},
{150.10970, -1539.03699, 10.82432},
{444.45468, -1727.82556, 10.38579},
{503.34659, -1295.16431, 16.03390},
{810.81256, -1060.01526, 25.24116},
{1177.41309, -959.84564, 43.19349},
{1349.26270, -948.11871, 34.95800},
{2254.39746, -1151.61963, 26.58891},
{2853.30054, -1641.15259, 11.13167},
{2448.25122, -1724.31128, 14.03288},
{2112.02832, -1744.08875, 13.72411}
};
Well the problem is when I use it in a command like:
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 8.0,BusStop[playerid][0],BusStop[playerid][1],BusStop[playerid][2]))
It only works for the second position in the list, and I already made sure the pos are in the right place. Any help will be appreciated, thanks
Reply
#2

That array isn't indexed by player ID's..

Where you have [playerid] you need to have a number. That number begins from 0 and corresponds with each set of float values in the array. So, BusStop[0][0] is 1832.73242, and BusStop[0][2] is 12.36594.
Reply
#3

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
That array isn't indexed by player ID's..

Where you have [playerid] you need to have a number. That number begins from 0 and corresponds with each set of float values in the array. So, BusStop[0][0] is 1832.73242, and BusStop[0][2] is 12.36594.
So how can IsPlayerInRangeOfPoint check for all the positions? I'm newbie with arrays
Reply
#4

pawn Код:
for(new i; i < sizeof(BusStop); i++)
{
    if(IsPlayerInRangeOfPoint(playerid, 8.0,BusStop[i][0],BusStop[i][1],BusStop[i][2]))
    {
        // do stuff
        break;
    }
}
Like that.
Reply
#5

Searching helps mate. Try it next time.

pawn Код:
for(new i = 0; i < sizeof(BusStop); i++)
{
    if(IsPlayerInRangeOfPoint(playerid, range, BusStop[i][0], BusStop[i][1], BusStop[i][2]))
    {
        // do something
        break;
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)