Frictional Games Forum (read-only)

Full Version: Display message only when looking at an entity
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
What I want, is to make a message appear on the screen when the player looks at an entity. But when i use my script, the message is displayed two times: when the player looks at it, and when looks away from it after looking at it.Here is my script:

void OnStart ()
{
SetEntityPlayerLookAtCallback("chair", "price_chair", false);

}


void price_chair(string &in asEntity, int alState)
{
SetMessage("price", "chair", 0);
}

I tried to change "int alState" into "int 1", but then the game crashes. Anyone got an idea? C:
Try changing the false in the Callback to true. That may help.
But that would delete the callback after it gets used, and I want it to use ulimited times.
Well, that may be why it does that. I'm not certain of that, though.
You could try setting up a timer that disables the callback for say, 10 seconds after looking at it, then sets active again.
thats a good idea Big Grin thanks a lot
Or just do:

if(alState == 1)
{
SetMessage
}

if(alState == -1)
{

}
even better Smile
thanks again
Tip: If you get an error in your script (the game crashes), closely read the error, looking for numbers like (7, 2)

Then, go down to the 7th row, and look in there. That's where the problem is (I used an example here).
I tried it but it didnt work:


void price_lantern(string &in asEntity, int alState)
{
if(alState == 1)
{
SetMessage("price", "lantern", 1);
}
if(alState == -1)
{

}
}
Pages: 1 2