[Ajuda] Velocimetro bugado
#1

O velocimetro fica mostrando a velocidade assim -18949779 KM/H O.O

O certo seria a velocidade.. tipo. 100 KM/H .-.

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new string[50], carid = GetPlayerVehicleID(playerid);
        GetVehicleVelocity(carid, velokm[0], velokm[1], velokm[2]);

        TextDrawShowForPlayer(playerid, Textdraw4);
        TextDrawShowForPlayer(playerid, Textdraw6);

        format(string, sizeof(string), "~p~Gasolina: ~w~%i", gss[playerid]);
        TextDrawSetString(Textdraw4, string);
       
        new Float: Velocity[3];
        GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);
       
        format(string, sizeof(string), "~p~Velocidade: ~w~%d KM/H", Velocity[0], Velocity[1], Velocity[2]);
        TextDrawSetString(Textdraw6, string);

        if(floatround(((floatsqroot(((velokm[0] * velokm[0]) + (velokm[1] * velokm[1]) + (velokm[2] * velokm[2]))) * (170.0))) * 1) > 5)
        {
            if(gss[playerid] == 0 && Avisado[playerid] == false)
            {
                SendClientMessage(playerid, COR_ERRO, "- Sua gasolina acabou, vocк pode chamar um Frentista, Guicho ou ir atй o posto mais prуximo e abastecer.");
                TogglePlayerControllable(playerid, false);
                Avisado[playerid] = true;
            }
            if(gss[playerid] > 0)
            {
                Retirada[playerid] += 1;
                if(Retirada[playerid] >= (RETIRAR_KM*13))
                {
                    gss[playerid]--;
                    TogglePlayerControllable(playerid, true);
                    Retirada[playerid] = 0;
                    Avisado[playerid] = false;
                }
            }
        }
    }
    return 1;
}
Reply
#2

EDIT@opa cara desculpe era pra te postado em otro local, topico erado confundi *-*
Reply
#3

Amigo, o meu cуdigo й um velocimetro, nгo um radar..

Preciso saber o que б de errado, que mostra -179848 KM/H ao invйz da velocidade real.
Reply
#4

'-' ao inves de
pawn Код:
format(string, sizeof(string), "~p~Velocidade: ~w~%d KM/H", Velocity[0], Velocity[1], Velocity[2]);
Use
pawn Код:
format(string, sizeof(string),"~p~Velocidade: ~w~%d KM/H",GetVehicleVelocity(i, true));
Antes disso no inicio do velocimetro coloca for(new i=0; i<MAX_PLAYERS; i++)
Reply
#5

Deu erro de argumentos..
Reply
#6

pawn Код:
format(string, sizeof(string), "~p~Velocidade: ~w~%i KM/H", ((floatround(floatsqroot(Velocity[0]*Velocity[0] + Velocity[1]*Velocity[1] + Velocity[2]*Velocity[2]) * 180 / 3.6))/1000));
Reply
#7

Agora o velocimetro nгo atualiza...
Reply
#8

Quote:
Originally Posted by Quazar
Посмотреть сообщение
Agora o velocimetro nгo atualiza...
Pq vc estб utilizando no OnPlayerUpdate, esse calculo que postei й para um Timer de 1 segundo...
Reply
#9

Continua nгo atualizando..

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    Timer_Velocimetro = SetTimerEx("AttVelocimetro", 1000, true, "is", -1, -1);
    return 1;
}

public OnPlayerUpdate(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        TextDrawShowForPlayer(playerid, Textdraw6);
    }
    else
    {
        TextDrawHideForPlayer(playerid, Textdraw6);
    }
    return 1;
}

forward AttVelocimetro(playerid);
public AttVelocimetro(playerid)
{
    new Float: Velocity[3];
    GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);

    new string[128];

    format(string, sizeof(string), "~p~Velocidade: ~w~%i KM/H", ((floatround(floatsqroot(Velocity[0]*Velocity[0] + Velocity[1]*Velocity[1] + Velocity[2]*Velocity[2]) * 180 / 3.6))/1000));
    TextDrawSetString(Textdraw6, string);
    return 1;
}
Reply
#10

Tbm que bosta tu fez ai ? LaL.

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate) {
    if(newstate == PLAYER_STATE_DRIVER) SetTimerEx("AttVelocimetro", 1000, false, "i", playerid);
    return 1;
}

forward AttVelocimetro(playerid);
public AttVelocimetro(playerid) {
    TextDrawHideForPlayer(playerid, Textdraw6);
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
        new Float: Velocity[3];
        GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);

        new string[128];
        format(string, sizeof(string), "~p~Velocidade: ~w~%i KM/H", ((floatround(floatsqroot(Velocity[0]*Velocity[0] + Velocity[1]*Velocity[1] + Velocity[2]*Velocity[2]) * 180 / 3.6))/1000));
        TextDrawSetString(Textdraw6, string);
        TextDrawShowForPlayer(playerid, Textdraw6);
        SetTimerEx("AttVelocimetro", 1000, false, "i", playerid)
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)