TextLabel wont delete - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: TextLabel wont delete (
/showthread.php?tid=528165)
TextLabel wont delete -
jackx3rx - 26.07.2014
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;
}
}
Re: TextLabel wont delete -
Konstantinos - 26.07.2014
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.
Re: TextLabel wont delete -
jackx3rx - 26.07.2014
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.
Re: TextLabel wont delete -
[KHK]Khalid - 26.07.2014
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;
}
Re: TextLabel wont delete -
Konstantinos - 26.07.2014
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.
Re: TextLabel wont delete -
[KHK]Khalid - 26.07.2014
Yeah, you can use Chat Bubble function as mentioned above. But, atleast you should learn how to use variables with timers from this.
AW: Re: TextLabel wont delete -
jackx3rx - 26.07.2014
Quote:
Originally Posted by Konstantinos
|
Thanks so much!