Jump to content
Autentificarea cu Google și Facebook nu mai este disponibilă. ×
  • 0

problema speedometer [odometer]


Question

Posted

salut guys

am intampinat si eu o problema cu speedometer-ul asta (e un sistem de vehicule persoanele de la 0). 

deci, sa va explic cum sta treaba

daca intru intr-un vehicul personal prima oara, merge functioneaza tot etc

insa daca intru in altul o ia razna

aveti aici un video mai detaliat

// functia pt + la odometer - fuel

ptask FuelOdometerPlayerTask[1000](playerid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(!isBike(vehicleid) && VehicleEngine[vehicleid] == true)
        {
            new Float:fuel = 0.050;
            if(GetVehicleSpeed(playerid) >= 5)
            {
                fuel = (GetVehicleSpeed(playerid) * 0.20) / 100;
            }

            VehicleFuel[vehicleid] -= fuel;
            if(vehicle_personal[vehicleid] > -1)
            {
                new id = vehicle_personal[vehicleid];
                CarInfo[id][cFuel] -= fuel;
                CarInfo[id][cOdometer] += fuel;
            }
        }
    }
}

//

speedometer:

stock UpdateVehicleTextdraws(playerid) {
    new vehicleid = GetPlayerVehicleID(playerid);
    format(stringx, sizeof(stringx), "~g~%d", GetVehicleSpeed(playerid));
    PlayerTextDrawSetString(playerid, VehicleInfoTD[playerid][0], stringx);
    PlayerTextDrawSetString(playerid, VehicleInfoTD[playerid][1], "KM/H");

    format(stringx, sizeof(stringx), "Fuel: ~r~%i", VehicleFuel[vehicleid]);
    PlayerTextDrawSetString(playerid, VehicleInfoTD[playerid][2], stringx);

    format(stringx, sizeof(stringx), "%s", (VehicleLock[vehicleid]) ? ("~R~LOCKED") : ("~g~UNLOCKED"));
    PlayerTextDrawSetString(playerid, VehicleInfoTD[playerid][3], stringx);
    if(vehicle_personal[vehicleid] > -1) 
    {
        format(stringx, sizeof(stringx), "~g~%d", GetVehicleSpeed(playerid));
        PlayerTextDrawSetString(playerid, VehicleInfoTD[playerid][0], stringx);
        PlayerTextDrawSetString(playerid, VehicleInfoTD[playerid][1], "KM/H");

        format(stringx, sizeof(stringx), "Fuel: ~r~%i~n~Odometer: %.2f~n~", VehicleFuel[vehicleid], CarInfo[vehicleid][cOdometer]);
        PlayerTextDrawSetString(playerid, VehicleInfoTD[playerid][2], stringx);

        format(stringx, sizeof(stringx), "%s", (CarInfo[vehicleid][cLock]) ? ("~R~LOCKED") : ("~g~UNLOCKED"));
        PlayerTextDrawSetString(playerid, VehicleInfoTD[playerid][3], stringx);
       }
}

3 answers to this question

Recommended Posts

  • 0
Posted
Acum 55 minute, hanako a spus:

salut guys

am intampinat si eu o problema cu speedometer-ul asta (e un sistem de vehicule persoanele de la 0). 

deci, sa va explic cum sta treaba

daca intru intr-un vehicul personal prima oara, merge functioneaza tot etc

insa daca intru in altul o ia razna

aveti aici un video mai detaliat

// functia pt + la odometer - fuel

ptask FuelOdometerPlayerTask[1000](playerid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(!isBike(vehicleid) && VehicleEngine[vehicleid] == true)
        {
            new Float:fuel = 0.050;
            if(GetVehicleSpeed(playerid) >= 5)
            {
                fuel = (GetVehicleSpeed(playerid) * 0.20) / 100;
            }

            VehicleFuel[vehicleid] -= fuel;
            if(vehicle_personal[vehicleid] > -1)
            {
                new id = vehicle_personal[vehicleid];
                CarInfo[id][cFuel] -= fuel;
                CarInfo[id][cOdometer] += fuel;
            }
        }
    }
}

//

speedometer:

stock UpdateVehicleTextdraws(playerid) {
    new vehicleid = GetPlayerVehicleID(playerid);
    format(stringx, sizeof(stringx), "~g~%d", GetVehicleSpeed(playerid));
    PlayerTextDrawSetString(playerid, VehicleInfoTD[playerid][0], stringx);
    PlayerTextDrawSetString(playerid, VehicleInfoTD[playerid][1], "KM/H");

    format(stringx, sizeof(stringx), "Fuel: ~r~%i", VehicleFuel[vehicleid]);
    PlayerTextDrawSetString(playerid, VehicleInfoTD[playerid][2], stringx);

    format(stringx, sizeof(stringx), "%s", (VehicleLock[vehicleid]) ? ("~R~LOCKED") : ("~g~UNLOCKED"));
    PlayerTextDrawSetString(playerid, VehicleInfoTD[playerid][3], stringx);
    if(vehicle_personal[vehicleid] > -1) 
    {
        format(stringx, sizeof(stringx), "~g~%d", GetVehicleSpeed(playerid));
        PlayerTextDrawSetString(playerid, VehicleInfoTD[playerid][0], stringx);
        PlayerTextDrawSetString(playerid, VehicleInfoTD[playerid][1], "KM/H");

        format(stringx, sizeof(stringx), "Fuel: ~r~%i~n~Odometer: %.2f~n~", VehicleFuel[vehicleid], CarInfo[vehicleid][cOdometer]);
        PlayerTextDrawSetString(playerid, VehicleInfoTD[playerid][2], stringx);

        format(stringx, sizeof(stringx), "%s", (CarInfo[vehicleid][cLock]) ? ("~R~LOCKED") : ("~g~UNLOCKED"));
        PlayerTextDrawSetString(playerid, VehicleInfoTD[playerid][3], stringx);
       }
}

Da mesaj in pv HPQ123(</>)#8114.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.