SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Português/Portuguese

Reply
 
Thread Tools Display Modes
Old 28/05/2020, 03:32 PM   #1
SkolPlay
Big Clucker
 
Join Date: Aug 2016
Posts: 130
Reputation: 0
Default Adicionar TextDraw

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!
SkolPlay is offline   Reply With Quote
Old 28/05/2020, 03:59 PM   #2
cicinho
Huge Clucker
 
cicinho's Avatar
 
Join Date: Feb 2015
Location: Brasil - Alagoas
Posts: 251
Reputation: 8
Default Re: Adicionar TextDraw

É 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);
cicinho is offline   Reply With Quote
Old 28/05/2020, 04:38 PM   #3
SkolPlay
Big Clucker
 
Join Date: Aug 2016
Posts: 130
Reputation: 0
Default Re: Adicionar TextDraw

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
SkolPlay is offline   Reply With Quote
Old 28/05/2020, 04:41 PM   #4
wearLy
Big Clucker
 
wearLy's Avatar
 
Join Date: Jun 2018
Location: SA-MP
Posts: 154
Reputation: 31
Default Re: Adicionar TextDraw

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).
__________________
_______


» [FilterScript] Sistema Anti-AFK


» Adeus ao meu Brasil Play Start


"In the community since 2010"
wearLy is offline   Reply With Quote
Old 28/05/2020, 05:42 PM   #5
SkolPlay
Big Clucker
 
Join Date: Aug 2016
Posts: 130
Reputation: 0
Default Re: Adicionar TextDraw

Obrigado a todos que me ajudaram, funcionou perfeitamente, +REP pra ambos!
SkolPlay is offline   Reply With Quote
Old 28/05/2020, 07:19 PM   #6
HelderPT
Banned
 
Join Date: Jan 2018
Location: São Miguel, Portugal
Posts: 607
Reputation: 22
Default Re: Adicionar TextDraw

Porque não criou a textdraw por player?
HelderPT is offline   Reply With Quote
Old 28/05/2020, 08:34 PM   #7
SkolPlay
Big Clucker
 
Join Date: Aug 2016
Posts: 130
Reputation: 0
Default Re: Adicionar TextDraw

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
SkolPlay is offline   Reply With Quote
Old 28/05/2020, 08:38 PM   #8
SkolPlay
Big Clucker
 
Join Date: Aug 2016
Posts: 130
Reputation: 0
Default Re: Adicionar TextDraw

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 ?
SkolPlay is offline   Reply With Quote
Old 28/05/2020, 09:50 PM   #9
cicinho
Huge Clucker
 
cicinho's Avatar
 
Join Date: Feb 2015
Location: Brasil - Alagoas
Posts: 251
Reputation: 8
Default Re: Adicionar TextDraw

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;

cicinho is offline   Reply With Quote
Old 29/05/2020, 05:40 PM   #10
SkolPlay
Big Clucker
 
Join Date: Aug 2016
Posts: 130
Reputation: 0
Default Re: Adicionar TextDraw

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]);
SkolPlay is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Ajuda] Adicionar linha... Ley Português/Portuguese 4 06/03/2018 12:38 AM
Adicionar CMD: Jetpack maicon098 Português/Portuguese 3 14/01/2017 12:33 PM
[Ajuda] adicionar um 1 mes + LocoGamer Português/Portuguese 4 05/03/2015 02:38 PM
[Ajuda] Adicionar gasolina e o sv cai... eNtinityGaming Português/Portuguese 3 19/02/2014 10:14 PM
[Ajuda] Adicionar euros goldspy98 Português/Portuguese 0 17/07/2013 09:28 PM


All times are GMT. The time now is 06:54 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.