SA-MP Forums Archive
[HowTo] Making a working Cruise control - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HowTo] Making a working Cruise control (/showthread.php?tid=134170)



[HowTo] Making a working Cruise control - sean5874 - 15.03.2010

Hey,
I want to make an cruise control. If the player press "C' when driving, the speed of the vehicle was saved in a variable and his speed stays constant by using SetVehicleVelocity. Only if i drive into an car and i activate the cruise control, the car flys up into the air and catch fire. I want a constant speed, not a flying car :S. Anyone know how to repair this?
Greetz
sean5874


Re: [HowTo] Making a working Cruise control - iLinx - 15.03.2010

What values are you saving when the user activates cruise control?
I would imagine you would only need to set the x and y velocity, and leave the z velocity alone (the z velocity controls the vertical velocity of the car)


Re: [HowTo] Making a working Cruise control - sean5874 - 15.03.2010

I remade an piece by using your advice, if im in a car, and that car dont move, everything is fine. The car dont go in cruise control, cuz the speed is 0. But when i go for a trip, and i do /cc (my cruise control command) the whole server crashes! Below you see my piece of script:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/cc", cmdtext, true, 10) == 0)
	{
		new Float:vX, vY, vZ;
		GetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
             SetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, 0.0); // im not using vZ
		SendClientMessage(playerid, COLOR_RED,"CRUISE CONTROL: Cc is on, use key S to turn it off.");
		return 1;
	}
	return 0;
}
Someone know whats wrong?


Re: [HowTo] Making a working Cruise control - Torran - 15.03.2010

Quote:
Originally Posted by sean5874
Hey,
I want to make an cruise control. If the player press "C' when driving, the speed of the vehicle was saved in a variable and his speed stays constant by using SetVehicleVelocity. Only if i drive into an car and i activate the cruise control, the car flys up into the air and catch fire. I want a constant speed, not a flying car :S. Anyone know how to repair this?
Greetz
sean5874
Theres already a filterscript that does this


Re: [HowTo] Making a working Cruise control - mick88 - 16.03.2010

Quote:
Originally Posted by sean5874
I remade an piece by using your advice, if im in a car, and that car dont move, everything is fine. The car dont go in cruise control, cuz the speed is 0. But when i go for a trip, and i do /cc (my cruise control command) the whole server crashes! Below you see my piece of script:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/cc", cmdtext, true, 10) == 0)
	{
		new Float:vX, vY, vZ;
		GetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
             SetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, 0.0); // im not using vZ
		SendClientMessage(playerid, COLOR_RED,"CRUISE CONTROL: Cc is on, use key S to turn it off.");
		return 1;
	}
	return 0;
}
Someone know whats wrong?
You need to reapply the velocity in timer. Also leave the vZ as it is, don't zero it, otherwise car won't go downhill but stay in the air. And you won't be able to make turns with your car. Check the FS in my sig for ready Cruise Control solution.


Re: [HowTo] Making a working Cruise control - Deat_Itself - 16.03.2010

btw
Код:
		new Float:vX, vY, vZ;
should be
Код:
		new Float:vX, Float:vY, Float:vZ;