Jump to content
  • 0

problema speedometer [odometer]


hanako

Question

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);
       }
}

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0
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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.