SA-MP Forums Archive
[Tutorial] Crear textdraws de estadisticas - 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: [Tutorial] Crear textdraws de estadisticas (/showthread.php?tid=129190)



[Tutorial] Crear textdraws de estadisticas - MrDeath537 - 21.02.2010

Hola, en este tutorial les enseсare a crear textdraws de estadisticas (O sea, los que son individuales para cada player. Por ejemplo: muestran su ping).



_________________________________________________



1) Crearemos el textdraw. їComo?
Usando Zamaroth's text draw editor!
Una vez que lo creamos lo exportaremos en modo CLASICO.



_________________________________________________



2) Ahora abrimos el archivo .txt que nos genero el TextDraw editor. Copiamos su contenido, ahora vamos a la parte de arriba de nuestro script donde alli agregaremos:
pawn Код:
new Text:nombredeltext[MAX_PLAYERS];


_________________________________________________



3) Bueno aqui empezaremos a crear los text draws de estadisticas. Hay 2 formas de hacerlo:

Antes de ver las formas primero con las lineas de nuestro textdraw haremos lo siguiente:
Remplazamos le nombre Textdraw0 por el nombre de nuestro textdraw y le agregaremos el [playerid] adelante.
Ejemplo:
pawn Код:
Ping[playerid] = TextDrawCreate(634.000000, 417.000000, "Ping: 0");
TextDrawAlignment(Ping[playerid], 3);
TextDrawBackgroundColor(Ping[playerid], 0x000000FF);
TextDrawFont(Ping[playerid], 2);
TextDrawLetterSize(Ping[playerid], 0.499999, 1.400000);
TextDrawSetOutline(Ping[playerid], 1);
-------------------------------------------------------------------------------


_________________________________________________



4) Ahora crearemos un timer que actulize los textdraws cada sierto tiempo:

En la parte de arriba de nuestro script: forward ActualizarTextDraws();
En OnGameModeInit: SetTimer("ActualizarTextDraws", 200, true);
Bueno ahi definimos una nueva funcion y creamos un cronometro que se repite actualizando constantemente los textdraws.



_________________________________________________



5) El callback, aqui pondremos el codigo para que nuestro textdraw se actualize:

Si en el paso 3 usaste el modo 1 sigue esta:

pawn Код:
public ActualizarTextDraws()
{
    new String[100];

    for(new playerid = 0; playerid < MAX_PLAYERS; playerid ++)
    {
        if(IsPlayerConnected(playerid))
        {
            format(String, sizeof(String), "Ping: %d", GetPlayerPing(playerid));
            TextDrawSetString(Ping[playerid], String);
            TextDrawShowForPlayer(playerid, Ping[playerid]);
        }
    }
}
De lo contrario esta:

pawn Код:
public ActualizarTextDraws()
{
    new String[100];

    for(new playerid = 0; playerid < GetMaxPlayers(); playerid ++)
    {
        if(IsPlayerConnected(playerid))
        {
            format(String, sizeof(String), "Ping: %d", GetPlayerPing(playerid));
            TextDrawSetString(Ping[playerid], String);
            TextDrawShowForPlayer(playerid, Ping[playerid]);
        }
    }
}

Que hicimos ahi? Usamos el for para checkear todos los slots a la vez. Luego checkeamos si esta conectado el jugador. Y luego actualizamos su textdraw.

Yo he creado el tutorial usando el ejemplo de un textdraw de ping. Ustedes pueden hacerlo de otras cosas.
Cualquier duda pregunten


Re: [Tutorial] Crear textdraws de estadisticas - xenowort - 21.02.2010

MMM se podria hacer de niveles


Re: [Tutorial] Crear textdraws de estadisticas - Sandman-x - 03.05.2010

Buen Tuto


Re: [Tutorial] Crear textdraws de estadisticas - [DOG]irinel1996 - 02.04.2011

Se agradece.


Respuesta: [Tutorial] Crear textdraws de estadisticas - [DOG]irinel1996 - 15.07.2011

Porque no se crea el TextDraw en OnPlayerConnect? Asн supuestamente el TextDraw se crea para cada jugador. No?
_________________
Saludos...


Respuesta: [Tutorial] Crear textdraws de estadisticas - leoals - 15.07.2011

Buen tutorial MrDeath