SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   Speedometer meter distance Help (https://forum.sa-mp.com/showthread.php?t=672467)

Eyex 14/02/2020 03:13 PM

Speedometer meter distance Help
 
Hy Guys. My speedometer and fuel gauge are fine. But on the other hand the distance meter does not work does not count. Can someone help me?

Code:

v Enum
{
  Float: FUTOTTKM,

Code:

public KMIdozito()
{

        for(new i; i < MAX_PLAYERS; i ++)
        {
                if(IsPlayerConnected(i))
                {
                    new VehID = GetPlayerVehicleID( i );
                    if(VehID >= 200)
                    {
                                if(IsPlayerInAnyVehicle(i) && !GetPlayerVehicleSeat(i))
                                {
                                    new Float:kmszamit;
                                    kmszamit = GetVehicleSpeed(VehID)*0.001;
                                        vInfo[VehID][FUTOTTKM] += kmszamit;

                                        vInfo[VehID][olajcserekm] += kmszamit;

                                        SaveVehicle(VehID);
                                }
                        }
                }
        }
}

Code:

Uzemanyagtext[playerid] = CreatePlayerTextDraw(playerid, 526.000000, 369.000000, "Sebesség: %dkm/h\nÜzemanyag: %d l\nFutottKM: %.3f");
        PlayerTextDrawBackgroundColor(playerid, Uzemanyagtext[playerid], 255);
        PlayerTextDrawFont(playerid, Uzemanyagtext[playerid], 1);
        PlayerTextDrawLetterSize(playerid, Uzemanyagtext[playerid], 0.230000, 1.100000);
        PlayerTextDrawColor(playerid, Uzemanyagtext[playerid], -1);//-16776961
        PlayerTextDrawSetOutline(playerid, Uzemanyagtext[playerid], 1);
        PlayerTextDrawSetProportional(playerid, Uzemanyagtext[playerid], 1);
        PlayerTextDrawUseBox(playerid, Uzemanyagtext[playerid], 1);
        PlayerTextDrawBoxColor(playerid, Uzemanyagtext[playerid], 102);
        PlayerTextDrawTextSize(playerid, Uzemanyagtext[playerid], 611.000000, -10.000000);

/////////////////////////////////////////////////

Code:

public KocsiText()
{
        new Float: elet, vehicleid, uzemanyag[50];
        new S[256];

        for(new player; player < MAX_PLAYERS; player++)
        {
            if( IsPlayerConnected(player))
            {
                        if(IsPlayerInAnyVehicle(player))
                        {
                                vehicleid = GetPlayerVehicleID(player);
                                GetVehicleHealth(vehicleid, elet);

                              GetVehicleHealth(vehicleid, elet);
                            if(elet < 300) return KocsiOff(vehicleid);

                                switch(vInfo[vehicleid][UZEMANYAGTIPUS])
                                {
                                        case BENZIN: { uzemanyag = "Benzin"; }
                                        case DIESEL: { uzemanyag = "Diesel"; }
                                }
                                if(vInfo[vehicleid][UZEMANYAGTIPUS] > 0)
                                {
                        format(S, sizeof(S), "%s: ~y~%dkm/h~w~~n~%s: ~y~%d l~w~~n~%s: ~y~%.3f~w~", FixGameString("Sebesség"), GetVehicleSpeed(vehicleid), uzemanyag, vInfo[vehicleid][UZEMANYAG], FixGameString("FutottKM"), vInfo[vehicleid][FUTOTTKM]);
                                        if(vInfo[vehicleid][UZEMANYAGTIPUS] != vInfo[vehicleid][UZEMANYAGTIPUSVAN]) format(S, sizeof(S), "%s: ~r~%dkm/h~w~~n~N/A: ~g~%d l~w~~n~%s: ~y~%.3f~w~", FixGameString("Sebesség"), GetVehicleSpeed(vehicleid), vInfo[vehicleid][UZEMANYAG], FixGameString("FutottKM"), vInfo[vehicleid][FUTOTTKM]);
                                  }
                                else
                                {
                                        format(S, sizeof(S), "%s ~y~%dkm/h~w~", FixGameString("Sebesség:"), GetVehicleSpeed(vehicleid) );
                                }

                                PlayerTextDrawSetString(player, Uzemanyagtext[player], S);
                        }
                }
        }

        return 1;
}

//////////////////

Code:

stock SaveVehicle( vehicleid )
{
                if(vehicleid > 210 )
                {
                    if(!dini_Exists(vehicleFile(vehicleid)))
                    {
                        dini_Remove(vehicleFile(vehicleid));
                        dini_Create( vehicleFile(vehicleid) );
                    }
                    else
                    {
                        dini_Create( vehicleFile(vehicleid) );
                    }

                }

                dini_IntSet( vehicleFile(vehicleid), "MODEL", vInfo[vehicleid][MODEL] );
            dini_FloatSet( vehicleFile(vehicleid), "X", vInfo[vehicleid][X] );
            dini_FloatSet( vehicleFile(vehicleid), "Y", vInfo[vehicleid][Y] );
            dini_FloatSet( vehicleFile(vehicleid), "Z", vInfo[vehicleid][Z] );
            dini_FloatSet( vehicleFile(vehicleid), "A", vInfo[vehicleid][A] );
            dini_Set( vehicleFile(vehicleid), "OWNER", vInfo[vehicleid][OWNER] );
            dini_Set( vehicleFile(vehicleid), "COOWNER", vInfo[vehicleid][COOWNER] );
            dini_IntSet( vehicleFile(vehicleid), "COLOR", vInfo[vehicleid][COLOR] );
            dini_IntSet( vehicleFile(vehicleid), "COLOR2", vInfo[vehicleid][COLOR2] );
            dini_IntSet( vehicleFile(vehicleid), "SOLD", vInfo[vehicleid][SOLD] );
            dini_IntSet( vehicleFile(vehicleid), "INT", vInfo[vehicleid][INT] );
            dini_IntSet( vehicleFile(vehicleid), "VW", vInfo[vehicleid][VW] );
            dini_Set( vehicleFile(vehicleid), "PLATE", vInfo[vehicleid][PLATE] );
            dini_IntSet( vehicleFile(vehicleid), "PRICE", vInfo[vehicleid][PRICE] );
            dini_IntSet( vehicleFile(vehicleid), "LOCKED", vInfo[vehicleid][LOCKED] );
            dini_IntSet(vehicleFile(vehicleid), "ÜzemanyagTipus", vInfo[vehicleid][UZEMANYAGTIPUS]);
                dini_IntSet(vehicleFile(vehicleid), "MilyenVanBenne", vInfo[vehicleid][UZEMANYAGTIPUSVAN]);
                dini_IntSet(vehicleFile(vehicleid), "MaxÜzemAnyag", vInfo[vehicleid][MAXUZEMANYAG]);
                dini_IntSet(vehicleFile(vehicleid), "ÜzemAnyag", vInfo[vehicleid][UZEMANYAG]);
                dini_IntSet(vehicleFile(vehicleid), "KerékBilincs", vInfo[vehicleid][KEREKBILINCS]);
                dini_IntSet(vehicleFile(vehicleid), "Lefoglalva", vInfo[vehicleid][LEFOGLALVA]);
                dini_IntSet(vehicleFile(vehicleid), "SPOILER", vInfo[vehicleid][SPOILER]);
                dini_FloatSet( vehicleFile(vehicleid), "FUTOTTKM", vInfo[vehicleid][FUTOTTKM] );
                dini_FloatSet( vehicleFile(vehicleid), "OLAJCSEREKM", vInfo[vehicleid][olajcserekm] );


jasperschellekens 14/02/2020 03:25 PM

Re: Speedometer meter distance Help
 
I use a timer and something like this for mileage:
PHP Code:

    new vehicleid GetPlayerVehicleID(playerid), Float:speed_xFloat:speed_yFloat:speed_zFloat:final_speedvalue;
        
GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
        
final_speed floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*85.4166672;
        
value floatround(final_speed,floatround_round);

        if(
TD_L_Value[playerid] == value
            return 
1;

    new 
plusma=value/=8;
    
MileAgeIM[vehicleid]+=plusma;

    if(
MileAgeIM[vehicleid]>=1600// Every 1600 meters mileage goes up by 1
    
{
        
MileAgeI[vehicleid]+=1;
        
MileAgeIM[vehicleid]=0;
    } 


Eyex 14/02/2020 03:30 PM

Re: Speedometer meter distance Help
 
This idozito timer.

SetTimer("KMIdozito", 1250, true);


All times are GMT. The time now is 06:45 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.