Porblem with ranges.
#1

I am trying to check if player in point of range of the dropped weapon;
Код:
if(IsPlayerInRangeOfPoint(playerid,2.5,DropsInfo[i][wp_x][k],DropsInfo[i][wp_y][k],DropsInfo[i][wp_z][k]))
				{
					print("Player Is in range.");
This doesn't work.
I tried some debugging and I get odd results;
Код:
FUNCTION Drops_ReplaceIt(playerid)
{
	new Float:x,Float:y,Float:z;
	GetPlayerPos(playerid,x,y,z);
	printf("Replace weapon called for %d",playerid);
	for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
	{
		if(!IsPlayerConnected(i)) continue;
		printf("Checking player %d's drops",i);
		for(new k=0; k<13; k++)
		{
			printf("Checking the info of Dropped (%b) %0.2f %0.2f %0.2f",DropsInfo[i][wp_Dropped][k],DropsInfo[i][wp_x][k],DropsInfo[i][wp_y][k],DropsInfo[i][wp_z][k]);
			
			if(DropsInfo[i][wp_Dropped][k])
			{
				print("Drop is dropped.");
				printf("Player pos %0.2f %0.2f %0.2f",x,y,z);
				printf("Distance is %0.2f",GetPlayerDistanceFromPoint(playerid, DropsInfo[i][wp_x][k],DropsInfo[i][wp_y][k],DropsInfo[i][wp_z][k]));
				
				if(((x+2.5 >= DropsInfo[i][wp_x][k] && x+2.6 <= DropsInfo[i][wp_x][k]) || (x-2.5 >= DropsInfo[i][wp_x][k] && x-2.6 <= DropsInfo[i][wp_x][k])) && ((y+2.5 >= DropsInfo[i][wp_y][k] && y+2.6 <= DropsInfo[i][wp_y][k]) || (y-2.5 >= DropsInfo[i][wp_y][k] && y-2.6 <= DropsInfo[i][wp_y][k])) && ((z+2.5 >= DropsInfo[i][wp_z][k] && z+2.6 <= DropsInfo[i][wp_z][k]) || (z-2.5 >= DropsInfo[i][wp_x][k] && z-2.6 <= DropsInfo[i][wp_z][k])))
				{
					printf("Fucking Shit works somehow");
				}
				
				if(IsPlayerInRangeOfPoint(playerid,2.5,DropsInfo[i][wp_x][k],DropsInfo[i][wp_y][k],DropsInfo[i][wp_z][k]))
				{
					print("Player Is in range.");
result:
Код:
Replace weapon called for 0
[18:01:10]
 Checking player 0's drops
[18:01:10]
 Checking the info of Dropped (0) 0.00 0.00 0.00
[18:01:10]
 Checking the info of Dropped (0) 0.00 0.00 0.00
[18:01:10]
 Checking the info of Dropped (0) 0.00 0.00 0.00
[18:01:10]
 Checking the info of Dropped (0) 0.00 0.00 0.00
[18:01:10]
 Checking the info of Dropped (0) 0.00 0.00 0.00
[18:01:10]
 Checking the info of Dropped (0) 0.00 0.00 0.00
[18:01:10]
 Checking the info of Dropped (0) 0.00 0.00 0.00
[18:01:10]
 Checking the info of Dropped (0) 0.00 0.00 0.00
[18:01:10]
 Checking the info of Dropped (0) 0.00 0.00 0.00
[18:01:10]
 Checking the info of Dropped (0) 0.00 0.00 0.00
[18:01:10]
 Checking the info of Dropped (0) 0.00 0.00 0.00
[18:01:10]
 Checking the info of Dropped (0) 0.00 0.00 0.00
[18:01:10]
 Checking the info of Dropped (0) 0.00 0.00 0.00
[18:01:10]
 Checking player 1's drops
[18:01:10]
 Checking the info of Dropped (0) 0.00 0.00 0.00
[18:01:10]
 Checking the info of Dropped (0) 0.00 0.00 0.00
[18:01:10]
 Checking the info of Dropped (0) 0.00 0.00 0.00
[18:01:10]
 Checking the info of Dropped (1) 2901.58 2097.20 10.82
[18:01:10]
 Drop is dropped.
[18:01:10]
 Player pos 2901.48 2097.05 10.82
[18:01:10]
 Distance is 1970902656.00
[18:01:10]
 Checking the info of Dropped (0) 0.00 0.00 0.00
//....
Other info;
Код:
enum wpdrops_enum {
	bool:wp_Dropped,
	wp_id,
	wp_weapon,
	wp_ammo,
	Float:wp_x,
	Float:wp_y,
	Float:wp_z,
	wp_slot
};

new DropsInfo[MAX_PLAYERS][wpdrops_enum][13];
Reply
#2

Do you break your loops when the result is true?

Код:
if(((x+2.5 >= DropsInfo[i][wp_x][k] && x+2.6 <= DropsInfo[i][wp_x][k]) || (x-2.5 >= DropsInfo[i][wp_x][k] && x-2.6 <= DropsInfo[i][wp_x][k])) && ((y+2.5 >= DropsInfo[i][wp_y][k] && y+2.6 <= DropsInfo[i][wp_y][k]) || (y-2.5 >= DropsInfo[i][wp_y][k] && y-2.6 <= DropsInfo[i][wp_y][k])) && ((z+2.5 >= DropsInfo[i][wp_z][k] && z+2.6 <= DropsInfo[i][wp_z][k]) || (z-2.5 >= DropsInfo[i][wp_x][k] && z-2.6 <= DropsInfo[i][wp_z][k])))
				{
					printf("Fucking Shit works somehow");
                                        break;
				}
				
				if(IsPlayerInRangeOfPoint(playerid,2.5,DropsInfo[i][wp_x][k],DropsInfo[i][wp_y][k],DropsInfo[i][wp_z][k]))
				{
					print("Player Is in range.");
                                        break;
Reply
#3

Yes i use break
Reply
#4

Fixed: Thanks to MichaelBelgium
changed new DropsInfo[MAX_PLAYERS][wpdrops_enum][13];
to new DropsInfo[MAX_PLAYERS][13][wpdrops_enum];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)