SA-MP Forums Archive
[Ajuda] TextDraw bugado ' -' - 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: [Ajuda] TextDraw bugado ' -' (/showthread.php?tid=631460)



TextDraw bugado ' -' - ThiagoGamemodes - 29.03.2017

olб, to fazendo um sistema de salvar kill do player e aparecer como pontos para o player sу que quando eu logo com meu amigo os Pontos sу ficam para o id 0 nгo aparece para mim, isso tambйm estб ocorrendo em um sistema de sono que eu havia testado, sу funciona para o id 0 e sempre q aparece pra um aparece bugado mt zuado isso, ta aqui o code, me ajudem a ver o porque disso por favor ?!
Quote:

enum e_PlayerStats
{
pMatou,
pMorreu
};

new pStats[MAX_PLAYERS][e_PlayerStats];

//Texts
new PlayerText:StatusBox[MAX_SLOTS];
new PlayerText:StatusInfo[MAX_SLOTS];
new PlayerText:StatusMatou[MAX_SLOTS];
new PlayerText:StatusMorreu[MAX_SLOTS];

new Updater;

//Ongamemodeinit
Updater = SetTimer("UpdateText",1000,true);

//Ongamemodeexit
KillTimer(Updater);

//OnPlayerConnect
StatusBox[playerid] = CreatePlayerTextDraw(playerid, 621.199951, 288.220001, "usebox");
PlayerTextDrawLetterSize(playerid, StatusBox[playerid], 0.000000, 7.564816);
PlayerTextDrawTextSize(playerid, StatusBox[playerid], 493.200012, 0.000000);
PlayerTextDrawAlignment(playerid, StatusBox[playerid], 1);
PlayerTextDrawColor(playerid, StatusBox[playerid], 0);
PlayerTextDrawUseBox(playerid, StatusBox[playerid], true);
PlayerTextDrawBoxColor(playerid, StatusBox[playerid], 102);
PlayerTextDrawSetShadow(playerid, StatusBox[playerid], 0);
PlayerTextDrawSetOutline(playerid, StatusBox[playerid], 0);
PlayerTextDrawFont(playerid, StatusBox[playerid], 0);

StatusInfo[playerid] = CreatePlayerTextDraw(playerid, 517.599975, 289.706604, "~h~~y~Status:");
PlayerTextDrawLetterSize(playerid, StatusInfo[playerid], 0.449999, 1.600000);
PlayerTextDrawAlignment(playerid, StatusInfo[playerid], 1);
PlayerTextDrawColor(playerid, StatusInfo[playerid], -1);
PlayerTextDrawSetShadow(playerid, StatusInfo[playerid], 0);
PlayerTextDrawSetOutline(playerid, StatusInfo[playerid], 1);
PlayerTextDrawBackgroundColor(playerid, StatusInfo[playerid], 51);
PlayerTextDrawFont(playerid, StatusInfo[playerid], 2);
PlayerTextDrawSetProportional(playerid, StatusInfo[playerid], 1);

StatusMatou[playerid] = CreatePlayerTextDraw(playerid, 508.799987, 310.613281, "Matou:");
PlayerTextDrawLetterSize(playerid, StatusMatou[playerid], 0.449999, 1.600000);
PlayerTextDrawAlignment(playerid, StatusMatou[playerid], 1);
PlayerTextDrawColor(playerid, StatusMatou[playerid], -1);
PlayerTextDrawSetShadow(playerid, StatusMatou[playerid], 0);
PlayerTextDrawSetOutline(playerid, StatusMatou[playerid], 1);
PlayerTextDrawBackgroundColor(playerid, StatusMatou[playerid], 51);
PlayerTextDrawFont(playerid, StatusMatou[playerid], 3);
PlayerTextDrawSetProportional(playerid, StatusMatou[playerid], 1);

StatusMorreu[playerid] = CreatePlayerTextDraw(playerid, 508.000000, 330.026519, "Morreu:");
PlayerTextDrawLetterSize(playerid, StatusMorreu[playerid], 0.449999, 1.600000);
PlayerTextDrawAlignment(playerid, StatusMorreu[playerid], 1);
PlayerTextDrawColor(playerid, StatusMorreu[playerid], -1);
PlayerTextDrawSetShadow(playerid, StatusMorreu[playerid], 0);
PlayerTextDrawSetOutline(playerid, StatusMorreu[playerid], 1);
PlayerTextDrawBackgroundColor(playerid, StatusMorreu[playerid], 51);
PlayerTextDrawFont(playerid, StatusMorreu[playerid], 3);
PlayerTextDrawSetProportional(playerid, StatusMorreu[playerid], 1);

pStats[playerid][pMatou] = 0;
pStats[playerid][pMorreu] = 0;

//Onplayerdisconnect
PlayerTextDrawDestroy(playerid, PlayerText:StatusBox[playerid]);
PlayerTextDrawDestroy(playerid, PlayerText:StatusInfo[playerid]);
PlayerTextDrawDestroy(playerid, PlayerText:StatusMatou[playerid]);
PlayerTextDrawDestroy(playerid, PlayerText:StatusMorreu[playerid]);

