SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 21/09/2010, 07:37 PM   #1
Nameless303
Huge Clucker
 
Join Date: Jul 2009
Location: Belgium
Posts: 206
Reputation: 0
Default Pointer above the car

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 : http://forum.sa-mp.com/showthread.php?t=116622

Thanks

Last edited by Nameless303; 21/09/2010 at 08:00 PM.
Nameless303 is offline  
Old 21/09/2010, 08:54 PM   #2
Voldemort
Gangsta
 
Voldemort's Avatar
 
Join Date: Aug 2010
Posts: 592
Reputation: 26
Default Re: Pointer above the car

Its looks like CreatePlayerObject + Attachobjecttoplayer + angle calculation to checkpoint
__________________


Voldemort is offline  
Old 21/09/2010, 09:38 PM   #3
Nameless303
Huge Clucker
 
Join Date: Jul 2009
Location: Belgium
Posts: 206
Reputation: 0
Default Re: Pointer above the car

Quote:
Originally Posted by Voldemort View Post
Its looks like CreatePlayerObject + Attachobjecttoplayer + angle calculation to checkpoint
Tought about that aswel, any idea wht's the cakculation/formula?
Nameless303 is offline  
Old 21/09/2010, 09:45 PM   #4
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 3,326
Reputation: 341
Default AW: Re: Pointer above the car

Quote:
Originally Posted by Nameless303 View Post
Tought about that aswel, any idea wht's the cakculation/formula?
If you dont know the trigonometric functions than search for GetAngleBetweenPoints
__________________


Nero_3D is online now  
Old 22/09/2010, 12:34 PM   #5
Nameless303
Huge Clucker
 
Join Date: Jul 2009
Location: Belgium
Posts: 206
Reputation: 0
Default Re: AW: Re: Pointer above the car

Quote:
Originally Posted by Nero_3D View Post
If you dont know the trigonometric functions than search for GetAngleBetweenPoints
I don't even know what trigometric functions are, but I found this...
Code:
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?
Nameless303 is offline  
Old 22/09/2010, 09:18 PM   #6
Nameless303
Huge Clucker
 
Join Date: Jul 2009
Location: Belgium
Posts: 206
Reputation: 0
Default Re: Pointer above the car

Bump? ;s
Nameless303 is offline  
Old 22/09/2010, 10:03 PM   #7
Steven82
High-roller
 
Join Date: Nov 2009
Posts: 2,625
Reputation: 169
Default Re: Pointer above the car

Jesus *facepalms* Try to google it, or just search around on the forums and wiki
Steven82 is offline  
Old 23/09/2010, 06:59 AM   #8
boelie
Gangsta
 
boelie's Avatar
 
Join Date: Apr 2009
Location: San Fierro
Posts: 661
Reputation: 1
Default Re: Pointer above the car

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

Code:
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);
}
__________________
boelie is offline  
Old 24/09/2010, 10:34 PM   #9
Nameless303
Huge Clucker
 
Join Date: Jul 2009
Location: Belgium
Posts: 206
Reputation: 0
Default Re: Pointer above the car

Quote:
Originally Posted by boelie View Post
how about this one;
found it in an old missile launcher script

Code:
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 View Post
Jesus *facepalms* Try to google it, or just search around on the forums and wiki
I did google 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!
Nameless303 is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 01:04 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.