Pointer above the car
#1

Hey,

I once saw a server witch had a gps system with a pointer above the car pointing in the right direction, how do I make this?
Something like this : https://sampforum.blast.hk/showthread.php?tid=116622

Thanks
Reply
#2

Its looks like CreatePlayerObject + Attachobjecttoplayer + angle calculation to checkpoint
Reply
#3

Quote:
Originally Posted by Voldemort
Посмотреть сообщение
Its looks like CreatePlayerObject + Attachobjecttoplayer + angle calculation to checkpoint
Tought about that aswel, any idea wht's the cakculation/formula?
Reply
#4

Quote:
Originally Posted by Nameless303
Посмотреть сообщение
Tought about that aswel, any idea wht's the cakculation/formula?
If you dont know the trigonometric functions than search for GetAngleBetweenPoints
Reply
#5

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
If you dont know the trigonometric functions than search for GetAngleBetweenPoints
I don't even know what trigometric functions are, but I found this...
Код:
Float:GetAngleBetweenPoints(Float:X1,Float:Y1,Float:X2,Float:Y2)
{
  new Float:angle=atan2(X2-X1,Y2-Y1);
  if(angle>360)angle-=360;
  if(angle<0)angle+=360;
  return angle;
}
Would that do the job?
Reply
#6

Bump? ;s
Reply
#7

Jesus *facepalms* Try to ****** it, or just search around on the forums and wiki
Reply
#8

how about this one;
found it in an old missile launcher script

Код:
stock SetObjectToFaceCords(objectid, Float:x1, Float:y1, Float:z1)
{

	new Float:x2,Float:y2,Float:z2;
	GetObjectPos(objectid, x2,y2,z2);

	new Float:DX = floatabs(x2-x1);
	new Float:DY = floatabs(y2-y1);
	new Float:DZ = floatabs(z2-z1);

    new Float:yaw = 0;
    new Float:pitch = 0;

	if(DY == 0 || DX == 0)
	{
	    if(DY == 0 && DX > 0) {
			yaw = 00;
			pitch = 0; }
		else if(DY == 0 && DX < 0) {
			yaw = 180;
			pitch = 180; }
		else if(DY > 0 && DX == 0)  {
			yaw = 90;
			pitch = 90; }
		else if(DY < 0 && DX == 0) {
			yaw = 270;
			pitch = 270; }
		else if(DY == 0 && DX == 0) {
			yaw = 0;
			pitch = 0; }
	}
	else
	{
		yaw = atan(DX/DY);
		pitch = atan(floatsqroot(DX*DX + DZ*DZ) / DY);
		if(x1 > x2 && y1 <= y2) {
		    yaw = yaw + 90;
			pitch = pitch - 45; }
        else if(x1 <= x2 && y1 < y2) {
		    yaw = 90 - yaw;
			pitch = pitch - 45; }
        else if(x1 < x2 && y1 >= y2) {
		    yaw = yaw - 90;
			pitch = pitch - 45; }
        else if(x1 >= x2 && y1 > y2) {
		    yaw = 270 - yaw;
			pitch = pitch + 315; }
        if(z1 < z2)
		    pitch = 360-pitch;
	}
	SetObjectRot(objectid, 0, 0, yaw);
	SetObjectRot(objectid, 0, pitch, yaw+90);
}
Reply
#9

Quote:
Originally Posted by boelie
Посмотреть сообщение
how about this one;
found it in an old missile launcher script

Код:
stock SetObjectToFaceCords(objectid, Float:x1, Float:y1, Float:z1)
{

	new Float:x2,Float:y2,Float:z2;
	GetObjectPos(objectid, x2,y2,z2);

	new Float:DX = floatabs(x2-x1);
	new Float:DY = floatabs(y2-y1);
	new Float:DZ = floatabs(z2-z1);

    new Float:yaw = 0;
    new Float:pitch = 0;

	if(DY == 0 || DX == 0)
	{
	    if(DY == 0 && DX > 0) {
			yaw = 00;
			pitch = 0; }
		else if(DY == 0 && DX < 0) {
			yaw = 180;
			pitch = 180; }
		else if(DY > 0 && DX == 0)  {
			yaw = 90;
			pitch = 90; }
		else if(DY < 0 && DX == 0) {
			yaw = 270;
			pitch = 270; }
		else if(DY == 0 && DX == 0) {
			yaw = 0;
			pitch = 0; }
	}
	else
	{
		yaw = atan(DX/DY);
		pitch = atan(floatsqroot(DX*DX + DZ*DZ) / DY);
		if(x1 > x2 && y1 <= y2) {
		    yaw = yaw + 90;
			pitch = pitch - 45; }
        else if(x1 <= x2 && y1 < y2) {
		    yaw = 90 - yaw;
			pitch = pitch - 45; }
        else if(x1 < x2 && y1 >= y2) {
		    yaw = yaw - 90;
			pitch = pitch - 45; }
        else if(x1 >= x2 && y1 > y2) {
		    yaw = 270 - yaw;
			pitch = pitch + 315; }
        if(z1 < z2)
		    pitch = 360-pitch;
	}
	SetObjectRot(objectid, 0, 0, yaw);
	SetObjectRot(objectid, 0, pitch, yaw+90);
}
Thanks, that's awesome.

Quote:
Originally Posted by Steven82
Посмотреть сообщение
Jesus *facepalms* Try to ****** it, or just search around on the forums and wiki
I did ****** and search and I did found an old gps script with this arrow thing (see above) but I never tought about looking in a missile script.

Thanks anyway!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)