Akos115
Member
Posts: 101
Threads: 14
Joined: Aug 2012
Reputation:
0
|
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 |
|
Robby
Posting Freak
Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation:
47
|
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 |
|
Akos115
Member
Posts: 101
Threads: 14
Joined: Aug 2012
Reputation:
0
|
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 |
|
Robby
Posting Freak
Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation:
47
|
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 |
|
Statyk
Schrödinger's Mod
Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation:
241
|
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 |
|
Akos115
Member
Posts: 101
Threads: 14
Joined: Aug 2012
Reputation:
0
|
RE: Display message only when looking at an entity
thats a good idea thanks a lot
|
|
09-25-2012, 03:45 PM |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
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 |
|
Akos115
Member
Posts: 101
Threads: 14
Joined: Aug 2012
Reputation:
0
|
RE: Display message only when looking at an entity
even better
thanks again
|
|
09-25-2012, 03:56 PM |
|
Robby
Posting Freak
Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation:
47
|
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 |
|
Akos115
Member
Posts: 101
Threads: 14
Joined: Aug 2012
Reputation:
0
|
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 |
|
|