---
title: "PlayerTextDrawSetString | open.mp"
description: "Altere o texto de um player-textdraw."
canonical: https://omp.itsneufox.com/pt-BR/docs/scripting/functions/PlayerTextDrawSetString
language: pt-BR
---

# PlayerTextDrawSetString

## Descrição

Altere o texto de um player-textdraw.

| Nome | Descrição |
| --- | --- |
| playerid | O ID do jogador cuja string textdraw deve ser definida |
| PlayerText:textid | O ID do textdraw a ser alterado |
| const format\[\] | A nova string para TextDraw |
| OPEN\_MP\_TAGS:... | Número indefinido de argumentos de qualquer tag. |

## Retornos

Esta função não retorna nenhum valor específico.

## Exemplos

```c
new PlayerText:pVehicleHealthTD[MAX_PLAYERS];
new pVehicleHealthTimer[MAX_PLAYERS];

public OnPlayerStateChange(playerid, PLAYER_STATE:newstate, PLAYER_STATE:oldstate)
{
    if (newstate == PLAYER_STATE_DRIVER) // Entrou em um veículo como motorista
    {
        pVehicleHealthTD[playerid] = CreatePlayerTextDraw(playerid, 320.0, 240.0, " ");
        PlayerTextDrawShow(playerid, pVehicleHealthTD[playerid]);

        // Defina um cronômetro para atualizar o textdraw a cada segundo
        pVehicleHealthTimer[playerid] = SetTimerEx("UpdateVehicleHealthTextDraw", 1000, true, "i", playerid);
    }
    if (oldstate == PLAYER_STATE_DRIVER)
    {
        KillTimer(pVehicleHealthTimer[playerid]);
        PlayerTextDrawDestroy(playerid, pVehicleHealthTD[playerid]);
    }
    return 1;
}

forward UpdateVehicleHealthTextDraw(playerid);
public UpdateVehicleHealthTextDraw(playerid)
{
    new
        string[32],
        vehicleid = GetPlayerVehicleID(playerid),
        Float:health;

    GetVehicleHealth(vehicleid, health);

    format(string, sizeof(string), "Vehicle Health: %.0f", health);
    PlayerTextDrawSetString(playerid, pVehicleHealthTD[playerid], string); // <<< Atualize o texto para mostrar a saúde do veículo

    // DICA PROFISSIONAL: Você não precisa de `format` em open.mp
    PlayerTextDrawSetString(playerid, pVehicleHealthTD[playerid], "Vehicle Health: %.0f", health);
    return 1;
}

/* NOTA: Este exemplo é apenas para fins de demonstração, não é garantido que funcione no jogo. É apenas para mostrar o uso da função PlayerTextDrawSetString. */
```

## Notas

dica

Você não precisa mostrar TextDraw novamente para aplicar as alterações.

aviso

Existem limites para o comprimento das strings textdraw! Consulte [Limites](https://omp.itsneufox.com/pt-BR/docs/scripting/resources/limits) para obter mais informações.

## Funções Relacionadas

-   [CreatePlayerTextDraw](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/CreatePlayerTextDraw): Crie um player-textdraw.
-   [PlayerTextDrawDestroy](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/PlayerTextDrawDestroy): Destrua um player-textdraw.
-   [PlayerTextDrawGetString](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/PlayerTextDrawGetString): Obtém o texto de um player-textdraw.
-   [PlayerTextDrawColor](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/PlayerTextDrawColor): Defina a cor do texto em um player-textdraw.
-   [PlayerTextDrawBoxColor](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/PlayerTextDrawBoxColor): Define a cor da caixa do player-textdraw.
-   [PlayerTextDrawBackgroundColor](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/PlayerTextDrawBackgroundColor): Defina a cor de fundo de um player-textdraw.
-   [PlayerTextDrawAlignment](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/PlayerTextDrawAlignment): Define o alinhamento de um player-textdraw.
-   [PlayerTextDrawFont](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/PlayerTextDrawFont): Defina a fonte de um player-textdraw.
-   [PlayerTextDrawLetterSize](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/PlayerTextDrawLetterSize): Defina o tamanho da letra do texto em um player-textdraw.
-   [PlayerTextDrawTextSize](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/PlayerTextDrawTextSize): Defina o tamanho de uma caixa de desenho de texto do jogador (ou área clicável para PlayerTextDrawSetSelectable).
-   [PlayerTextDrawSetOutline](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/PlayerTextDrawSetOutline): Alterna o contorno em um player-textdraw.
-   [PlayerTextDrawSetShadow](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/PlayerTextDrawSetShadow): Defina a sombra em um player-textdraw.
-   [PlayerTextDrawSetProportional](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/PlayerTextDrawSetProportional): Dimensione o espaçamento do texto em um player-textdraw para uma proporção proporcional.
-   [PlayerTextDrawUseBox](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/PlayerTextDrawUseBox): Ative a caixa em um player-textdraw.
-   [PlayerTextDrawShow](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/PlayerTextDrawShow): Mostra um desenho de texto do jogador.
-   [PlayerTextDrawHide](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/PlayerTextDrawHide): Ocultar um player-textdraw.
