How to insert value of GetPVarInt into a player text draw
#1

How do I insert the value of GetPVarInt in to a player text draw, I tried this but it didn't work

pawn Код:
new PlayerCashBalance[25];
format(PlayerCashBalance, sizeof(PlayerCashBalance), "Cash: %d", GetPVarInt(playerid, "Cash"));
PlayerTextDrawSetString(playerid, CashTextDraw[playerid], PlayerCashBalance);
Reply
#2

That way is correct, I usually after editing the string, I set the string and then show to player.
Reply
#3

I don't see any error there, but do you get Errors? Yes? Then post them here.
And it would be good if you give us more informations. What does it show?

Did you even used PlayerTextDrawShow()? Try printf() below PlayerTextDrawSetString() and look what comes out at console.

pawn Код:
printf("Textdrawstring: %s", PlayerCashBalance);
Reply
#4

Yeah I did use PlayerTextDrawShow(). Here's more details

My full code
pawn Код:
CashTextDraw[playerid] = CreatePlayerTextDraw(playerid, 560.0, 108.0, "Cash: 0");
PlayerTextDrawSetShadow(playerid, CashTextDraw[playerid], 1);
PlayerTextDrawAlignment(playerid, CashTextDraw[playerid], 3);
PlayerTextDrawFont(playerid, CashTextDraw[playerid], 1);
PlayerTextDrawColor(playerid, CashTextDraw[playerid], 0xFF0000AA);
PlayerTextDrawSetOutline(playerid, CashTextDraw[playerid], 1);
PlayerTextDrawShow(playerid, CashTextDraw[playerid]);

SetPVarInt(playerid, "Cash", 362528);
new PlayerCashBalance[25];
format(PlayerCashBalance, sizeof(PlayerCashBalance), "Cash: %d", GetPVarInt(playerid, "Cash"));
PlayerTextDrawSetString(playerid, CashTextDraw[playerid], PlayerCashBalance);
PlayerTextDrawShow(playerid, CashTextDraw[playerid]);
Here's the result



Here's the server log with the printf code
Код:
[22:08:02] Incoming connection: 25.23.69.146:65384
[22:08:02] [join] SlonCHL has joined the server (0:25.23.69.146)
[22:08:02] Textdrawstring: Cash: 362528
[22:09:07] [part] SlonCHL has left the server (0:1)
Reply
#5

Where have you added that part (callback)?
pawn Код:
new PlayerCashBalance[25];
format(PlayerCashBalance, sizeof(PlayerCashBalance), "Cash: %d", GetPVarInt(playerid, "Cash"));
PlayerTextDrawSetString(playerid, CashTextDraw[playerid], PlayerCashBalance);
PlayerTextDrawShow(playerid, CashTextDraw[playerid]);
Reply
#6

OnPlayerConnect but now I added a timer there

pawn Код:
CashTextDraw[playerid] = CreatePlayerTextDraw(playerid, 560.0, 100.0, "Cash: 0");
PlayerTextDrawSetShadow(playerid, CashTextDraw[playerid], 1);
PlayerTextDrawAlignment(playerid, CashTextDraw[playerid], 3);
PlayerTextDrawFont(playerid, CashTextDraw[playerid], 1);
PlayerTextDrawColor(playerid, CashTextDraw[playerid], 0xFF0000AA);
PlayerTextDrawSetOutline(playerid, CashTextDraw[playerid], 1);
PlayerTextDrawShow(playerid, CashTextDraw[playerid]);

SetPVarInt(playerid, "Cash", 362528);
SetTimerEx("UpdateCashAmount", 1500, true, "i", playerid);
pawn Код:
public UpdateCashAmount(playerid)
{
new PlayerCashBalance[25];
format(PlayerCashBalance, sizeof(PlayerCashBalance), "Cash: %d", GetPVarInt(playerid, "Cash"));
PlayerTextDrawSetString(playerid, CashTextDraw[playerid], PlayerCashBalance);
}
Reply
#7

Ok peoples, solved it. My fault
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)