X4anco
Member
Posts: 157
Threads: 66
Joined: Apr 2011
Reputation:
0
Multiple problems
Hello people
I have 2 problems but I am sure you can help:
Problem 1:
I want text to appear when the player looks at something, but nothing happens
SetEntityPlayerLookAtCallback("1", "lookat1", false);
SetEntityPlayerLookAtCallback("2", "lookat2", false);
SetEntityPlayerLookAtCallback("3", "lookat3", false);
SetEntityPlayerLookAtCallback("4", "lookat4", false);
void lookat1(string &in entity, string &in type)
{
SetMessage("Message", "look1", 2);
}
void lookat2(string &in entity, string &in type)
{
SetMessage("Message", "look2", 2);
}
void lookat3(string &in entity, string &in type)
{
SetMessage("Message", "look3", 2);
}
void lookat4(string &in entity, string &in type)
{
SetMessage("Message", "look4", 2);
}
<Entry Name="look1">Lever 1</Entry>
<Entry Name="look2">Lever 2</Entry>
<Entry Name="look3">Lever 3</Entry>
<Entry Name="look4">Lever 4</Entry>
And problem 2 is:
How would I get a variable to increase as they pull the levers in the right order but if they pull the wrong one the variable goes back to 0?
Thank-you
...
05-18-2011, 04:42 PM
Acies
Posting Freak
Posts: 1,643
Threads: 60
Joined: Feb 2011
Reputation:
73
RE: Multiple problems
Lever:
if(alState == -1) && GetLocalVarInt("LeverX")==0) // Correct pull
{
SetLeverStuckState("LeverName", asalState, false);
AddLocalVarInt("LeverX", 1);
PlayGuiSound("CorrectSound", 0.8f);
return;
}
else if (alState == 1) && GetLocalVarInt("LeverX")==0) // Correct pull
{
SetLeverStuckState("LeverName", asalState, false);
AddLocalVarInt("LeverX", 1);
PlayGuiSound("CorrectSound", 0.8f);
return;
}
else
SetLocalVarInt("LeverX", 0);
PlayGuiSound("WrongSound", 0.8f);
//Reset levers to state 0?
}
If there was some way to reset the levers to state 0, that would be good to add.
Looking:
if(alState == -1); // not looking
else if (alState == 1); // looking
Example:
void lookat1(string &in entity, string &in type)
{
if(alState == -1); // not looking
else if (alState == 1) SetMessage("Message", "look1", 2); // looking
}
Not sure of the lever stuff. Almost sure something is wrong there.
ジ
(This post was last modified: 05-18-2011, 05:40 PM by Acies .)
05-18-2011, 05:29 PM
X4anco
Member
Posts: 157
Threads: 66
Joined: Apr 2011
Reputation:
0
RE: Multiple problems
(05-18-2011, 05:29 PM) Acies Wrote: Both of your questions can be answered with this part of a script:
if(alState == -1); // Wrong pull
else if (alState == 1); // Correct pull
if(alState == -1); // not looking
else if (alState == 1); // looking
Example:
void lookat1(string &in entity, string &in type)
{
if(alState == -1); // not looking
else if (alState == 1) SetMessage("Message", "look1", 2); // looking
}
How would I get a variable to count
...
05-18-2011, 05:32 PM
Acies
Posting Freak
Posts: 1,643
Threads: 60
Joined: Feb 2011
Reputation:
73
RE: Multiple problems
Updated my first post to fit your script better
ジ
05-18-2011, 05:57 PM
X4anco
Member
Posts: 157
Threads: 66
Joined: Apr 2011
Reputation:
0
RE: Multiple problems
(05-18-2011, 05:57 PM) Acies Wrote: Updated my first post to fit your script better
What function should I use
...
05-18-2011, 06:03 PM
Acies
Posting Freak
Posts: 1,643
Threads: 60
Joined: Feb 2011
Reputation:
73
RE: Multiple problems
Spoiler below!
Entity tab on your lever --> ConnectionStateChangeCallback --> "PullLever1"
void PullLever1(string &in EntityName, int alState)
{
if(alState == -1) && GetLocalVarInt("LeverX")==0) // Correct pull
{
SetLeverStuckState("LeverName", asalState, false);
AddLocalVarInt("LeverX", 1);
PlayGuiSound("CorrectSound", 0.8f);
return;
}
else if (alState == 1) && GetLocalVarInt("LeverX")==0) // Correct pull
{
SetLeverStuckState("LeverName", asalState, false);
AddLocalVarInt("LeverX", 1);
PlayGuiSound("CorrectSound", 0.8f);
return;
}
else
SetLocalVarInt("LeverX", 0);
PlayGuiSound("WrongSound", 0.8f);
//Reset levers to state 0?
}
}
However, there is more work to the script. It doesn't work as it is.
ジ
(This post was last modified: 05-18-2011, 06:09 PM by Acies .)
05-18-2011, 06:08 PM
X4anco
Member
Posts: 157
Threads: 66
Joined: Apr 2011
Reputation:
0
RE: Multiple problems
I'm getting Expected expression value error
(73,19)
(80,1)
(87,1)
...
05-18-2011, 06:15 PM
Acies
Posting Freak
Posts: 1,643
Threads: 60
Joined: Feb 2011
Reputation:
73
RE: Multiple problems
Spoiler below!
Entity tab on your lever --> ConnectionStateChangeCallback --> "PullLever1"
void PullLever1(string &in EntityName, int alState)
{
if(alState == -1) && GetLocalVarInt("LeverX")==0) // Correct pull
{
SetLeverStuckState("LeverName", -1, false);
AddLocalVarInt("LeverX", 1);
PlayGuiSound("CorrectSound", 0.8f);
return;
}
else if (alState == 1) && GetLocalVarInt("LeverX")==0) // Correct pull
{
SetLeverStuckState("LeverName", 1, false);
AddLocalVarInt("LeverX", 1);
PlayGuiSound("CorrectSound", 0.8f);
return;
}
else
SetLeverStuckState("LeverName", 0, false);
SetLeverStuckState("LeverName2", 0, false);
SetLeverStuckState("LeverName3", 0, false);
SetLeverStuckState("LeverName4", 0, false);
SetLocalVarInt("LeverX", 0);
PlayGuiSound("WrongSound", 0.8f);
//Reset levers to state 0?
}
}
This process has to be repeated for each lever. The difference will be the name as well as the variable "LeverX".
LeverX decides the order - 0 for the first, 1 for the second, 2 for the third, 3 for the fourth.
else if (alState == 1) && GetLocalVarInt("LeverX")==1) // Correct pull
else if (alState == 1) && GetLocalVarInt("LeverX")==2) // Correct pull'
Etc.
As you may notice, my scripting is kind of blunt.
ジ
(This post was last modified: 05-18-2011, 06:22 PM by Acies .)
05-18-2011, 06:18 PM
X4anco
Member
Posts: 157
Threads: 66
Joined: Apr 2011
Reputation:
0
RE: Multiple problems
Now I am getting lots of errors, I think this is a bit too complex
...
05-18-2011, 06:28 PM
Acies
Posting Freak
Posts: 1,643
Threads: 60
Joined: Feb 2011
Reputation:
73
RE: Multiple problems
I will recreate it myself when I have the time
hopefully someone talented may help you
ジ
05-18-2011, 08:21 PM