SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 14/06/2012, 11:28 AM   #1
iWhite
Big Clucker
 
Join Date: May 2012
Posts: 176
Reputation: 18
Default PullVehicleIntoDirection pulls my car....

Function:
Code:
stock PullVehicleIntoDirection(vehicleid, Float:x, Float:y, Float:z, Float:speed)
{
new
Float:distance,
Float:vehicle_pos[3];

GetVehiclePos(vehicleid, vehicle_pos[0], vehicle_pos[1], vehicle_pos[2]);
SetVehicleZAngle(vehicleid, atan2VehicleZ(vehicle_pos[0], vehicle_pos[1], x, y));
x -= vehicle_pos[0];
y -= vehicle_pos[1];
//z -= vehicle_pos[2];
distance = floatsqroot((x * x) + (y * y)/* + (z * z)*/);
x = (speed * x) / distance;
y = (speed * y) / distance;
//z = (speed * z) / distance;
GetVehicleVelocity(vehicleid, z, z, z);
SetVehicleVelocity(vehicleid, x, y, z);
}
forward Float:atan2VehicleZ(Float:Xb,Float:Yb,Float:Xe,Float:Ye);// Dunno how to name it...
stock Float:atan2VehicleZ(Float:Xb,Float:Yb,Float:Xe,Float:Ye)
{
        new Float:a = floatabs(360.0 - atan2( Xe-Xb,Ye-Yb));
        if(360 > a > 180)return a;
        return a-360.0;
}
Command to create the car:

Code:
    if(!strcmp(cmdtext, "/car1", true))
    {
	   GetPlayerPos(playerid, xs, ys, zs);
	   car1 = AddStaticVehicleEx(411, xs, ys, zs, 0, 1, 1, 15000);
	   return 1;
	}
And Command to drive to my position:

Code:
    if(!strcmp(cmdtext, "/go", true))
    {
	   SetTimerEx("Drive", 1000, true, "i", playerid);
       return 1;
	}
In "Drive" public:

   GetVehiclePos(GetPlayerVehicleID(playerid), xs, ys, zs);
   PullVehicleIntoDirection(car1, xs, ys, zs, 1);
   PullVehicleIntoDirection(car2, xs, ys, zs, 1);
Pulls my vehicle, but "car1" not moving....

Any ideas?
iWhite is offline   Reply With Quote
Old 14/06/2012, 11:59 AM   #2
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,086
Reputation: 2655
Default Re: PullVehicleIntoDirection pulls my car....

As far as I know the car must be occupied for SetVehicleVelocity to work.
__________________
Vince is offline   Reply With Quote
Old 14/06/2012, 12:04 PM   #3
Faisal_khan
High-roller
 
Faisal_khan's Avatar
 
Join Date: Feb 2012
Location: Nagpur, India
Posts: 1,826
Reputation: 208
Default Re: PullVehicleIntoDirection pulls my car....

Why don't just make a bot and let him be seated in your car for only the process of moving.
__________________
Not a SAMP Dev. anymore.
Hire me for teaching any programming langauge.
Interested? Hit me up on Skype: pfk3325
Faisal_khan is offline   Reply With Quote
Old 14/06/2012, 12:08 PM   #4
darkowner
Big Clucker
 
Join Date: Jun 2011
Posts: 168
Reputation: 5
Default Re: PullVehicleIntoDirection pulls my car....

Quote:
Originally Posted by Vince View Post
As far as I know the car must be occupied for SetVehicleVelocity to work.
Agreed
darkowner is offline   Reply With Quote
Reply

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Floats on a textdraw statbar, Pulls other players stats? -Rebel Son- Help Archive 15 04/06/2010 12:08 AM


All times are GMT. The time now is 10:22 PM.


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