SA-MP Forums Archive
[Ayuda] Velocнmetro. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: [Ayuda] Velocнmetro. (/showthread.php?tid=408375)



[Ayuda] Velocнmetro. - BenjaminT4L - 17.01.2013

Lo que pasa es que tengo este velocнmetro, pero el puntito no sirve de nada y sale esto:



Quiero que el punto se mueva S:

El cуdigo es:

pawn Код:
#include <a_samp>
enum td
{
        Text:TDSpeedClock[10]
}

new TextDraws[td];
new Text:TextDrawsd[MAX_PLAYERS][4];
new DeActiveSpeedometer[MAX_PLAYERS];

public OnFilterScriptInit()
{
    print("Archivo de Textdraws generado utilizando");
    print("    Zamaroht's textdraw editor fue exitosamente cargado.");

    // Crear los textdraws:
    TextDraws[TDSpeedClock][0] = TextDrawCreate(617.000000, 314.000000, "300");
    TextDrawBackgroundColor(TextDraws[TDSpeedClock][0], 255);
    TextDrawFont(TextDraws[TDSpeedClock][0], 3);
    TextDrawLetterSize(TextDraws[TDSpeedClock][0], 0.230000, 1.200000);
    TextDrawColor(TextDraws[TDSpeedClock][0], 10682367);
    TextDrawSetOutline(TextDraws[TDSpeedClock][0], 1);
    TextDrawSetProportional(TextDraws[TDSpeedClock][0], 1);

    TextDraws[TDSpeedClock][1] = TextDrawCreate(592.000000, 321.000000, "250");
    TextDrawBackgroundColor(TextDraws[TDSpeedClock][1], 255);
    TextDrawFont(TextDraws[TDSpeedClock][1], 3);
    TextDrawLetterSize(TextDraws[TDSpeedClock][1], 0.230000, 1.200000);
    TextDrawColor(TextDraws[TDSpeedClock][1], 10682367);
    TextDrawSetOutline(TextDraws[TDSpeedClock][1], 1);
    TextDrawSetProportional(TextDraws[TDSpeedClock][1], 1);

    TextDraws[TDSpeedClock][2] = TextDrawCreate(568.000000, 330.000000, "210");
    TextDrawBackgroundColor(TextDraws[TDSpeedClock][2], 255);
    TextDrawFont(TextDraws[TDSpeedClock][2], 3);
    TextDrawLetterSize(TextDraws[TDSpeedClock][2], 0.230000, 1.200000);
    TextDrawColor(TextDraws[TDSpeedClock][2], 10682367);
    TextDrawSetOutline(TextDraws[TDSpeedClock][2], 1);
    TextDrawSetProportional(TextDraws[TDSpeedClock][2], 1);

    TextDraws[TDSpeedClock][3] = TextDrawCreate(548.000000, 345.000000, "160");
    TextDrawBackgroundColor(TextDraws[TDSpeedClock][3], 255);
    TextDrawFont(TextDraws[TDSpeedClock][3], 3);
    TextDrawLetterSize(TextDraws[TDSpeedClock][3], 0.230000, 1.200000);
    TextDrawColor(TextDraws[TDSpeedClock][3], 10682367);
    TextDrawSetOutline(TextDraws[TDSpeedClock][3], 1);
    TextDrawSetProportional(TextDraws[TDSpeedClock][3], 1);

    TextDraws[TDSpeedClock][4] = TextDrawCreate(533.000000, 364.000000, "120");
    TextDrawBackgroundColor(TextDraws[TDSpeedClock][4], 255);
    TextDrawFont(TextDraws[TDSpeedClock][4], 3);
    TextDrawLetterSize(TextDraws[TDSpeedClock][4], 0.230000, 1.200000);
    TextDrawColor(TextDraws[TDSpeedClock][4], 10682367);
    TextDrawSetOutline(TextDraws[TDSpeedClock][4], 1);
    TextDrawSetProportional(TextDraws[TDSpeedClock][4], 1);

    TextDraws[TDSpeedClock][5] = TextDrawCreate(521.000000, 383.000000, "70");
    TextDrawBackgroundColor(TextDraws[TDSpeedClock][5], 255);
    TextDrawFont(TextDraws[TDSpeedClock][5], 3);
    TextDrawLetterSize(TextDraws[TDSpeedClock][5], 0.230000, 1.200000);
    TextDrawColor(TextDraws[TDSpeedClock][5], 10682367);
    TextDrawSetOutline(TextDraws[TDSpeedClock][5], 1);
    TextDrawSetProportional(TextDraws[TDSpeedClock][5], 1);

    TextDraws[TDSpeedClock][6] = TextDrawCreate(512.000000, 404.000000, "40");
    TextDrawBackgroundColor(TextDraws[TDSpeedClock][6], 255);
    TextDrawFont(TextDraws[TDSpeedClock][6], 3);
    TextDrawLetterSize(TextDraws[TDSpeedClock][6], 0.230000, 1.200000);
    TextDrawColor(TextDraws[TDSpeedClock][6], 10682367);
    TextDrawSetOutline(TextDraws[TDSpeedClock][6], 1);
    TextDrawSetProportional(TextDraws[TDSpeedClock][6], 1);

    TextDraws[TDSpeedClock][7] = TextDrawCreate(509.000000, 427.000000, "0");
    TextDrawBackgroundColor(TextDraws[TDSpeedClock][7], 255);
    TextDrawFont(TextDraws[TDSpeedClock][7], 3);
    TextDrawLetterSize(TextDraws[TDSpeedClock][7], 0.270000, 1.299999);
    TextDrawColor(TextDraws[TDSpeedClock][7], 10682367);
    TextDrawSetOutline(TextDraws[TDSpeedClock][7], 1);
    TextDrawSetProportional(TextDraws[TDSpeedClock][7], 1);

    TextDraws[TDSpeedClock][8] = TextDrawCreate(520.000000, 422.000000, ".");
    TextDrawBackgroundColor(TextDraws[TDSpeedClock][8], 255);
    TextDrawFont(TextDraws[TDSpeedClock][8], 1);
    TextDrawLetterSize(TextDraws[TDSpeedClock][8], 0.439999, 1.799999);
    TextDrawColor(TextDraws[TDSpeedClock][8], -1);
    TextDrawSetOutline(TextDraws[TDSpeedClock][8], 1);
    TextDrawSetProportional(TextDraws[TDSpeedClock][8], 1);

    /*TextDraws[TDSpeedClock][9] = TextDrawCreate(570.000000, 371.000000, "KM/H");
    TextDrawBackgroundColor(TextDraws[TDSpeedClock][9], 255);
    TextDrawFont(TextDraws[TDSpeedClock][9], 3);
    TextDrawLetterSize(TextDraws[TDSpeedClock][9], 0.270000, 1.299999);
    TextDrawColor(TextDraws[TDSpeedClock][9], -16777046);
    TextDrawSetOutline(TextDraws[TDSpeedClock][9], 1);
    TextDrawSetProportional(TextDraws[TDSpeedClock][9], 1);*/


    return 1;
}

