SA-MP Forums Archive
[Pedido] "X" na tela ao acertar o tiro - 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: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Pedido] "X" na tela ao acertar o tiro (/showthread.php?tid=654951)



"X" na tela ao acertar o tiro - ChrisZaum - 09.06.2018

Fala galera!!
Entгo, estava interessado em um cуdigo que vi em alguns servidores como o Kokys deathmatch.



Quando o player acerta o tiro em outro, tipo que aparece um "X" sobrepondo a mira do atirador.


Re: "X" na tela ao acertar o tiro - renatog - 10.06.2018

Sу criar um 'X' no meio da tela do jogador quando acertar o tiro


Re: "X" na tela ao acertar o tiro - willttoonn - 10.06.2018

Coloque no topo do GM:
pawn Код:
new Text:HitMark;
Coloque no OnGamemodeInit
pawn Код:
//HitMarker
    HitMark = TextDrawCreate(333.000000, 174.000000, "X");
    TextDrawBackgroundColor(HitMark, 255);
    TextDrawFont(HitMark, 1);
    TextDrawLetterSize(HitMark, 0.500000, 1.000000);
    TextDrawColor(HitMark, -1);
    TextDrawSetOutline(HitMark, 0);
    TextDrawSetProportional(HitMark, 1);
    TextDrawSetShadow(HitMark, 1);

    SetTimer("CheckHitMark", 500, true);//0,5s
Coloque dentro da funзгo OnPlayerGiveDamage
pawn Код:
SetPVarInt(playerid, "HitMark", 1);
    TextDrawHideForPlayer(playerid, HitMark);
    TextDrawShowForPlayer(playerid, HitMark);
Coloque em algum canto do gamemode
pawn Код:
forward CheckHitMark();
public CheckHitMark()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(GetPVarInt(i, "HitMark") > 0)
        {
            SetPVarInt(i, "HitMark", GetPVarInt(i, "HitMark")-1);
            if(GetPVarInt(i, "HitMark") == 0)
            {
                TextDrawHideForPlayer(i,HitMark);
            }
        }
    }
    return 1;
}



Re: "X" na tela ao acertar o tiro - ChrisZaum - 11.06.2018

Valeu @willttoonn, funcionou direitinho


Re: "X" na tela ao acertar o tiro - Bruno13 - 11.06.2018

Quote:
Originally Posted by willttoonn
Посмотреть сообщение
Coloque no topo do GM:
pawn Код:
new Text:HitMark;
Coloque no OnGamemodeInit
pawn Код:
//HitMarker
    HitMark = TextDrawCreate(333.000000, 174.000000, "X");
    TextDrawBackgroundColor(HitMark, 255);
    TextDrawFont(HitMark, 1);
    TextDrawLetterSize(HitMark, 0.500000, 1.000000);
    TextDrawColor(HitMark, -1);
    TextDrawSetOutline(HitMark, 0);
    TextDrawSetProportional(HitMark, 1);
    TextDrawSetShadow(HitMark, 1);

    SetTimer("CheckHitMark", 500, true);//0,5s
Coloque dentro da funзгo OnPlayerGiveDamage
pawn Код:
SetPVarInt(playerid, "HitMark", 1);
    TextDrawHideForPlayer(playerid, HitMark);
    TextDrawShowForPlayer(playerid, HitMark);
Coloque em algum canto do gamemode
pawn Код:
forward CheckHitMark();
public CheckHitMark()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(GetPVarInt(i, "HitMark") > 0)
        {
            SetPVarInt(i, "HitMark", GetPVarInt(i, "HitMark")-1);
            if(GetPVarInt(i, "HitMark") == 0)
            {
                TextDrawHideForPlayer(i,HitMark);
            }
        }
    }
    return 1;
}
PVar com loop perde desempenho. Hб diversas maneiras de fazer isso, mas com certeza usar PVar dessa maneira nгo seria uma boa ideia.


Re: "X" na tela ao acertar o tiro - willttoonn - 11.06.2018

Quote:
Originally Posted by Bruno13
Посмотреть сообщение
PVar com loop perde desempenho. Hб diversas maneiras de fazer isso, mas com certeza usar PVar dessa maneira nгo seria uma boa ideia.
Mandei a maneira mais fбcil pra ele usar, otimizar ai й outros quinhentos e ele que deve procurar fazer isso xD


Re: "X" na tela ao acertar o tiro - Bruno13 - 11.06.2018

Quote:
Originally Posted by willttoonn
Посмотреть сообщение
Mandei a maneira mais fбcil pra ele usar, otimizar ai й outros quinhentos e ele que deve procurar fazer isso xD
Vocк poderia jб ter utilizado uma maneira mais eficiente, mas no fim nуs dois sabemos que isso nгo mudaria nada. Sу pelo fato do autor usar a tag Pedido e nгo Ajuda, o final da histуria jб й previsнvel.

Apenas deixei registrado que, aos que realmente se importam, hб caminhos mais otimizados.


Re: "X" na tela ao acertar o tiro - renatog - 11.06.2018

Quote:
Originally Posted by willttoonn
Посмотреть сообщение
Mandei a maneira mais fбcil pra ele usar, otimizar ai й outros quinhentos e ele que deve procurar fazer isso xD
Se ele nгo souber fazer pelo caminho das pedras que eu indiquei, ele nгo vai saber otimizar seu cуdigo.