GetPlayerTargetPlayer - Doesn't work with sniper
#1

GetPlayerTargetPlayer(playerid)

Doesn't work with sniper no matter how close or far away you are!
Doesn't work even when I am just a unit away from the player.
Reply
#2

That's because sniper's don't lock on to the player(and the green target indicator isn't there). This only returns a player if a green target indicating is showing.
Reply
#3

Quote:
Originally Posted by Abagail
View Post
That's because sniper's don't lock on to the player(and the green target indicator isn't there). This only returns a player if a green target indicating is showing.
That is correct this isn't a bug at all.
Reply
#4

It's still a bug if it dosen't work for snipers ph.
Reply
#5

Quote:
Originally Posted by Write
View Post
It's still a bug if it dosen't work for snipers ph.
Sniped players are not targeted therefore this is not a bug at all..... Use a line/sphere intersection function.

Code:
// This checks to see if a line intersects a sphere
stock RaySphere(Float:p1[3],Float:p2[3],Float:sc[3],Float:r)
{
	new Float:dist, Float:sdist1, Float:sdist2;
	dist = getdist3d(p1[0], p1[1], p1[2], p2[0], p2[1], p2[2]);
    sdist1 = getdist3d(sc[0], sc[1], sc[2], p1[0], p1[1], p1[2]);
    sdist2 = getdist3d(sc[0], sc[1], sc[2], p2[0], p2[1], p2[2]);
    
	// Make sure player is between the points if so check if the sphere intersects
    if(dist > sdist1 && dist > sdist2)
	{
		new Float:a, Float:b, Float:c, Float:bb4ac, Float:dp[3];
		dp[0] = p2[0] - p1[0];
		dp[1] = p2[1] - p1[1];
		dp[2] = p2[2] - p1[2];
		a = dp[0] * dp[0] + dp[1] * dp[1] + dp[2] * dp[2];
		b = 2 * (dp[0] * (p1[0] - sc[0]) + dp[1] * (p1[1] - sc[1]) + dp[2] * (p1[2] - sc[2]));
		c = sc[0] * sc[0] + sc[1] * sc[1] + sc[2] * sc[2];
		c += p1[0] * p1[0] + p1[1] * p1[1] + p1[2] * p1[2];
		c -= 2 * (sc[0] * p1[0] + sc[1] * p1[1] + sc[2] * p1[2]);
		c -= r * r;
		bb4ac = b * b - 4 * a * c;
		if(bb4ac < 0) return 0;
		return 1;
	}
	return 0;
}
Reply
#6

There is no way one can decide if its a bug or not.

https://sampwiki.blast.hk/wiki/GetPlayerTargetPlayer

If you follow the description of the function then this is a bug.

Quote:

Sniped players are not targeted therefore this is not a bug at all

What is targeted and non-targeted?
Reply
#7

It's not a bug the PLAYER IS NOT TARGETED! There is no internal mechanism that does this like the the other weapons get it through your head you can't get a targeted player if no player is targeted.
Reply
#8

It's not a bug, but is it sad that we can't know if a player is targeting a player with a sniper or not, yes it is!

Although, you can do some vectoral checks and know if the player is targeting a player with their sniper. But this requires checks at the server side, would it be better if we had functions to do it? Yes it would be!
Reply
#9

There is a function since 0.3.7 called GetPlayerCameraTargetPlayer

It returns the player that you're looking at. Give it a try for snipers!
Reply
#10

Quote:
Originally Posted by arakuta
View Post
There is a function since 0.3.7 called GetPlayerCameraTargetPlayer

It returns the player that you're looking at. Give it a try for snipers!
It's range is like 30 units or something, it doesn't work at long distances.
Reply
#11

Quote:
Originally Posted by Tamer
Посмотреть сообщение
It's range is like 30 units or something, it doesn't work at long distances.
Doesn't work even if I am 5 units away from the player.
Reply
#12

Quote:
Originally Posted by Yashas
Посмотреть сообщение
Doesn't work even if I am 5 units away from the player.
GetPlayerTargetPlayer or GetPlayerCameraTargetPlayer, sniper or no sniper. Explain your procedure.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)