PDA

View Full Version : player 3dlabel


iBots
15/05/2014, 11:37 AM
i have something,when player connects it makes a label and attaches it to you,when you click on lmb it changes the string to +1,each time you click it changes and gets +1 clicks,the label shows how many clicks you have,but it works fine till i reach 10 clicks then i get two labels on me and it gets hard to see,how can i make it update the string to the amount of the clicks and works right?
code:

clicktag[playerid] = Create3DTextLabel("Clicks ", COLOR_WHITE, 30.0, 40.0, 50.0, 40.0, 0, 0);
Attach3DTextLabelToPlayer(clicktag[playerid], playerid, 0.0, 0.0, 0.5);

and onplayerkeystatechange:"

Clicks[playerid] += 1;

Smileys
15/05/2014, 12:08 PM
can you show us your entire code, because I don't see how you're showing the amount of clicks in 3d label here; seems like you only posted half of the code

iBots
15/05/2014, 01:00 PM
listen,i just made it when you click under onplayerkeystatechange it makes Clicks for you +1,and each 1 second it updates the label,but it doesnt work good,it reaches 10 clicks then the label gets bugged,how can i make a good one?

ball
15/05/2014, 02:19 PM
clicktag[playerid] = Create3DTextLabel("Clicks ", COLOR_WHITE, 30.0, 40.0, 50.0, 40.0, 0, 0);
Attach3DTextLabelToPlayer(clicktag[playerid], playerid, 0.0, 0.0, 0.5);

This code you should enter in OnPlayerConnect. In timer you should use Update3DTextLabelText function

new s[32];
format(s, 32, "Clicks: %d", Clicks[playerid]);
Update3DTextLabelText(...);

iBots
15/05/2014, 02:22 PM
i tried like that but when it reach 10 clicks it gets bugged,and i made onplayerdisconnect/connect to make it 0,but still when i relog it writes the same clicks i had,could you create one for me?

ball
15/05/2014, 02:26 PM
You have to destroy player label in OnPlayerDisconnect

Delete3DTextLabel(clicktag[playerid]);

iBots
15/05/2014, 02:27 PM
already did but doesnt work,can you make one from the beginning for me?

ball
15/05/2014, 02:38 PM
In my code i have Delete3DTextLabel used two times - in OnPlayerConnect and OnPlayerDisconnect

//OnPlayerConnect
Delete3DTextLabel(pLabel[playerid][0]);
pLabel[playerid][0] = Create3DTextLabel(pName[playerid], 0xFFFFFFFF, 0.0, 0.0, 0.25, 12.5, -1);
return Attach3DTextLabelToPlayer(pLabel[playerid][0], playerid, 0.0, 0.0, -0.65);

//OnPlayerDisconnect
Delete3DTextLabel(pLabel[playerid][0]);

//In some timer
Update3DTextLabelText(...);

And for me it works good - never get bugged.