Speedo Error
#1

Everytime i entered a vehicle and typed "ENGINE" it took about 30 seconds before its starts because of the code how to fix the delay?

Код:
forward velocimetro();
public velocimetro()
{
    new string[500];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInAnyVehicle(i))
            {
				format(string,sizeof(string),"%d",GetPlayerSpeed(i));
				PlayerTextDrawSetString(i,velo[i][1],string);
				new Float:health;
				GetVehicleHealth(GetPlayerVehicleID(i),health);
				if(health == 1000) for(new a=26; a<36; a++) PlayerTextDrawColor(i,velo[i][a], 12582911);
				else if(health >= 900 && health < 1000) for(new a=26; a<36; a++) PlayerTextDrawColor(i,velo[i][a], 12582911),PlayerTextDrawColor(i,velo[i][35], 0x00000044);
				else if(health >= 800 && health < 900)
				{
					for(new a=26; a<36; a++)
					{
						PlayerTextDrawColor(i,velo[i][a], 12582911);
						PlayerTextDrawColor(i,velo[i][35], 0x00000044);
						PlayerTextDrawColor(i,velo[i][34], 0x00000044);
					}
				}
				else if(health >= 700 && health < 800)
				{
					for(new a=26; a<36; a++)
					{
						PlayerTextDrawColor(i,velo[i][a], 12582911);
						PlayerTextDrawColor(i,velo[i][35], 0x00000044);
						PlayerTextDrawColor(i,velo[i][34], 0x00000044);
						PlayerTextDrawColor(i,velo[i][33], 0x00000044);
					}
				}
				else if(health >= 600 && health < 700)
				{
					for(new a=26; a<36; a++)
					{
						PlayerTextDrawColor(i,velo[i][a], 12582911);
						PlayerTextDrawColor(i,velo[i][35], 0x00000044);
						PlayerTextDrawColor(i,velo[i][34], 0x00000044);
						PlayerTextDrawColor(i,velo[i][33], 0x00000044);
						PlayerTextDrawColor(i,velo[i][32], 0x00000044);
					}
				}
				else if(health >= 500 && health < 600)
				{
					for(new a=26; a<36; a++)
					{
						PlayerTextDrawColor(i,velo[i][a], 12582911);
						PlayerTextDrawColor(i,velo[i][35], 0x00000044);
						PlayerTextDrawColor(i,velo[i][34], 0x00000044);
						PlayerTextDrawColor(i,velo[i][33], 0x00000044);
						PlayerTextDrawColor(i,velo[i][32], 0x00000044);
						PlayerTextDrawColor(i,velo[i][31], 0x00000044);
					}
				}
                else if(health >= 400 && health < 500)
				{
					for(new a=26; a<36; a++)
					{
						PlayerTextDrawColor(i,velo[i][a], 12582911);
						PlayerTextDrawColor(i,velo[i][35], 0x00000044);
						PlayerTextDrawColor(i,velo[i][34], 0x00000044);
						PlayerTextDrawColor(i,velo[i][33], 0x00000044);
						PlayerTextDrawColor(i,velo[i][32], 0x00000044);
						PlayerTextDrawColor(i,velo[i][31], 0x00000044);
						PlayerTextDrawColor(i,velo[i][30], 0x00000044);
					}
				}
                else if(health >= 300 && health < 400)
				{
					for(new a=26; a<36; a++)
					{
						PlayerTextDrawColor(i,velo[i][a], 12582911);
						PlayerTextDrawColor(i,velo[i][35], 0x00000044);
						PlayerTextDrawColor(i,velo[i][34], 0x00000044);
						PlayerTextDrawColor(i,velo[i][33], 0x00000044);
						PlayerTextDrawColor(i,velo[i][32], 0x00000044);
						PlayerTextDrawColor(i,velo[i][31], 0x00000044);
						PlayerTextDrawColor(i,velo[i][30], 0x00000044);
						PlayerTextDrawColor(i,velo[i][29], 0x00000044);
					}
				}
				else if(health >= 200 && health < 300)
				{
					for(new a=26; a<36; a++)
					{
						PlayerTextDrawColor(i,velo[i][a], 12582911);
						PlayerTextDrawColor(i,velo[i][35], 0x00000044);
						PlayerTextDrawColor(i,velo[i][34], 0x00000044);
						PlayerTextDrawColor(i,velo[i][33], 0x00000044);
						PlayerTextDrawColor(i,velo[i][32], 0x00000044);
						PlayerTextDrawColor(i,velo[i][31], 0x00000044);
						PlayerTextDrawColor(i,velo[i][30], 0x00000044);
						PlayerTextDrawColor(i,velo[i][29], 0x00000044);
						PlayerTextDrawColor(i,velo[i][28], 0x00000044);
					}
				}
				else if(health >= 100 && health < 200)
				{
					for(new a=26; a<36; a++)
					{
						PlayerTextDrawColor(i,velo[i][a], 12582911);
						PlayerTextDrawColor(i,velo[i][35], -1);
						PlayerTextDrawColor(i,velo[i][34], -1);
						PlayerTextDrawColor(i,velo[i][33], -1);
						PlayerTextDrawColor(i,velo[i][32], -1);
						PlayerTextDrawColor(i,velo[i][31], -1);
						PlayerTextDrawColor(i,velo[i][30], -1);
						PlayerTextDrawColor(i,velo[i][29], -1);
						PlayerTextDrawColor(i,velo[i][28], -1);
						PlayerTextDrawColor(i,velo[i][27], -1);
					}
				}
				else if(health >= 0 && health < 100)
				{
					for(new a=26; a<36; a++)
					{
						PlayerTextDrawColor(i,velo[i][a], 12582911);
						PlayerTextDrawColor(i,velo[i][35], 0x00000044);
						PlayerTextDrawColor(i,velo[i][34], 0x00000044);
						PlayerTextDrawColor(i,velo[i][33], 0x00000044);
						PlayerTextDrawColor(i,velo[i][32], 0x00000044);
						PlayerTextDrawColor(i,velo[i][31], 0x00000044);
						PlayerTextDrawColor(i,velo[i][30], 0x00000044);
						PlayerTextDrawColor(i,velo[i][29], 0x00000044);
						PlayerTextDrawColor(i,velo[i][28], 0x00000044);
						PlayerTextDrawColor(i,velo[i][27], 0x00000044);
						PlayerTextDrawColor(i,velo[i][26], 0x00000044);
					}
				}

				switch(GetPlayerSpeed(i))
				{
				    case 0: {
  						for(new a=2; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 1..9: {
                        PlayerTextDrawColor(i,velo[i][2], 12582911);
                        PlayerTextDrawShow(i,velo[i][2]);
                        for(new a=3; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 10..19: {
				        for(new a=2; a<3; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=4; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 20..29: {
				        for(new a=2; a<4; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=5; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 30..39: {
				        for(new a=2; a<5; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=6; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 40..49: {
				        for(new a=2; a<6; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=7; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 50..59: {
				        for(new a=2; a<7; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=8; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 60..69: {
				        for(new a=2; a<8; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=9; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 70..79: {
				        for(new a=2; a<9; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=10; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 80..89: {
				        for(new a=2; a<10; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=11; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 90..99: {
				        for(new a=2; a<11; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=12; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 100..109: {
				        for(new a=2; a<12; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=13; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 110..119: {
				        for(new a=2; a<13; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=14; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 120..129: {
				        for(new a=2; a<14; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=15; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 130..139: {
				        for(new a=2; a<15; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=16; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 140..149: {
				        for(new a=2; a<16; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=17; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 150..159: {
				        for(new a=2; a<17; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=18; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 160..169: {
				        for(new a=2; a<18; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=19; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 170..179: {
				        for(new a=2; a<19; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=20; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 180..189: {
				        for(new a=2; a<20; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=21; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 190..199: {
				        for(new a=2; a<25; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=22; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 200..209: {
				        for(new a=2; a<22; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=23; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 210..219: {
				        for(new a=2; a<23; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
						for(new a=24; a<25; a++){
                       		PlayerTextDrawColor(i,velo[i][a], 0x00000044);
						}
				    }
				    case 220..229: {
				        for(new a=2; a<24; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
					   	PlayerTextDrawColor(i,velo[i][25], 0x00000044);
				    }
				    case 230..245:{
				    	for(new a=2; a<25; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
				    }
				    case 246..300:{
				    	for(new a=2; a<25; a++){
                            PlayerTextDrawColor(i,velo[i][a], 12582911);
						}
				    }
				}
				for(new a; a<37; a++) PlayerTextDrawShow(i,velo[i][a]);
			}
			else
			{
				for(new a; a<37; a++) PlayerTextDrawHide(i,velo[i][a]);
			    PlayerTextDrawSetString(i,velo[i][1],"0");
			}
        }
    }
	return 1;
}
stock GetPlayerSpeed(playerid)
{
    new Float:ST[4];
    if(IsPlayerInAnyVehicle(playerid))
    GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
    else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
    ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 101.0*1.609344;
    return floatround(ST[3]);
Reply
#2

BUMP!!!!!
Reply
#3

show us the
PHP код:
SetTimer(.... 
Reply
#4

dude, show us a command code.
Reply
#5

It's speedo meter no command for it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)