PDA

View Full Version : IsPlayerInRangeOfPoint


gagnier91
09/12/2011, 03:49 AM
Im trying to verify if a player is near a point from a list and then do some things with that. this is my list :
enum eZone {
Float:x,
Float:y,
Float:z,
}

new ZoneInfo[][eZone] = { //COORDONÉE DU POINT CENTRAL DE L'ENDROIT
{1411.0,-2408.8,17.379},
{1411.0,-2408.8,17.379}
};

My verification code :

public isin(playerid) {
new var = 0;
for(new i = 0; i <= 1; i++) {
if (IsPlayerInRangeOfPoint(playerid, 45.0, ZoneInfo[i][0], ZoneInfo[i][1], ZoneInfo[i][2])) {
var = 1;
}
}
return var;
}

when i want to see if the vehicle is near, i do this :
if(isin(playerid)) {

but it always return false (zero)

antonio112
09/12/2011, 06:20 AM
You can't use '<=' or '>=' in a loop.

Instead of:

for(new i = 0; i <= 1; i++) {


use:

for(new i = 0; i < 1 + 1; i++) {

gagnier91
09/12/2011, 03:44 PM
it still say the player isn't in the radius even when im touching the object i used for the point

MoroDan
09/12/2011, 05:01 PM
Im trying to verify if a player is near a point from a list and then do some things with that. this is my list :
enum eZone {
Float:x,
Float:y,
Float:z,
}

new ZoneInfo[][eZone] = { //COORDONÉE DU POINT CENTRAL DE L'ENDROIT
{1411.0,-2408.8,17.379},
{1411.0,-2408.8,17.379}
};

My verification code :

public isin(playerid) {
new var = 0;
for(new i = 0; i <= 1; i++) {
if (IsPlayerInRangeOfPoint(playerid, 45.0, ZoneInfo[i][0], ZoneInfo[i][1], ZoneInfo[i][2])) {
var = 1;
}
}
return var;
}

when i want to see if the vehicle is near, i do this :
if(isin(playerid)) {

but it always return false (zero)

Try this:

enum eZone
{
Float:x,
Float:y,
Float:z,
}

new ZoneInfo[][eZone] =
{ //COORDONÉE DU POINT CENTRAL DE L'ENDROIT
{1411.0,-2408.8,17.379},
{1411.0,-2408.8,17.379}
};

public isin(playerid)
{
for(new i = 0; i < sizeof(ZoneInfo); i++)
{
if (IsPlayerInRangeOfPoint(playerid, 45.0, ZoneInfo[i][0], ZoneInfo[i][1], ZoneInfo[i][2]))
return 1;
}
return 0;
}

You can't use '<=' or '>=' in a loop.

Instead of:

for(new i = 0; i <= 1; i++) {


use:

for(new i = 0; i < 1 + 1; i++) {



LOOOOOOOL ! Who told you that :O ?

MadeMan
09/12/2011, 06:26 PM
Are you sure you are near {1411.0,-2408.8,17.379} ?

gagnier91
09/12/2011, 09:00 PM
Are you sure you are near {1411.0,-2408.8,17.379} ?
Yes, i am.


Try this:

enum eZone
{
Float:x,
Float:y,
Float:z,
}

new ZoneInfo[][eZone] =
{ //COORDONÉE DU POINT CENTRAL DE L'ENDROIT
{1411.0,-2408.8,17.379},
{1411.0,-2408.8,17.379}
};

public isin(playerid)
{
for(new i = 0; i < sizeof(ZoneInfo); i++)
{
if (IsPlayerInRangeOfPoint(playerid, 45.0, ZoneInfo[i][0], ZoneInfo[i][1], ZoneInfo[i][2]))
return 1;
}
return 0;
}


I have 3 time this warning : warning 213: tag mismatch on this line :
if (IsPlayerInRangeOfPoint(playerid, 45.0, ZoneInfo[i][0], ZoneInfo[i][1], ZoneInfo[i][2]))

and still not working..

gagnier91
09/12/2011, 09:17 PM
Now, i get the tag mismatch error for each thing in my array :
new ZoneInfo[][eZone] =
{ //COORDONÉE DU POINT CENTRAL DE L'ENDROIT
{1411.0,-2408.8,17.379}, //3 errors here
{1411.0,-2408.8,17.379} //3 other errors here
};

Sinc
09/12/2011, 09:20 PM
You can't use '<=' or '>=' in a loop.

Instead of:

for(new i = 0; i <= 1; i++) {


use:

for(new i = 0; i < 1 + 1; i++) {


Yes, you may.

gagnier91
09/12/2011, 09:30 PM
its now working perfectly, thank you !