public OnFilterScriptExit()
{
    TextDrawHideForAll(TextDraws[TDSpeedClock][0]);
    TextDrawDestroy(TextDraws[TDSpeedClock][0]);
    TextDrawHideForAll(TextDraws[TDSpeedClock][1]);
    TextDrawDestroy(TextDraws[TDSpeedClock][1]);
    TextDrawHideForAll(TextDraws[TDSpeedClock][2]);
    TextDrawDestroy(TextDraws[TDSpeedClock][2]);
    TextDrawHideForAll(TextDraws[TDSpeedClock][3]);
    TextDrawDestroy(TextDraws[TDSpeedClock][3]);
    TextDrawHideForAll(TextDraws[TDSpeedClock][4]);
    TextDrawDestroy(TextDraws[TDSpeedClock][4]);
    TextDrawHideForAll(TextDraws[TDSpeedClock][5]);
    TextDrawDestroy(TextDraws[TDSpeedClock][5]);
    TextDrawHideForAll(TextDraws[TDSpeedClock][6]);
    TextDrawDestroy(TextDraws[TDSpeedClock][6]);
    TextDrawHideForAll(TextDraws[TDSpeedClock][7]);
    TextDrawDestroy(TextDraws[TDSpeedClock][7]);
    TextDrawHideForAll(TextDraws[TDSpeedClock][8]);
    TextDrawDestroy(TextDraws[TDSpeedClock][8]);
    TextDrawHideForAll(TextDraws[TDSpeedClock][9]);
    TextDrawDestroy(TextDraws[TDSpeedClock][9]);
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
        if(newstate == PLAYER_STATE_DRIVER && !DeActiveSpeedometer[playerid])
        {
                for(new i; i < 10; i++)
                        TextDrawShowForPlayer(playerid, TextDraws[TDSpeedClock][i]);

                for(new i; i < 4; i++)
                        TextDrawsd[playerid][i] = TextDrawCreate(520.000000, 422.000000, "~b~.");

        }
        else
        {
                for(new i; i < 4; i++)
                    TextDrawHideForPlayer(playerid, TextDrawsd[playerid][i]);
                for(new i; i < 10; i++)
                        TextDrawHideForPlayer(playerid, TextDraws[TDSpeedClock][i]);
        }

    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        TextDrawShowForPlayer(playerid, TextDraws[TDSpeedClock][0]);
        TextDrawShowForPlayer(playerid, TextDraws[TDSpeedClock][1]);
        TextDrawShowForPlayer(playerid, TextDraws[TDSpeedClock][2]);
        TextDrawShowForPlayer(playerid, TextDraws[TDSpeedClock][3]);
        TextDrawShowForPlayer(playerid, TextDraws[TDSpeedClock][4]);
        TextDrawShowForPlayer(playerid, TextDraws[TDSpeedClock][5]);
        TextDrawShowForPlayer(playerid, TextDraws[TDSpeedClock][6]);
        TextDrawShowForPlayer(playerid, TextDraws[TDSpeedClock][7]);
        TextDrawShowForPlayer(playerid, TextDraws[TDSpeedClock][8]);
    }
    else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
    {
        TextDrawHideForPlayer(playerid, TextDraws[TDSpeedClock][0]);
        TextDrawHideForPlayer(playerid, TextDraws[TDSpeedClock][1]);
        TextDrawHideForPlayer(playerid, TextDraws[TDSpeedClock][2]);
        TextDrawHideForPlayer(playerid, TextDraws[TDSpeedClock][3]);
        TextDrawHideForPlayer(playerid, TextDraws[TDSpeedClock][4]);
        TextDrawHideForPlayer(playerid, TextDraws[TDSpeedClock][5]);
        TextDrawHideForPlayer(playerid, TextDraws[TDSpeedClock][6]);
        TextDrawHideForPlayer(playerid, TextDraws[TDSpeedClock][7]);
        TextDrawHideForPlayer(playerid, TextDraws[TDSpeedClock][8]);
    }
    return 1;
}
public OnPlayerUpdate(playerid)
{
        new
            Float:fPos[3],
            Float:Pos[4][2],
            Float:fSpeed;

        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && !DeActiveSpeedometer[playerid])
        {
                GetVehicleVelocity(GetPlayerVehicleID(playerid), fPos[0], fPos[1], fPos[2]);

                fSpeed = floatsqroot(floatpower(fPos[0], 2) + floatpower(fPos[1], 2) +
                 floatpower(fPos[2], 2)) * 300;

                new Float:alpha = 320 - fSpeed;
                if(alpha < 60)
                    alpha = 60;

                for(new i; i < 4; i++)
                {
                    TextDrawHideForPlayer(playerid, TextDrawsd[playerid][i]);
                    TextDrawDestroy(TextDrawsd[playerid][i]);
                        GetDotXY(300, 401, Pos[i][0], Pos[i][1], alpha, (i + 1) * 8);
                        TextDrawsd[playerid][i] = TextDrawCreate(Pos[i][0], Pos[i][1], "~w~.");
                        TextDrawLetterSize(TextDrawsd[playerid][i], 0.270000, 1.299999);
                        TextDrawSetOutline(TextDrawsd[playerid][i], 1);
                        TextDrawSetShadow(TextDrawsd[playerid][i], 1);
                        TextDrawFont(TextDrawsd[playerid][i], 3);
                        TextDrawShowForPlayer(playerid, TextDrawsd[playerid][i]);

                }
        }


        return 1;
}

