Ok i wanted to create a script that show a message in a label when i take an object and dissapears after few seconds but when i click again in the object i wanted to do another script because already got the object, but it always show the label saying "new item taken".
function hSacoLixo_Interact()
{
if (cJake.HasInventory(iPills)){
cJake.Say("There's nothing more there.");
GiveScore(-5);
GUITexto.Text = ("");}
else
cJake.Say ("I found some Sleeping pills.");
GUITexto.Text = ("New item taken.");
cJake.AddInventory (iPills);
GiveScore(5);
SetTimer(1, (5*40));
}
Thank you for the help
I think you're missing some brackets. Your current code does nothing for the 'else' condition and runs the code below it every time. Here's how the code should look:
function hSacoLixo_Interact()
{
if (cJake.HasInventory(iPills)){
cJake.Say("There's nothing more there.");
GiveScore(-5);
GUITexto.Text = ("");
}
else {
cJake.Say ("I found some Sleeping pills.");
GUITexto.Text = ("New item taken.");
cJake.AddInventory (iPills);
GiveScore(5);
SetTimer(1, (5*40));
}
}
Yeah it works but now it keep taking 5 from my score :(
Because you subtract five points from the score with the "GiveScore(-5);" call. Unless you want to punish the player for clicking the hotspotagain after picking up the pills that line shouldn't be there at all.
Also, the way its scripted now, the player will be able to go back and pick up more pills once he uses/loses them. I don't know if that's intentional.
function hSacoLixo_Interact()
{
if (cJake.HasInventory(iPills)){
cJake.Say("There's nothing more there.");
if (Game.DoOnceOnly("pillscore")) {
GiveScore(-5);
}
GUITexto.Text = ("");
}
else {
cJake.Say ("I found some Sleeping pills.");
GUITexto.Text = ("New item taken.");
cJake.AddInventory (iPills);
GiveScore(5);
SetTimer(1, (5*40));
}
}
That should do it.
It worked ;) thank you a lot :D