Turning XYZ to up, down, left/right (cruise control)
#1

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 ?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)