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



Adicionar TextDraw - SkolPlay - 28.05.2020

Bom, eu fiz um text draw de cash, dai eu queria fazer pra aparecer quantos cash o player tem

pawn Code:
Textdraw3 = TextDrawCreate(1.000000, 432.000000, "Cash:");
TextDrawBackgroundColor(Textdraw3, 255);
TextDrawFont(Textdraw3, 1);
TextDrawLetterSize(Textdraw3, 0.500000, 1.000000);
TextDrawColor(Textdraw3, -1);
TextDrawSetOutline(Textdraw3, 0);
TextDrawSetProportional(Textdraw3, 1);
TextDrawSetShadow(Textdraw3, 1);
TextDrawSetSelectable(Textdraw3, 0);
/////////////////////////////////////////////////////////////

new Cash[MAX_PLAYERS] = 0;
Cash[playerid] = (playerid,dUserINT(PlayerName(playerid)).("Cash"));
dUserSetINT(PlayerName(playerid)).("Cash",Cash[playerid]);
Cash[playerid] = 0;
Quem consegui fazer isto, recebera +REP!


Re: Adicionar TextDraw - cicinho - 28.05.2020

Й sу usar TextDrawSetString, eu te conselho em vez de usar TextDraw(global), fazer uso de PlayerTextDraw para o propуsito que vocк pretende, mostrar informaзхes pessoais.

HTML Code:
new newtext[41];
    format(newtext, 41, "Cash: %d", Cash[playerid]);
    TextDrawSetString(Textdraw3, newtext);   
    TextDrawShowForPlayer(playerid, Textdraw3);



Re: Adicionar TextDraw - SkolPlay - 28.05.2020

Quote:
Originally Posted by cicinho
View Post
Й sу usar TextDrawSetString, eu te conselho em vez de usar TextDraw(global), fazer uso de PlayerTextDraw para o propуsito que vocк pretende, mostrar informaзхes pessoais.

HTML Code:
new newtext[41];
    format(newtext, 41, "Cash: %d", Cash[playerid]);
    TextDrawSetString(Textdraw3, newtext);   
    TextDrawShowForPlayer(playerid, Textdraw3);
Funcionou certinho, mas teria como ele ser atualizado na hora que eu retirar um cash?
Se minha explicaзгo estiver ruim irei citar um exemplo.

Ex:Eu tenho 1000 cash, dai retiro 1, e ele atualizar e ficar 999

Porque ele sу estar atualizando quando eu deslogo e entro novamente


Re: Adicionar TextDraw - wearLy - 28.05.2020

PHP Code:
stock UpdatePlayerCash(playerid)
{
    new 
newtext[41];
    
    
format(newtext41"Cash: %d"Cash[playerid]);
    
TextDrawSetString(Textdraw3newtext);
}
// E usar isso em tudo que for consumir ou adicionar cash:
UpdatePlayerCash(playerid); 
Ou vocк pode usar um 'timer' de 1 segundo para atualizar constantemente (oque й o mais usado e o menos recomendado).


Re: Adicionar TextDraw - SkolPlay - 28.05.2020

Obrigado a todos que me ajudaram, funcionou perfeitamente, +REP pra ambos!


Re: Adicionar TextDraw - HelderPT - 28.05.2020

Porque nгo criou a textdraw por player?


Re: Adicionar TextDraw - SkolPlay - 28.05.2020

Quote:
Originally Posted by cicinho
View Post
Й sу usar TextDrawSetString, eu te conselho em vez de usar TextDraw(global), fazer uso de PlayerTextDraw para o propуsito que vocк pretende, mostrar informaзхes pessoais.

HTML Code:
new newtext[41];
    format(newtext, 41, "Cash: %d", Cash[playerid]);
    TextDrawSetString(Textdraw3, newtext);   
    TextDrawShowForPlayer(playerid, Textdraw3);
