Update3DTextLabel [+REP]
#1

Hi guys,
I'd like to know how to refresh a textlabel without making it disappear.
If I wasnt clear enough, I'm using a timer system to update stats for warehouses.

It's supposed to update the text label of a warehouse and present the new stats of it(lead and metal), however when I reload a warehouse by using the following stock: ReloadWH(), it makes the label disappear and reappear within a few seconds.

I want it to update the text label live, without making it disappear.
The following code makes the compiler crash:
PHP код:
    format(whnamezsizeof(whnamez), "{40BCFF}[ %s's Warehouse ]\n{AECDE6}Level: {40BCFF}%d\n{AECDE6}Lead: {40BCFF}%s\n{AECDE6}Metal: {40BCFF}%s\n{AECDE6}Materials: {40BCFF}%s"wh[i][whname],wh[i][whlevel],number_format(wh[i][whlead]),number_format(wh[i][whmetal]),number_format(wh[i][whmaterials]), wh[i][outx],wh[i][outy],wh[i][outz]);
    
Update3DTextLabel(wh[i][whlabel], COLOR_WHITEwhnamez); 
Anywho, here's the textlabel lines in the stock:
PHP код:
stock ReloadWH(i)
{
....
    new 
whnamez[MAX_STRING];
    
format(whnamezsizeof(whnamez), "{40BCFF}[ %s's Warehouse ]\n{AECDE6}Level: {40BCFF}%d\n{AECDE6}Lead: {40BCFF}%s\n{AECDE6}Metal: {40BCFF}%s\n{AECDE6}Materials: {40BCFF}%s"wh[i][whname],wh[i][whlevel],number_format(wh[i][whlead]),number_format(wh[i][whmetal]),number_format(wh[i][whmaterials]), wh[i][outx],wh[i][outy],wh[i][outz]);
    
wh[i][whlabel] = CreateDynamic3DTextLabel(whnamezCOLOR_WHITEwh[i][outx],wh[i][outy],wh[i][outz]+0.630);

so if you still didnt understand what I'm trying to do - I'm trying to make a text label update itself without disappearing for a few seconds. The text label is the following:
PHP код:
    new whnamez[MAX_STRING];
    
format(whnamezsizeof(whnamez), "{40BCFF}[ %s's Warehouse ]\n{AECDE6}Level: {40BCFF}%d\n{AECDE6}Lead: {40BCFF}%s\n{AECDE6}Metal: {40BCFF}%s\n{AECDE6}Materials: {40BCFF}%s"wh[i][whname],wh[i][whlevel],number_format(wh[i][whlead]),number_format(wh[i][whmetal]),number_format(wh[i][whmaterials]), wh[i][outx],wh[i][outy],wh[i][outz]);
    
wh[i][whlabel] = CreateDynamic3DTextLabel(whnamezCOLOR_WHITEwh[i][outx],wh[i][outy],wh[i][outz]+0.630);

+REPing the helper
Reply
#2

I managed to fix the problem on which the pawn compiler crashes(Changed the Update3DTextLabel to Dynamic)
but it still doesn't update them live, I have to reload them or smth by moving them or using the stock..
Reply
#3

BUMP?
Reply
#4

I belive making the label disappear and appear is the only way to update a 3DTextLabel.
Reply
#5

I have seen on other servers text labels which update live, at least so it seems
Reply
#6

Quote:
Originally Posted by Amit1998
Посмотреть сообщение
I managed to fix the problem on which the pawn compiler crashes(Changed the Update3DTextLabel to Dynamic)
but it still doesn't update them live, I have to reload them or smth by moving them or using the stock..
To solve this you should understand how streamer works, it won't update anything for you unless you move(or do something, I'm not exactly sure about this part)
Therefore all you need to do is put a Streamer_Update(playerid, STREAMER_TYPE_3D_TEXT_LABEL); and loop it for everyone (or everyone near, as you wish) so it gets update for those near the 3D text label.
Reply
#7

If I can ask, why would you use a timer to update it, when you can update it at the time it is changed. On the other hand, yes, your way is completely possible just that you probably made a mistake somewhere, I will check it later and I will get back to you.

Edit: Some mistakes I found, you are trying to update dynamic label with a code for a non-dynamic. On the reloadwh function you are just creating a new label without destroying it first, which woulld cause the IDs to overlap eachother and the old one would be unobtainable because a new one would be there however the old one would still be present and it would be colliding with the new one.
Reply
#8

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
To solve this you should understand how streamer works, it won't update anything for you unless you move(or do something, I'm not exactly sure about this part)
Therefore all you need to do is put a Streamer_Update(playerid, STREAMER_TYPE_3D_TEXT_LABEL); and loop it for everyone (or everyone near, as you wish) so it gets update for those near the 3D text label.
What an excellent tip. Used it and it works, thank you mate! <:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)