[Ajuda]Textdraw
#1

Boa tarde pessoal, bom minha duvidade й o seguinte eu quero criar um barra de carregamento em textdraw.

Problema: Esta aparecendo tudo de uma vez quando eu queria que aparece text draw por text draw com o tempo definido se alguem poder me ajudar eu agradeзo.
Reply
#2

Crias 3 textdraws, 1 com o fundo, 1 com a cor do textdraw a aumentar consoante a percentagem, e 1 com a percentagem. Depois com um timer й sу ir aumentando o X/Y.
Reply
#3

Desculpe amigo ainda sou novato em pawntem como vocк fazeer um exemplo ai para mim.
Reply
#4

Nгo estб perfeita, mas acho que dб para entenderes.

Jб agora, obrigadгo ao PlayMaker por uma correcзгo na string.





pawn Код:
#define FILTERSCRIPT

#include <a_samp>

new Text:Textdraw0;
new Text:Textdraw1;
new Text:Textdraw2;

new updatetxtd;
new timerupdate;

public OnFilterScriptInit()
{
    Textdraw0 = TextDrawCreate(339.000000, 381.000000, "_");
    TextDrawUseBox(Textdraw0, 1);
    TextDrawBoxColor(Textdraw0, 1095626832);
    TextDrawTextSize(Textdraw0, 234.000000, -1.000000);
   
    Textdraw1 = TextDrawCreate(236.000000, 381.000000, "_");
    TextDrawUseBox(Textdraw1, 1);
    TextDrawBoxColor(Textdraw1, 270392319);
    TextDrawTextSize(Textdraw1, 234.000000, -1.000000);

    Textdraw2 = TextDrawCreate(339.000000, 381.000000, "0 %");
    TextDrawBackgroundColor(Textdraw2, 255);
    TextDrawFont(Textdraw2, 3);
    TextDrawLetterSize(Textdraw2, 0.210000, 1.000000);
    TextDrawColor(Textdraw2, -1);
    TextDrawSetOutline(Textdraw2, 1);
    TextDrawSetProportional(Textdraw2, 0);
    return 1;
}

public OnFilterScriptExit()
{
    TextDrawHideForAll(Textdraw0);
    TextDrawDestroy(Textdraw0);
   
    TextDrawHideForAll(Textdraw1);
    TextDrawDestroy(Textdraw1);
   
    TextDrawHideForAll(Textdraw2);
    TextDrawDestroy(Textdraw2);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/show"))
    {
        TextDrawShowForPlayer(playerid, Textdraw0);
        TextDrawShowForPlayer(playerid, Textdraw1);
        TextDrawShowForPlayer(playerid, Textdraw2);
        return 1;
    }
   
    if(!strcmp(cmdtext, "/hide"))
    {
        TextDrawHideForPlayer(playerid, Textdraw0);
        TextDrawHideForPlayer(playerid, Textdraw1);
        TextDrawHideForPlayer(playerid, Textdraw2);
        return 1;
    }
   
    if(!strcmp(cmdtext, "/update"))
    {
        timerupdate = SetTimerEx("Update", 3000, true, "%d", playerid);
        return 1;
    }
    return 1;
}

forward Update(playerid);
public Update(playerid)
{
    updatetxtd++;
 
    if(updatetxtd == 1)
    {
        TextDrawHideForPlayer(playerid, Textdraw1);
        TextDrawTextSize(Textdraw1, 234.000000+20, -1.000000);
        TextDrawShowForPlayer(playerid, Textdraw1);

        TextDrawSetString(Textdraw2, "20 %");
    }

    if(updatetxtd == 2)
    {
        TextDrawHideForPlayer(playerid, Textdraw1);
        TextDrawTextSize(Textdraw1, 234.000000+40, -1.000000);
        TextDrawShowForPlayer(playerid, Textdraw1);

        TextDrawSetString(Textdraw2, "40 %");
    }

    if(updatetxtd == 3)
    {
        TextDrawHideForPlayer(playerid, Textdraw1);
        TextDrawTextSize(Textdraw1, 234.000000+60, -1.000000);
        TextDrawShowForPlayer(playerid, Textdraw1);

        TextDrawSetString(Textdraw2, "60 %");
    }

    if(updatetxtd == 4)
    {
        TextDrawHideForPlayer(playerid, Textdraw1);
        TextDrawTextSize(Textdraw1, 234.000000+80, -1.000000);
        TextDrawShowForPlayer(playerid, Textdraw1);
   
        TextDrawSetString(Textdraw2, "80 %");
    }

    if(updatetxtd == 5)
    {
        TextDrawHideForPlayer(playerid, Textdraw1);
        TextDrawTextSize(Textdraw1, 234.000000+100+2, -1.000000);
        TextDrawShowForPlayer(playerid, Textdraw1);
   
        TextDrawSetString(Textdraw2, "100 %");

        KillTimer(timerupdate);
    }
    return 1;
}

