Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display message only when looking at an entity
Akos115 Offline
Member

Posts: 101
Threads: 14
Joined: Aug 2012
Reputation: 0
#1
Display message only when looking at an entity

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:

09-25-2012, 03:33 PM
Find
Robby Offline
Posting Freak

Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation: 47
#2
RE: Display message only when looking at an entity

Try changing the false in the Callback to true. That may help.

Infrequently active. Don't expect an immediate response. Best to contact me at a different locale. If I create a thread, expect me to be quite active.
09-25-2012, 03:36 PM
Website Find
Akos115 Offline
Member

Posts: 101
Threads: 14
Joined: Aug 2012
Reputation: 0
#3
RE: Display message only when looking at an entity

But that would delete the callback after it gets used, and I want it to use ulimited times.

09-25-2012, 03:40 PM
Find
Robby Offline
Posting Freak

Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation: 47
#4
RE: Display message only when looking at an entity

Well, that may be why it does that. I'm not certain of that, though.

Infrequently active. Don't expect an immediate response. Best to contact me at a different locale. If I create a thread, expect me to be quite active.
09-25-2012, 03:41 PM
Website Find
Statyk Offline
Schrödinger's Mod

Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation: 241
#5
RE: Display message only when looking at an entity

You could try setting up a timer that disables the callback for say, 10 seconds after looking at it, then sets active again.
09-25-2012, 03:44 PM
Find
Akos115 Offline
Member

Posts: 101
Threads: 14
Joined: Aug 2012
Reputation: 0
#6
RE: Display message only when looking at an entity

thats a good idea Big Grin thanks a lot

09-25-2012, 03:45 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#7
RE: Display message only when looking at an entity

Or just do:

if(alState == 1)
{
SetMessage
}

if(alState == -1)
{

}

Trying is the first step to success.
09-25-2012, 03:53 PM
Find
Akos115 Offline
Member

Posts: 101
Threads: 14
Joined: Aug 2012
Reputation: 0
#8
RE: Display message only when looking at an entity

even better Smile
thanks again

09-25-2012, 03:56 PM
Find
Robby Offline
Posting Freak

Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation: 47
#9
RE: Display message only when looking at an entity

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).

Infrequently active. Don't expect an immediate response. Best to contact me at a different locale. If I create a thread, expect me to be quite active.
09-25-2012, 04:00 PM
Website Find
Akos115 Offline
Member

Posts: 101
Threads: 14
Joined: Aug 2012
Reputation: 0
#10
RE: Display message only when looking at an entity

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)
{

}
}

09-25-2012, 04:05 PM
Find




Users browsing this thread: 1 Guest(s)