SA-MP Forums Archive
Speedometer problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Speedometer problem (/showthread.php?tid=644103)



Speedometer problem - Leonaardo - 04.11.2017

Does anyone know where I went wrong in this code so the vehicle's statistics appear up to whoever is in the passenger seat or ride?
Well, until you're not driving, the speedometer and ...
How can I solve this?

pawn Код:
public Velocimetro()
{
foreach(Player, i)
{
new aname[MAX_PLAYER_NAME];
GetPlayerName(i, aname, MAX_PLAYER_NAME);
if(IsPlayerInAnyVehicle(i)) {
new Float:X, Float:Y, Float:Z, Float:Speed;
GetVehicleVelocity(GetPlayerVehicleID(i), X, Y, Z);
Speed = floatmul(floatsqroot(floatadd(floatadd(floatpower(X, 2), floatpower(Y, 2)),  floatpower(Z, 2))), 170.0);
new Float:vcarro;
GetVehicleHealth(GetPlayerVehicleID(i), vcarro);
new velocid;
velocid = floatround(Speed, floatround_floor);
new string[128];
new PlayerVehicleModelID = GetVehicleModel(GetPlayerVehicleID(i));
PlayerVehicleModelID -= 400;
new ncarro[30];


if(velocid == 300){
SetTimerEx("remove it", 1000, false, "i", i);
}
if(velocid == 350){
SetTimerEx("remove it", 1000, false, "i", i);
}
if(velocid == 380){
SetTimerEx("remove it", 1000, false, "i", i);
}
if(velocid > 385){
SetTimerEx("banspeed", 100, false, "i", i);
}

format(ncarro,30,PlayerVehicle[PlayerVehicleModelID]);
GetPlayer2DZone(i, zone, MAX_ZONE_NAME);
format(string, 128,"%i",velocid); //~y~Km/h
TextDrawSetString(velo[i],string);
// PLAYER VEHICLE
format(ncarro,30,PlayerVehicle[PlayerVehicleModelID]);
GetPlayer2DZone(i, zone, MAX_ZONE_NAME);
format(string,sizeof(string),"~b~%s",PlayerVehicle[PlayerVehicleModelID]);
TextDrawSetString(Veiculo[i], string);
// PLAYER VEHICLE
// LOCATION SPEEDOMETER
format(ncarro,30,PlayerVehicle[PlayerVehicleModelID]);
GetPlayer2DZone(i, zone, MAX_ZONE_NAME);
format(string,sizeof(string),"~w~%s", zone);
TextDrawSetString(Localidades[i], string);
// KM / H
format(ncarro,30,PlayerVehicle[PlayerVehicleModelID]);
GetPlayer2DZone(i, zone, MAX_ZONE_NAME);
format(string,sizeof(string),"~y~KM/H"); //~y~~i~/~y~
TextDrawSetString(Kmh, string);
Radar(i);
TextDrawShowForPlayer(i, velo[i]);
TextDrawShowForPlayer(i, Veiculo[i]);
TextDrawShowForPlayer(i, Localidades[i]);
TextDrawShowForPlayer(i, Kmh);
}else{
TextDrawHideForPlayer(i, velo[i]),TextDrawHideForPlayer(i, Veiculo[i]),TextDrawHideForPlayer(i, Kmh),TextDrawHideForPlayer(i, Localidades[i]);
}
}
return 1;
}



Re: Speedometer problem - StrikerZ - 04.11.2017