Reply
#5

Obrigado Russo vocк me ajudou muito mas agora estou com outro problema.

Problema: Como eu fasso para fazer apareecer essa barra quando o player morrer?
Reply
#6

aew russo como eu faзo essa mesma barrinha sу que um quadrado emcima do chat?
sу sei faze letras
Reply
#7

Quote:
Originally Posted by Levelup
Obrigado Russo vocк me ajudou muito mas agora estou com outro problema.

Problema: Como eu fasso para fazer apareecer essa barra quando o player morrer?
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
TextDrawShowForPlayer(playerid,Textdraw0);
TextDrawShowForPlayer(playerid,Textdraw1);
TextDrawShowForPlayer(playerid,Textdraw2);
 return 1;
}
Reply
#8

TheGarfield eu acho q assim desse jeito nгo vai aparecer a barra com intervalos tipo carregando.
Reply
#9

Quote:
Originally Posted by Levelup
TheGarfield eu acho q assim desse jeito nгo vai aparecer a barra com intervalos tipo carregando.
usa o setimer
Reply
#10

Aqui tens um exemplo jб em gamemode. Deve funcionar bem, mas de qualquer maneira й sу mudares ou perguntares aqui.

pawn Код:
#include <a_samp>

#if defined MAX_PLAYERS

    #undef MAX_PLAYERS
    #define MAX_PLAYERS   (50) // Altera para o nъmero de slots do teu servidor.

#endif

new updatetxtd;
new timerupdate;

main()
{

}

public OnGameModeInit()
{
    SetGameModeText("Example");

    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        TextDrawHideForPlayer(i, Text:GetPVarInt(i, "MainBox"));
        TextDrawHideForPlayer(i, Text:GetPVarInt(i, "SecondaryBox"));
        TextDrawHideForPlayer(i, Text:GetPVarInt(i, "Percentage"));

        TextDrawDestroy(Text:GetPVarInt(i, "MainBox"));
        TextDrawDestroy(Text:GetPVarInt(i, "SecondaryBox"));
        TextDrawDestroy(Text:GetPVarInt(i, "Percentage"));

        DeletePVar(i, "MainBox");
        DeletePVar(i, "SecondaryBox");
        DeletePVar(i, "Percentage");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    _OnPlayerDisconnect(playerid);
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    TogglePlayerSpectating(playerid, 1);
   
    _OnPlayerConnect(playerid);

    TextDrawShowForPlayer(playerid, Text:GetPVarInt(playerid, "MainBox"));
    TextDrawShowForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
    TextDrawShowForPlayer(playerid, Text:GetPVarInt(playerid, "Percentage"));

    timerupdate = SetTimerEx("Update", 3000, true, "%d", playerid);
    return 1;
}

