textdraw problem
#1

Hello,i created this small textdraw to show at bottom of the screen the player wanted level.But doesnt work.
pawn Код:
[new Text:WantedTxd0;
new Text:WantedTxd1;
OnGameModeInit:

pawn Код:
WantedTxd0 = TextDrawCreate(526.000000, 430.000000, "Wanted Level:");
    TextDrawBackgroundColor(WantedTxd0, 255);
    TextDrawFont(WantedTxd0, 3);
    TextDrawLetterSize(WantedTxd0, 0.320000, 1.100000);
    TextDrawColor(WantedTxd0, -16776961);
    TextDrawSetOutline(WantedTxd0, 1);
    TextDrawSetProportional(WantedTxd0, 1);

    WantedTxd1 = TextDrawCreate(621.000000, 430.000000, "0");
    TextDrawBackgroundColor(WantedTxd1, 255);
    TextDrawFont(WantedTxd1, 3);
    TextDrawLetterSize(WantedTxd1, 0.320000, 1.100000);
    TextDrawColor(WantedTxd1, -16776961);
    TextDrawSetOutline(WantedTxd1, 1);
    TextDrawSetProportional(WantedTxd1, 1);
OnPlayerConnect:

pawn Код:
TextDrawShowForPlayer(playerid, WantedTxd0);
    TextDrawShowForPlayer(playerid, WantedTxd1);
   
    new wantedtext[20];
    GetPlayerWantedLevel(playerid);
    format(wantedtext, sizeof(wantedtext), "%d",PlayerInfo[playerid][pWantedLevel]);
    TextDrawSetString(WantedTxd1, wantedtext);
I tried with a wanted level and it shows only Wanted Level: 0

Why??

P.S PlayerInfo[playerid][pWantedLevel] is the function i use to save wanted level.
Reply
#2

Wouldn't be :
pawn Код:
new wantedtext[20];
format(wantedtext, sizeof(wantedtext), "%d",GetPlayerWantedLevel(playerid));
TextDrawSetString(WantedTxd1, wantedtext);
Reply
#3

Already tried and it doesnt work...
Reply
#4

You're creating ONE GLOBAL textdraw. You need to create it per-player.
Reply
#5

Quote:
Originally Posted by MP2
Посмотреть сообщение
You're creating ONE GLOBAL textdraw. You need to create it per-player.
So i need to use a loop?
Reply
#6

PlayerInfo[playerid][pWantedLevel] is loaded when player connect?

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
So i need to use a loop?
Yes.
Reply
#7

No you don't need to use a loop. You need to have an array to store the textdraw ID in, you need to create it under OnPlayerConnect, destroy it under OnPlayerDisconnect and update it when you set their wanted level.
Reply
#8

Quote:
Originally Posted by MP2
Посмотреть сообщение
No you don't need to use a loop. You need to have an array to store the textdraw ID in, you need to create it under OnPlayerConnect, destroy it under OnPlayerDisconnect and update it when you set their wanted level.
I already destroy the textdraw at onplayerdisconnect,and for updating it,that's why i used pWantedLevel because it autoupdates at the players stats.

Can you show me an example about the array to store the textdraw id?

Quote:

@Viniborn: PlayerInfo[playerid][pWantedLevel] is loaded when player connect?

It loads after a player login (when a player connects it asks for login in account).
Reply
#9

Bump.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)