//OnPlayerSpawn
PlayerTextDrawShow(playerid, PlayerText:StatusBox[playerid]);
PlayerTextDrawShow(playerid, PlayerText:StatusInfo[playerid]);
PlayerTextDrawShow(playerid, PlayerText:StatusMatou[playerid]);
PlayerTextDrawShow(playerid, PlayerText:StatusMorreu[playerid]);

//Onplayerdeath
pStats[playerid][pMorreu]++;
if(killerid != 0xFFFF)
{
pStats[killerid][pMatou]++;
}

public UpdateText(playerid)
{
new
str[128];

format(str, sizeof(str), "Matou: ~h~~g~%d", pStats[playerid][pMatou]);
PlayerTextDrawSetString(playerid, StatusMatou[playerid], str);
format(str, sizeof(str), "Morreu: ~h~~r~%d", pStats[playerid][pMorreu]);
PlayerTextDrawSetString(playerid, StatusMorreu[playerid], str);
return 1;
}

ME AJUDEM POR FAVOR ;-;
o textdraw sу aparece para o ID 0 quem souber agradeзo


Re: TextDraw bugado ' -' - ViniBorn - 29.03.2017

pawn Код:
SetTimer("UpdateText",1000,true);

public UpdateText(playerid)
Fazendo isso, o parвmetro playerid vai ser sempre 0, pois o SetTimer nгo traz a possibilidade de fornecer valores а funзгo desejada, ao contrбrio do SetTimerEx


Ou vocк usa SetTimerEx em OnPlayerConnect, ou usa um loop em UpdateText, embora a terceira opзгo que vou citar, seja a mais indicada.

Basta atualizar o TextDraw apenas quando o valor mudar, e nгo a cada segundo.


Re: TextDraw bugado ' -' - ThiagoGamemodes - 29.03.2017

Obrigado, e como posso fazer para atualizar o textdraw apenas quando alterar algo ?


Re: TextDraw bugado ' -' - ThiagoGamemodes - 29.03.2017

Quote:
Originally Posted by ViniBorn
Посмотреть сообщение
pawn Код:
SetTimer("UpdateText",1000,true);

public UpdateText(playerid)
Fazendo isso, o parвmetro playerid vai ser sempre 0, pois o SetTimer nгo traz a possibilidade de fornecer valores а funзгo desejada, ao contrбrio do SetTimerEx


Ou vocк usa SetTimerEx em OnPlayerConnect, ou usa um loop em UpdateText, embora a terceira opзгo que vou citar, seja a mais indicada.

Basta atualizar o TextDraw apenas quando o valor mudar, e nгo a cada segundo.
Manolo como posso atualizar o textdraw apenas quando o valor muda ?!


Re: TextDraw bugado ' -' - Rato22 - 29.03.2017

Amigo, pхem o SetTimer("UpdateText",1000,true); junto com os outros Timers !


Re: TextDraw bugado ' -' - ThiagoGamemodes - 29.03.2017

mas o mano ViniBorn citou que SetTimer nгo й recomendado, ele diz que o certo й fazer um loop, utilizar SetTimerEx ou atualizar o textdraw apenas quando o valor mudar, se vocк souber utilizar o SetTimerEx ou fazer para atualizar o textdraw quando o valor mudar agradeзo !


Re: TextDraw bugado ' -' - ViniBorn - 29.03.2017

Para esse sistema de Kills, especificamente, coloca pra atualizar em OnPlayerDeath.

Com isso vocк nem vai precisar de timers


Re: TextDraw bugado ' -' - ThiagoGamemodes - 29.03.2017

Quote:
Originally Posted by ViniBorn
Посмотреть сообщение
Para esse sistema de Kills, especificamente, coloca pra atualizar em OnPlayerDeath.

Com isso vocк nem vai precisar de timers
Certo mas como posso fazer nгo sei fazer isso manoo!!!


Re: TextDraw bugado ' -' - ThiagoGamemodes - 29.03.2017

Quote:
Originally Posted by Carlos001
Посмотреть сообщение
PHP код:
public OnPlayerSpawn(playerid)
{
    
//...
    
new str[128];
    
format(strsizeof(str), "Matou: ~h~~g~%d"pStats[playerid][pMatou]);
    
PlayerTextDrawSetString(playeridStatusMatou[playerid], str);
    
format(strsizeof(str), "Morreu: ~h~~r~%d"pStats[playerid][pMorreu]);
    
PlayerTextDrawSetString(playeridStatusMorreu[playerid], str);
    
//para quando ele nascer atualizar as TD
    
return 1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    
//...
    
new str[128];
    
format(strsizeof(str), "Matou: ~h~~g~%d"pStats[playerid][pMatou]);
    
PlayerTextDrawSetString(playeridStatusMatou[playerid], str);
    
format(strsizeof(str), "Morreu: ~h~~r~%d"pStats[playerid][pMorreu]);
    
PlayerTextDrawSetString(playeridStatusMorreu[playerid], str);
    
//Assim irar atualizar apenas quando ele morrer/matar alguem
    
return 1;

Muito obrigado !