Turning XYZ to up, down, left/right (cruise control) -
gamer931215 - 30.10.2010
Hi guys, im creating a cruise control, but my current system doesnt turn with the vehicle.
So it just keeps continuing the point where you started using the cruise control.
Script:
pawn Код:
#include <a_samp>
enum gCruiseControl
{
Float:x,
Float:y,
enabled
}
new CruiseControl[MAX_PLAYERS][gCruiseControl];
public OnFilterScriptInit()
{
SetTimer("update",250,true);
return 1;
}
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
if(PRESSED(KEY_FIRE))
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(CruiseControl[playerid][enabled] == 0) {
new Float:temp;
GetVehicleVelocity(GetPlayerVehicleID(playerid),CruiseControl[playerid][x],CruiseControl[playerid][y],temp);
CruiseControl[playerid][enabled] = 1;
SendClientMessage(playerid,0x00AA00FF,"Cruise control enabled");
} else {
CruiseControl[playerid][enabled] = 0;
SendClientMessage(playerid,0x00AA00FF,"Cruise control disabled");
}
}
}
return 0;
}
forward update();
public update()
{
for(new i =0;i<MAX_PLAYERS; i++)
{
new veh = GetPlayerVehicleID(i);
//updating cruise control
if(CruiseControl[i][enabled] == 1)
{
new Float:temp,Float:cz;
GetVehicleVelocity(veh,temp,temp,cz);
SetVehicleVelocity(veh,CruiseControl[i][x],CruiseControl[i][y],cz);
}
}
return 1;
}
Any ideas how to solve this ?
Re: Turning XYZ to up, down, left/right (cruise control) -
willsuckformoney - 30.10.2010
How about adding when they press a key? All you have is fire to active/deactivate the cruise control.
Re: Turning XYZ to up, down, left/right (cruise control) -
gamer931215 - 30.10.2010
Quote:
Originally Posted by willsuckformoney
How about adding when they press a key? All you have is fire to active/deactivate the cruise control.
|
Yea sorry, i just ripped parts out of the gamemode where im scripting it in.
Everything works only when i want to make a turn, The car just keeps continuing in the same direction.
Re: Turning XYZ to up, down, left/right (cruise control) -
willsuckformoney - 31.10.2010
Quote:
Originally Posted by SA:MP Wiki
Up/Down-Keys
KEY_UP
KEY_DOWN
Left/Right-Keys
KEY_LEFT
KEY_RIGHT
|
That should help you a little, when they press a key, SetVehicleFacingAngel or something to +10 or something.
Re: Turning XYZ to up, down, left/right (cruise control) -
gamer931215 - 31.10.2010
Quote:
Originally Posted by willsuckformoney
That should help you a little, when they press a key, SetVehicleFacingAngel or something to +10 or something.
|
I didnt let it change the Z angle if you look good at the code. So i am free to rotate already! only when the car's rotation turns left it just keep "drifting" straight forward.
In gta you have angles, X (north/south), Y (east/west) and Z (height)
The car just keeps driving towards the coordinates where it was saved by enabling the cruise control.
I need to let it re-calculate that if you turn, so you just keep your speed and are free to move.
Re: Turning XYZ to up, down, left/right (cruise control) -
willsuckformoney - 31.10.2010
From mick88
http://pastebin.com/fYBZZGWe
Re: Turning XYZ to up, down, left/right (cruise control) -
gamer931215 - 31.10.2010
Quote:
Originally Posted by willsuckformoney
|
Thank you very much!
Ive searched before and i DID found his post, but that specefic post didnt include a downloadlink/pastebinlink ?
Anyways i used some of his functions (with credits in a comment added) and got it working now