Hi, i already searhed the forum but cant find a good help for my doubt, i have a label in a GUI that display a message depending of whatI'm doing, so if i get a a item it says "New item taken" if i discovered a new place "New place discovered" i already got that to work with the script
GUITexto.Text = String.Format ("New item taken.");
For example, but now i want it to dissaper in 5 seconds and i cant do it, i know ill problably have to do something like
GUITexto.Text = String.Format ("");
but cant activate the timer, how can i do it?
Thank you
First of all you don't need String.Format() if you don't use any variables in the output.
So you can just use:
GUITexto.Text = "New item taken.";
But use String.Format, if f.e. you want to display the items name.
GUITexto.Text = String.Format("%s taken.", item.name);
To answer your question. You need to put this into repeatedly execute:
if(IsTimerExpired(1)) {
GUITexto.Text = "";
}
And then just call this after you've changed the label text:
SetTimer(1, (5*40)); // 40 loops per second
Exactly, or use a custom function:
// header (global.ash)
import void Message(String text, int timeout = 5); // default: 5 seconds
// global script (global.asc)
void Message(String text, int timeout) {
GUITexto.Text = text;
SetTimer(1, timeout*GetGameSpeed());
}
Call it like this:
Message(String.Format("%s taken.", iBox.Name));
or with a different timeout:
Message(String.Format("%s taken.", iBox.Name), 10);
Well Thank you for the help but it doesnt work, prob im doing something wrong but dont know what, i used:
function hSacoLixo_Interact() //name of the hotspot where is the object
{
if (cJake.HasInventory(iPills)) //if the char already got the object
cJake.Say("There's nothing more there.");
else
cJake.Say ("I found some Sleeping pills.");// if the char doesnt have the object
GUITexto.Text = ("New item taken."); // text appear in GUIlabel
SetTimer(1, (5*40)); //i set the timer
if(IsTimerExpired(1)) { //the timer expires
GUITexto.Text = ""; //and here the text doenst appear dont know why
}
cJake.AddInventory (iPills); //here i add the inventory
GiveScore(5); //here i give score
}
You missed the part when they said that the "if (IsTimeExpired)" line should be in the repeatedly execute function, not in the hSacoLixo_Interact function...
Sorry my fault im not understanding where is to put that script, its still put in the hotspot script or in another place? Sorry
Oh awesome already did it, thak you ;)
GUITexto.Text = ("New item taken.");
You don't need the brackets, btw.
Ok thank you again ;)