PHP код:
public Velocimetro()
{
    foreach(
Playeri)
    {
        new 
aname[MAX_PLAYER_NAME];
        
GetPlayerName(ianameMAX_PLAYER_NAME);
        if(
IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
        {
            new 
Float:XFloat:YFloat:ZFloat:Speed;
            
GetVehicleVelocity(GetPlayerVehicleID(i), XYZ);
            
Speed floatmul(floatsqroot(floatadd(floatadd(floatpower(X2), floatpower(Y2)),  floatpower(Z2))), 170.0);
            new 
Float:vcarro;
            
GetVehicleHealth(GetPlayerVehicleID(i), vcarro);
            new 
velocid;
            
velocid floatround(Speedfloatround_floor);
            new 
string[128];
            new 
PlayerVehicleModelID GetVehicleModel(GetPlayerVehicleID(i));
            
PlayerVehicleModelID -= 400;
            new 
ncarro[30];


            if(
velocid == 300)
            {
                
SetTimerEx("remove it"1000false"i"i);
            }
            if(
velocid == 350)
            {
                
SetTimerEx("remove it"1000false"i"i);
            }
            if(
velocid == 380)
            {
                
SetTimerEx("remove it"1000false"i"i);
            }
            if(
velocid 385)
            {
                
SetTimerEx("banspeed"100false"i"i);
            }

            
format(ncarro,30,PlayerVehicle[PlayerVehicleModelID]);
            
GetPlayer2DZone(izoneMAX_ZONE_NAME);
            
format(string128,"%i",velocid); //~y~Km/h
            
TextDrawSetString(velo[i],string);
            
// PLAYER VEHICLE
            
format(ncarro,30,PlayerVehicle[PlayerVehicleModelID]);
            
GetPlayer2DZone(izoneMAX_ZONE_NAME);
            
format(string,sizeof(string),"~b~%s",PlayerVehicle[PlayerVehicleModelID]);
            
TextDrawSetString(Veiculo[i], string);
            
// PLAYER VEHICLE
            // LOCATION SPEEDOMETER
            
format(ncarro,30,PlayerVehicle[PlayerVehicleModelID]);
            
GetPlayer2DZone(izoneMAX_ZONE_NAME);
            
format(string,sizeof(string),"~w~%s"zone);
            
TextDrawSetString(Localidades[i], string);
            
// KM / H
            
format(ncarro,30,PlayerVehicle[PlayerVehicleModelID]);
            
GetPlayer2DZone(izoneMAX_ZONE_NAME);
            
format(string,sizeof(string),"~y~KM/H"); //~y~~i~/~y~
            
TextDrawSetString(Kmhstring);
            
Radar(i);
            
TextDrawShowForPlayer(ivelo[i]);
            
TextDrawShowForPlayer(iVeiculo[i]);
            
TextDrawShowForPlayer(iLocalidades[i]);
            
TextDrawShowForPlayer(iKmh);
            }else{
            
TextDrawHideForPlayer(ivelo[i]),TextDrawHideForPlayer(iVeiculo[i]),TextDrawHideForPlayer(iKmh),TextDrawHideForPlayer(iLocalidades[i]);
        }
    }
    return 
1;




Re: Speedometer problem - Leonaardo - 04.11.2017

Quote:
Originally Posted by Sunehildeep
Посмотреть сообщение
PHP код:
public Velocimetro()
{
    foreach(
Playeri)
    {
        new 
aname[MAX_PLAYER_NAME];
        
GetPlayerName(ianameMAX_PLAYER_NAME);
        if(
IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
        {
            new 
Float:XFloat:YFloat:ZFloat:Speed;
            
GetVehicleVelocity(GetPlayerVehicleID(i), XYZ);
            
Speed floatmul(floatsqroot(floatadd(floatadd(floatpower(X2), floatpower(Y2)),  floatpower(Z2))), 170.0);
            new 
Float:vcarro;
            
GetVehicleHealth(GetPlayerVehicleID(i), vcarro);
            new 
velocid;
            
velocid floatround(Speedfloatround_floor);
            new 
string[128];
            new 
PlayerVehicleModelID GetVehicleModel(GetPlayerVehicleID(i));
            
PlayerVehicleModelID -= 400;
            new 
ncarro[30];
            if(
velocid == 300)
            {
                
SetTimerEx("remove it"1000false"i"i);
            }
            if(
velocid == 350)
            {
                
SetTimerEx("remove it"1000false"i"i);
            }
            if(
velocid == 380)
            {
                
SetTimerEx("remove it"1000false"i"i);
            }
            if(
velocid 385)
            {
                
SetTimerEx("banspeed"100false"i"i);
            }
            
format(ncarro,30,PlayerVehicle[PlayerVehicleModelID]);
            
GetPlayer2DZone(izoneMAX_ZONE_NAME);
            
format(string128,"%i",velocid); //~y~Km/h
            
TextDrawSetString(velo[i],string);
            
// PLAYER VEHICLE
            
format(ncarro,30,PlayerVehicle[PlayerVehicleModelID]);
            
GetPlayer2DZone(izoneMAX_ZONE_NAME);
            
format(string,sizeof(string),"~b~%s",PlayerVehicle[PlayerVehicleModelID]);
            
TextDrawSetString(Veiculo[i], string);
            
// PLAYER VEHICLE
            // LOCATION SPEEDOMETER
            
format(ncarro,30,PlayerVehicle[PlayerVehicleModelID]);
            
GetPlayer2DZone(izoneMAX_ZONE_NAME);
            
format(string,sizeof(string),"~w~%s"zone);
            
TextDrawSetString(Localidades[i], string);
            
// KM / H
            
format(ncarro,30,PlayerVehicle[PlayerVehicleModelID]);
            
GetPlayer2DZone(izoneMAX_ZONE_NAME);
            
format(string,sizeof(string),"~y~KM/H"); //~y~~i~/~y~
            
TextDrawSetString(Kmhstring);
            
Radar(i);
            
TextDrawShowForPlayer(ivelo[i]);
            
TextDrawShowForPlayer(iVeiculo[i]);
            
TextDrawShowForPlayer(iLocalidades[i]);
            
TextDrawShowForPlayer(iKmh);
            }else{
            
TextDrawHideForPlayer(ivelo[i]),TextDrawHideForPlayer(iVeiculo[i]),TextDrawHideForPlayer(iKmh),TextDrawHideForPlayer(iLocalidades[i]);
        }
    }
    return 
1;

thank you friend.
That solved! <3
+ RP