stock GetDotXY(Float:StartPosX, Float:StartPosY, &Float:NewX, &Float:NewY, Float:alpha, Float:dist)
{
         NewX = StartPosX + (dist * floatsin(alpha, degrees));
         NewY = StartPosY + (dist * floatcos(alpha, degrees));
}



Respuesta: [Ayuda] Velocнmetro. - enigma513 - 18.01.2013

Si dijeras quien hizo el code, o pasaras el real te podria ayudar.

PD: Yo acabo de hacer un sistema similar, los datos que necesito son la velocidad del auto(la uso como angulo), el radio del circulo, las pos X Y del centro del circulo para poder calcular con Seno y Coseno la posicion que debera tomar cuando la velocidad cambie.
http://www.youtube.com/watch?feature...&v=ll0wR45acK8


Respuesta: [Ayuda] Velocнmetro. - BenjaminT4L - 18.01.2013

Quote:
Originally Posted by enigma513
Посмотреть сообщение
Si dijeras quien hizo el code, o pasaras el real te podria ayudar.

PD: Yo acabo de hacer un sistema similar, los datos que necesito son la velocidad del auto(la uso como angulo), el radio del circulo, las pos X Y del centro del circulo para poder calcular con Seno y Coseno la posicion que debera tomar cuando la velocidad cambie.
http://www.youtube.com/watch?feature...&v=ll0wR45acK8
Lo que hize fue modificar uno ya echo, les cambie las coordenadas... por eso pido ayuda :c

