IsPlayerInRangeOfPoint bugged?
#1

Or is just me?

I have this in a FS:

no matter if I put 0.0, 0.1, 0.5, this trigger is always TRUE.

What the fuck?

* x, y, and z coordinates are taken from npcid, wich is an npc executing the timer that contains this loop.

Код:
if(IsPlayerInRangeOfPoint(i, 0.5, x,y,z)) // HERE
{
 	if(IsPlayerAimingAtPlayer(i, npcid))
    {
		switch(weapon)
		{
		  case 0,14: NPC_Chat[npcid][life] -= 7;
		  case 1: NPC_Chat[npcid][life] -= 8;
		  case 2,3,5,6,7,15: NPC_Chat[npcid][life] -= 10;
		  case 4,8: NPC_Chat[npcid][life] -= 14;
		  case 22,23,24,25,26,27,28,29,30,31,32,33: NPC_Chat[npcid][life] -= 2;
		  case 34: continue;
		}

		ApplyAnimation(npcid,"ped","HIT_front",4.1,0,0,0,0,0);
		NPC_Chat[npcid][insultedby] = i; // You anger the bastard!!!
	    //SendClientMessage(i, COLOR_RED, "DAMAGE 1.0");
     }
}
Here's the header if you like:

Код:
forward Check(npcid);
public Check(npcid)
{
  new Float:x,Float:y,Float:z,name[30];
  GetPlayerPos(npcid, x,y,z);
  GetPlayerName(npcid, name, sizeof(name));
  

	for(new i=0;i<MAX_PLAYERS;i++)
	{
		if(i != npcid && IsPlayerConnected(i) && ( !IsPlayerNPC(i) || (IsPlayerNPC(i) && IsPlayerInAnyVehicle(i))))
		{
           if(((HOLDING(KEY_HANDBRAKE) && (PRESSED(KEY_FIRE) || PRESSED(KEY_SECONDARY_ATTACK)) || PRESSED(KEY_FIRE))) && PlayerKeys[i][1] != 300 && !IsPlayerInAnyVehicle(i) && GetPlayerState(i) == 1)
           {	          
              if(IsPlayerInRangeOfPoint(i, 0.5, x,y,z)) // THIS IS THE PART
		      {
 					 if(IsPlayerAimingAtPlayer(i, npcid))
	                    {
						switch(weapon)
						{
							 case 0,14: NPC_Chat[npcid][life] -= 7;
							 case 1: NPC_Chat[npcid][life] -= 8;
							 case 2,3,5,6,7,15: NPC_Chat[npcid][life] -= 10;
							 case 4,8: NPC_Chat[npcid][life] -= 14;
							 case 22,23,24,25,26,27,28,29,30,31,32,33: NPC_Chat[npcid][life] -= 2;
							 case 34: continue;
						}
						ApplyAnimation(npcid,"ped","HIT_front",4.1,0,0,0,0,0);
						NPC_Chat[npcid][insultedby] = i; // You anger the bastard!!!
	                    //SendClientMessage(i, COLOR_RED, "DAMAGE 1.0");
					 }
			  }
           }
     }
}
I just gave you the start of the timer, where the variables are taken from, and the condition. There are other checks before that, but they don't mess with this part. Every check is independent.
Reply
#2

Isn't IsPlayerInRangeOfPoint a custom function?
If so, show us the code of your IPIROP func.


The code you showed us is pretty useless since we also don't know where you get i from, and where you get x,y,z from.
Reply
#3

Quote:
Originally Posted by kingdutch
Isn't IsPlayerInRangeOfPoint a custom function?
No its a pre-defined

But where did you fefine 'i' ? is that function in a for loop or something like that?
Reply
#4

Quote:
Originally Posted by kingdutch
Isn't IsPlayerInRangeOfPoint a custom function?
If so, show us the code of your IPIROP func.


The code you showed us is pretty useless since we also don't know where you get i from, and where you get x,y,z from.
i stated that x y and z are taken from npcid, wich is the id of the npc passed to the timer this loop is in.

i is the playerid taken from a loop that meet the requirement of beign InPlayerRangeOfPoint.

In other words, X Y Z are the position from npcid and i is the player detected to be close to the npc taken from a "for" loop.
Reply
#5

Yes however, I can state that my code does something, however if I made a little error I don't spot myself, no one is going to notice without some code.

Usually to check if something is a bug the original poster breaks his code down to the function that produces the error and gives a little compilable code snippet so others can see if the bug happens on other machines as well. So something like this:
Код:
OnPlayerSpawn(playerid) { if (IsPlayerInRangeOfPoint(playerid, 1.0, /*some static x,y,z*/)) { print("True"); } else { print( "False" ); } }
If that piece of code still produces the bug I'd say you have excluded all external influences and it's a bug out of your reach, if this little piece of code does not display the bug, you probably made a mistake.
Reply
#6

I updated the data.

Now can see where the timer starts and where i get the coords.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)