Yes, but the approach to this depends on whether these positions are going to change while the script is running or not. Are you adding the positions in-game or do you add them manually to the script?
Anyway, using arrays, here's an example.
PHP код:
new Float:MyPoints[][3] = { // These are all your coordinates. {x coordinate, y coordinate, z coordinate}
{100.0, 200.0, 300.0}, // Point 1
{1000.0, 2000.0, 3000.0}, // Point 2
{10.0, 20.0, 30.0}, // Point 3
{1.0, 2.0, 3.0} // Point 4
// You can continue this as many times as you like
};
IsPlayerWithinRangeOfPoint(playerid, Float:range, point = -1)
{
if(point == -1) // If you aren't trying to find a particular point, but all points in general
{
for(new i = 0; i < sizeof(MyPoints); i++) // Start looping through all the points you have created.
{
if(IsPlayerInRangeOfPoint(playerid, range, MyPoints[i][0], MyPoints[i][1], MyPoints[i][2])) // If the player is within range of the point...
return 1; // Return '1' or true.
}
}
else if(0 <= point <= sizeof(MyPoints)) // If you are trying to check for a particular point, for example point 3
{
return IsPlayerInRangeOfPoint(playerid, range, MyPoints[point][0], MyPoints[point][1], MyPoints[point][2]); // Checks if they are near the point specified, returns either 1 or 0.
}
return 0; // Return '0' or false. They are not near a point.
}
Here's an example of how you might use it. To check if a player is within 10.0 units of any given point:
PHP код:
public OnPlayerSpawn(playerid)
{
if(IsPlayerWithinRangeOfPoint(playerid, 10.0))
{
SendClientMessage(playerid, -1, "You are within 10 metres of a point!");
}
else SendClientMessage(playerid, -1, "You are not close enough to a point.");
return 1;
}
If you wanted to see if they were within 100 units of point 12, you would do this:
PHP код:
public OnPlayerSpawn(playerid)
{
if(IsPlayerWithinRangeOfPoint(playerid, 100.0, 12))
{
SendClientMessage(playerid, -1, "You are within 100 metres of point number 12!");
}
else SendClientMessage(playerid, -1, "You are not close enough to point number 12.");
return 1;
}