Guten arbend, ich habe problem mit mein Tempomat. Und zwar fahre ich gewissen kmh und drück die Taste "H" und dann schaltet sich der Tempomat ein. Mein Problem ist sobald ich sie loslasse deaktiviert sich der Tempomat was eiglich nicht passiren darf.
Code:
if ((newkeys & CCKey) && !(oldkeys & CCKey) && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vid = GetPlayerVehicleID(playerid);
if (GetVehicleSpeed(vid) == 0) return false;
new Float:x, Float:y, Float:z;
GetVehicleVelocity(vid, x, y, z);
GetVehicleZAngle(vid, PlayerHeadingAngle[playerid]);
DistanceFlat(0, 0, x, y, PlayerCruiseSpeed[playerid]);
SetTimerEx("CruiseControl", 500, false, "d", playerid);
SendClientMessage(playerid, COLOR_GREY, "* Tempomat Eingeschaltet");
}
else if (PlayerCruiseSpeed[playerid] != 0.00 && (newkeys & KEY_HANDBRAKE))
{
PlayerCruiseSpeed[playerid] = 0.00;
}
public CruiseControl(playerid)
{
new vid = GetPlayerVehicleID(playerid);
new Float:x, Float:y, Float:z;
GetVehicleVelocity(vid, x, y, z);
new keys, ud, lr;
GetPlayerKeys(playerid, keys, ud, lr);
new Float:angle, Float:heading, Float:speed;
GetVehicleZAngle(vid, angle);
GetVehicleHeadingAngle(vid, heading);
DistanceFlat(0, 0, x, y, speed);
if (!(keys & CCKey) || PlayerCruiseSpeed[playerid] == 0.00 ||
GetPlayerState(playerid) != PLAYER_STATE_DRIVER ||
(speed < 0.7 * PlayerCruiseSpeed[playerid]) ||
z > 1 || //if car is going upwards too fast
(floatabs(angle - heading) > 50 && floatabs(angle - heading) < 310))
{
PlayerCruiseSpeed[playerid] = 0.00;
SendClientMessage(playerid, COLOR_GREY, "*Tempomat Ausgeschaltet");
return false;
}
GetVehicleZAngle(vid, PlayerHeadingAngle[playerid]);
GetXYVelocity(vid, x, y, PlayerCruiseSpeed[playerid]);
SetVehicleVelocity(vid, x, y, z);
return SetTimerEx("CruiseControl", 500, false, "d", playerid);
}