SA-MP Forums Archive
IsPlayerInRangeOfPoint - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: IsPlayerInRangeOfPoint (/showthread.php?tid=302462)



IsPlayerInRangeOfPoint - gagnier91 - 09.12.2011

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)


Re: IsPlayerInRangeOfPoint - antonio112 - 09.12.2011

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

Instead of:
pawn Код:
for(new i = 0; i <= 1; i++) {
use:
pawn Код:
for(new i = 0; i < 1 + 1; i++) {



Re : IsPlayerInRangeOfPoint - gagnier91 - 09.12.2011

it still say the player isn't in the radius even when im touching the object i used for the point


Re: IsPlayerInRangeOfPoint - MoroDan - 09.12.2011

Quote:
Originally Posted by gagnier91
Посмотреть сообщение
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:
PHP код:
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 
0sizeof(ZoneInfo); i++)
    {
        if (
IsPlayerInRangeOfPoint(playerid45.0ZoneInfo[i][0], ZoneInfo[i][1], ZoneInfo[i][2]))
            return 
1;
       }
    return 
0;

Quote:
Originally Posted by antonio112
Посмотреть сообщение
You can't use '<=' or '>=' in a loop.

Instead of:
pawn Код:
for(new i = 0; i <= 1; i++) {
use:
pawn Код:
for(new i = 0; i < 1 + 1; i++) {
LOOOOOOOL ! Who told you that :O ?


Re: IsPlayerInRangeOfPoint - MadeMan - 09.12.2011

Are you sure you are near {1411.0,-2408.8,17.379} ?


Re : Re: IsPlayerInRangeOfPoint - gagnier91 - 09.12.2011

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
Are you sure you are near {1411.0,-2408.8,17.379} ?
Yes, i am.

Quote:
Originally Posted by MoroDan
Посмотреть сообщение
Try this:
PHP код:
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 
0sizeof(ZoneInfo); i++)
    {
        if (
IsPlayerInRangeOfPoint(playerid45.0ZoneInfo[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..


Re : IsPlayerInRangeOfPoint - gagnier91 - 09.12.2011

Now, i get the tag mismatch error for each thing in my array :
pawn Код:
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
};



Re: IsPlayerInRangeOfPoint - Sinc - 09.12.2011

Quote:
Originally Posted by antonio112
Посмотреть сообщение
You can't use '<=' or '>=' in a loop.

Instead of:
pawn Код:
for(new i = 0; i <= 1; i++) {
use:
pawn Код:
for(new i = 0; i < 1 + 1; i++) {
Yes, you may.


Re : IsPlayerInRangeOfPoint - gagnier91 - 09.12.2011

its now working perfectly, thank you !