TextLabel wont delete
#1

I'm making my own RP script, when a player types in the chat it displays a TextLabel above the players head.. however once 5000 ticks (5 seconds) passes it doesn't delete the textlabel?

Here is the code:
Код:
public OnPlayerText(playerid, text[])
{
	new string[128];
	format(string,sizeof(string),"%s: %s",RemoveUnderScore(playerid),text);
	ProxDetector(30,playerid,string,CHATFADE_1,CHATFADE_2,CHATFADE_3,CHATFADE_4,CHATFADE_5);
	{
		new Text3D:chatlabel = Create3DTextLabel(string,CHATFADE_1,0,0,0,30,GetPlayerVirtualWorld(playerid),0);
		Attach3DTextLabelToPlayer(chatlabel,playerid,0,0,0.7);
		SetTimer("Delete3DTextLabel(chatlabel)",5000,false);
		return 1;
	}
}
Reply
#2

How is it supposed to delete the 3D label when its ID is unknown? You should either store it on an array and pass the player's ID in the timer's callback parameters so you'll get the value of the array for that index or pass the 3D label ID directly.

However, I find chat bubble easier to be used for that purpose.
Reply
#3

I have no idea what you mean by 'store it on an array'.

Chat bubble? What is that? Does that display the chat above the players head? That's what I'd like.
Reply
#4

You don't use SetTimer like this and this is not how you pass variables through timers. You should of used SetTimerEx

pawn Код:
SetTimerEx("DeleteIt", 5000, false, "i", chatlabel); // Calls "DeleteIt" after 5 seconds and passes 'chatlabel' to the function


forward DeleteIt(id); // just forwarding
public DeleteIt(id) // here id is the text label id which you passed before
{
    Delete3DTextLabel(id); // deletes it
    return 1;
}
Reply
#5

https://sampwiki.blast.hk/wiki/SetPlayerChatBubble

It has also expire time as parameter - basically what you're looking for.

@[KHK]Khalid: That way, you'd need to use the correct tag and _: to pass the 3D label ID as argument.
Reply
#6

Yeah, you can use Chat Bubble function as mentioned above. But, atleast you should learn how to use variables with timers from this.
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/SetPlayerChatBubble

It has also expire time as parameter - basically what you're looking for.

@[KHK]Khalid: That way, you'd need to use the correct tag and _: to pass the 3D label ID as argument.
Thanks so much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)