Aconteceu um problema. Se um player que estiver logado tenha 5 cash e outro que tiver entrando tiver 0, acaba setando 0 pra todo mundo


Re: Adicionar TextDraw - SkolPlay - 28.05.2020

Quote:
Originally Posted by HelderPT
View Post
Porque nгo criou a textdraw por player?
Sou muito noob em pawn e muito mais em textdraw kkk, como que faz isso ?


Re: Adicionar TextDraw - cicinho - 28.05.2020

Quote:
Originally Posted by SkolPlay
View Post
Sou muito noob em pawn e muito mais em textdraw kkk, como que faz isso ?
Tente:

PHP Code:
new PlayerText:TextCash[MAX_PLAYERS],
    
Timer[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
TextCash[playerid] = CreatePlayerTextDraw(playerid1.000000432.000000"Cash");
    
PlayerTextDrawLetterSize(playeridTextCash[playerid], 0.5000001.000000);
    
PlayerTextDrawAlignment(playeridTextCash[playerid], 2);
    
PlayerTextDrawColor(playeridTextCash[playerid], -1);
    
PlayerTextDrawSetShadow(playeridTextCash[playerid], 0);
    
PlayerTextDrawSetOutline(playeridTextCash[playerid], 1);
    
PlayerTextDrawBackgroundColor(playeridTextCash[playerid], 255);
    
PlayerTextDrawFont(playeridTextCash[playerid], 2);
    
PlayerTextDrawSetProportional(playeridTextCash[playerid], 1);
    
TextDrawShowForPlayer(playeridTextCash[playerid]);
    
    
    
Timer[playerid] = SetTimerEx("AtualizarCash"1000true"i"playerid);
    return 
true;
}
forward AtualizarCash(playerid);
public 
AtualizarCash(playerid)
{
    new 
String[36];
    
format(String36"Cash: %d, "Cash[playerid]);
    
PlayerTextDrawSetString(playeridTextCash[playerid], String);
    return 
true;
}
public 
OnPlayerDisconnect(playerid)
{
    
KillTimer(Timer[playerid]);
    return 
true;




Re: Adicionar TextDraw - SkolPlay - 29.05.2020

Quote:
Originally Posted by cicinho
View Post
Tente:

PHP Code:
new PlayerText:TextCash[MAX_PLAYERS],
    
Timer[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
TextCash[playerid] = CreatePlayerTextDraw(playerid1.000000432.000000"Cash");
    
PlayerTextDrawLetterSize(playeridTextCash[playerid], 0.5000001.000000);
    
PlayerTextDrawAlignment(playeridTextCash[playerid], 2);
    
PlayerTextDrawColor(playeridTextCash[playerid], -1);
    
PlayerTextDrawSetShadow(playeridTextCash[playerid], 0);
    
PlayerTextDrawSetOutline(playeridTextCash[playerid], 1);
    
PlayerTextDrawBackgroundColor(playeridTextCash[playerid], 255);
    
PlayerTextDrawFont(playeridTextCash[playerid], 2);
    
PlayerTextDrawSetProportional(playeridTextCash[playerid], 1);
    
TextDrawShowForPlayer(playeridTextCash[playerid]);
    
    
    
Timer[playerid] = SetTimerEx("AtualizarCash"1000true"i"playerid);
    return 
true;
}
forward AtualizarCash(playerid);
public 
AtualizarCash(playerid)
{
    new 
String[36];
    
format(String36"Cash: %d, "Cash[playerid]);
    
PlayerTextDrawSetString(playeridTextCash[playerid], String);
    return 
true;
}
public 
OnPlayerDisconnect(playerid)
{
    
KillTimer(Timer[playerid]);
    return 
true;

Agora nгo estб mostrando o textdraw na tela...
E quando copila, aparece isto: (14067) warning 213: tag mismatch

pawn Code:
(14067)TextDrawShowForPlayer(playerid, TextCash[playerid]);