If is player near coords.. -
Lajko1 - 21.11.2013
Hey I'm trying to detect if player is near those coords:
pawn Код:
new GasStations[8][]=
{
{1942.0497,-1769.2963,13.6406}, // IW 1
{1941.6536,-1776.3457,13.6406}, // IW 2
{-1601.3220,-2708.2751,48.5391}, // highway towards Prickle Pine
{1604.5129,-2712.7729,48.5335}, // highway towards Prickle Pine
{-1607.7809,-2717.2312,48.5391}, // highway towards Prickle Pine
{-1610.9799,-2722.2913,48.5391}, // highway towards Prickle Pine
{-2247.2778,-2559.1624,31.9219}, // Diliamore
{-2240.6899,-2562.2366,31.9219} // Dilliamore
};
I want to detect them in this function:
pawn Код:
if(!IsPlayerInRangeOfPoint(playerid, 7.0, 2695.6880, -1704.6300, 11.8438))
what to write in parameters to detect if player is near those coords?
And, is code correct? I'm not getting any errors for now..
Thanks for help in advance
Re: If is player near coords.. -
newbie scripter - 21.11.2013
if u use '!' , it means that if he ISN'T in that place.
Re: If is player near coords.. -
Konstantinos - 21.11.2013
pawn Код:
forward bool: IsPlayerInRangeOfGasStations( playerid );
new GasStations[8][3]=
{
{1942.0497,-1769.2963,13.6406}, // IW 1
{1941.6536,-1776.3457,13.6406}, // IW 2
{-1601.3220,-2708.2751,48.5391}, // highway towards Prickle Pine
{1604.5129,-2712.7729,48.5335}, // highway towards Prickle Pine
{-1607.7809,-2717.2312,48.5391}, // highway towards Prickle Pine
{-1610.9799,-2722.2913,48.5391}, // highway towards Prickle Pine
{-2247.2778,-2559.1624,31.9219}, // Diliamore
{-2240.6899,-2562.2366,31.9219} // Dilliamore
};
stock bool: IsPlayerInRangeOfGasStations( playerid )
{
new
bool: in_range
;
for( new i; i != sizeof( GasStations ); i++ )
{
if( IsPlayerInRangeOfPoint( playerid, 7.0, GasStations[ i ][ 0 ], GasStations[ i ][ 1 ], GasStations[ i ][ 2 ] ) )
{
in_range = true;
break;
}
}
return in_range;
}
Where you want to check:
pawn Код:
if( IsPlayerInRangeOfGasStations( playerid ) )
{
// player is in range:
}
Re: If is player near coords.. -
Lajko1 - 21.11.2013
@Newbie scripter: I know that ^^
@Konstantinos:
Well I added your code for start it was great but after I added in my command:
pawn Код:
if( IsPlayerInRangeOfGasStations( playerid ) )
I received a lot of those warnings
pawn Код:
warning 213: tag mismatch
On those lines:
pawn Код:
{1942.0497,-1769.2963,13.6406}, // IW 1
{1941.6536,-1776.3457,13.6406}, // IW 2
{-1601.3220,-2708.2751,48.5391}, // highway towards Prickle Pine
{1604.5129,-2712.7729,48.5335}, // highway towards Prickle Pine
{-1607.7809,-2717.2312,48.5391}, // highway towards Prickle Pine
{-1610.9799,-2722.2913,48.5391}, // highway towards Prickle Pine
{-2247.2778,-2559.1624,31.9219}, // Diliamore
{-2240.6899,-2562.2366,31.9219} // Dilliamore
EDIT: Command I want to use:
pawn Код:
if(strcmp(cmdtext, "/refuel", true) == 0)
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You need to be in vehicle to use this command.");
if(IsPlayerInRangeOfGasStations(playerid))
{
// I will put code here
}
else
{
SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You are not near any gas pump.");
return 1;
}
return 1;
}
return 0;
}
Thanks for help in advance
Re: If is player near coords.. -
newbie scripter - 21.11.2013
what does 'i' mean?
Re: If is player near coords.. -
Konstantinos - 21.11.2013
Sorry about that, I pasted your GasStations array without changing the tag.
Anyways, change to:
pawn Код:
new Float: GasStations[8][3]=
{
{1942.0497,-1769.2963,13.6406}, // IW 1
{1941.6536,-1776.3457,13.6406}, // IW 2
{-1601.3220,-2708.2751,48.5391}, // highway towards Prickle Pine
{1604.5129,-2712.7729,48.5335}, // highway towards Prickle Pine
{-1607.7809,-2717.2312,48.5391}, // highway towards Prickle Pine
{-1610.9799,-2722.2913,48.5391}, // highway towards Prickle Pine
{-2247.2778,-2559.1624,31.9219}, // Diliamore
{-2240.6899,-2562.2366,31.9219} // Dilliamore
};
since they're floats.
Quote:
Originally Posted by newbie scripter
|
It's from the for loop. We use it to loop through each row of GasStations.
Re: If is player near coords.. -
iFiras - 21.11.2013
.
removed my post
Re: If is player near coords.. -
Lajko1 - 21.11.2013
newbie scripter, "i" is from here
pawn Код:
for( new i; i != sizeof( GasStations ); i++ )
as kons. said it's loop, I still don't know exactly what is this but I'm learning, thanks for help you will get rep+

it's working.
EDIT: I gave to much rep last 24 hours, don't worry you 2 will get it as soon as I will be able to give it
Re: If is player near coords.. -
newbie scripter - 21.11.2013
i know about loop,i just didn't see that piece of code. Thanks for rep.