Lo ъnico que me falta es que esa bolita se mueva. El lнmite de velocidad serнa 300... como dice en la imagen


Respuesta: [Ayuda] Velocнmetro. - Blaze_Strockovic - 18.01.2013

Disculpa que no tenga que ver esta respuesta al Post, pero їDonde descargaste ese FS?


Respuesta: [Ayuda] Velocнmetro. - OTACON - 18.01.2013

Quote:
Originally Posted by Blaze_Strockovic
Посмотреть сообщение
Disculpa que no tenga que ver esta respuesta al Post, pero їDonde descargaste ese FS?
de la seccion pedidos, es de Jordan98

https://sampforum.blast.hk/showthread.php?tid=126022&page=125


Respuesta: [Ayuda] Velocнmetro. - BenjaminT4L - 18.01.2013

Quote:
Originally Posted by bytytus
Посмотреть сообщение
Sii, pero es que los que le pasaron estбn bugueados :/ por eso pido ayuda.


Respuesta: [Ayuda] Velocнmetro. - [DOG]irinel1996 - 18.01.2013

No pensй que mi velocнmetro os gustara tanto.

Te ayudarнa pero, volvн al SA-MP y estoy haciendo un servidor de carreras, asн que me reservo la exclusividad.

PD: Si dicen que lo copie del servidor ese de dуnde Jordan98 sacу la imagen, no lo digan, porque lo vendн a ellos con licencia personal.

ЎSaludos!


Re: [Ayuda] Velocнmetro. - BenjaminT4L - 18.01.2013

Ayuda por favor. :/


Respuesta: [Ayuda] Velocнmetro. - adri1 - 18.01.2013

No te recomiendo ese tipo de velocimetros ya que genere bastante lag...
Cuanto mбs sencillo menos lag


Respuesta: [Ayuda] Velocнmetro. - [DOG]irinel1996 - 18.01.2013

Quote:
Originally Posted by adri1
Посмотреть сообщение
No te recomiendo ese tipo de velocimetros ya que genere bastante lag...
Cuanto mбs sencillo menos lag
Si quieres te paso la IP del server dуnde estб on que tiene mбs de 150 jugadores. A ver si hay lagg.