SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 14/02/2020, 03:13 PM   #1
Eyex
Little Clucker
 
Join Date: May 2019
Posts: 16
Reputation: 0
Default 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] );
Eyex is offline   Reply With Quote
Old 14/02/2020, 03:25 PM   #2
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,065
Reputation: 106
Default 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;
    } 
__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!


Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Discord - Website
jasperschellekens is offline   Reply With Quote
Old 14/02/2020, 03:30 PM   #3
Eyex
Little Clucker
 
Join Date: May 2019
Posts: 16
Reputation: 0
Default Re: Speedometer meter distance Help

This idozito timer.

SetTimer("KMIdozito", 1250, true);
Eyex is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me Puttings Speedometer and gas meter on my gamemod Patrick Scripting Help 1 15/09/2012 05:58 AM
Meter Sony14 Scripting Help 2 24/07/2012 05:28 PM
meter speedometer CraftMan Scripting Help 6 01/10/2011 07:07 PM
[BUG] The Speed-o-Meter and Fuel-o-Meter is not appearing! [UNSOLVED!!!] Rand_Omar Help Archive 12 28/01/2011 02:17 PM
Pay meter Erkan Help Archive 1 17/07/2009 06:57 PM


All times are GMT. The time now is 04:25 AM.


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