forward Update(playerid);
public Update(playerid)
{
    updatetxtd++;

    if(updatetxtd == 1)
    {
        TextDrawHideForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
        TextDrawTextSize(Text:GetPVarInt(playerid, "SecondaryBox"), 234.000000+20, -1.000000);
        TextDrawShowForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));

        TextDrawSetString(Text:GetPVarInt(playerid, "Percentage"), "20 %");
    }
    else if(updatetxtd == 2)
    {
        TextDrawHideForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
        TextDrawTextSize(Text:GetPVarInt(playerid, "SecondaryBox"), 234.000000+40, -1.000000);
        TextDrawShowForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));

        TextDrawSetString(Text:GetPVarInt(playerid, "Percentage"), "40 %");
    }
    else if(updatetxtd == 3)
    {
        TextDrawHideForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
        TextDrawTextSize(Text:GetPVarInt(playerid, "SecondaryBox"), 234.000000+60, -1.000000);
        TextDrawShowForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));

        TextDrawSetString(Text:GetPVarInt(playerid, "Percentage"), "60 %");
    }
    else if(updatetxtd == 4)
    {
        TextDrawHideForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
        TextDrawTextSize(Text:GetPVarInt(playerid, "SecondaryBox"), 234.000000+80, -1.000000);
        TextDrawShowForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));

        TextDrawSetString(Text:GetPVarInt(playerid, "Percentage"), "80 %");
    }
    else if(updatetxtd == 5)
    {
        TextDrawHideForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
        TextDrawTextSize(Text:GetPVarInt(playerid, "SecondaryBox"), 234.000000+100+2, -1.000000);
        TextDrawShowForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));

        TextDrawSetString(Text:GetPVarInt(playerid, "Percentage"), "100 %");
       
        GameTextForPlayer(playerid, "A preparar as coisas...", 2000, 5);
    }
    else if(updatetxtd == 6)
    {
        _OnPlayerDisconnect(playerid);

        updatetxtd = 0;

        TogglePlayerSpectating(playerid, 0);

        SpawnPlayer(playerid);
    }
    return 1;
}

stock _OnPlayerConnect(playerid)
{
    SetPVarInt(playerid, "MainBox", _:TextDrawCreate(339.000000, 381.000000, "_"));
    TextDrawUseBox(Text:GetPVarInt(playerid, "MainBox"), 1);
    TextDrawBoxColor(Text:GetPVarInt(playerid, "MainBox"), 1095626832);
    TextDrawTextSize(Text:GetPVarInt(playerid, "MainBox"), 234.000000, -1.000000);

    SetPVarInt(playerid, "SecondaryBox", _:TextDrawCreate(236.000000, 381.000000, "_"));
    TextDrawUseBox(Text:GetPVarInt(playerid, "SecondaryBox"), 1);
    TextDrawBoxColor(Text:GetPVarInt(playerid, "SecondaryBox"), 270392319);
    TextDrawTextSize(Text:GetPVarInt(playerid, "SecondaryBox"), 234.000000, -1.000000);

    SetPVarInt(playerid, "Percentage", _:TextDrawCreate(339.000000, 381.000000, "0 %"));
    TextDrawBackgroundColor(Text:GetPVarInt(playerid, "Percentage"), 255);
    TextDrawFont(Text:GetPVarInt(playerid, "Percentage"), 3);
    TextDrawLetterSize(Text:GetPVarInt(playerid, "Percentage"), 0.210000, 1.000000);
    TextDrawColor(Text:GetPVarInt(playerid, "Percentage"), -1);
    TextDrawSetOutline(Text:GetPVarInt(playerid, "Percentage"), 1);
    TextDrawSetProportional(Text:GetPVarInt(playerid, "Percentage"), 0);
}

stock _OnPlayerDisconnect(playerid)
{
    KillTimer(timerupdate);

    TextDrawHideForPlayer(playerid, Text:GetPVarInt(playerid, "MainBox"));
    TextDrawHideForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
    TextDrawHideForPlayer(playerid, Text:GetPVarInt(playerid, "Percentage"));

    TextDrawDestroy(Text:GetPVarInt(playerid, "MainBox"));
    TextDrawDestroy(Text:GetPVarInt(playerid, "SecondaryBox"));
    TextDrawDestroy(Text:GetPVarInt(playerid, "Percentage"));

    DeletePVar(playerid, "MainBox");
    DeletePVar(playerid, "SecondaryBox");
    DeletePVar(playerid, "Percentage");
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)