Frictional Games Forum (read-only)

Full Version: Multiple problems
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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

Code:
    SetEntityPlayerLookAtCallback("1", "lookat1", false);
    SetEntityPlayerLookAtCallback("2", "lookat2", false);
    SetEntityPlayerLookAtCallback("3", "lookat3", false);
    SetEntityPlayerLookAtCallback("4", "lookat4", false);

Code:
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);
}
Code:
    <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 Big GrinCoolBig GrinCool
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.
(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
Updated my first post to fit your script better Smile
(05-18-2011, 05:57 PM)Acies Wrote: [ -> ]Updated my first post to fit your script better Smile

What function should I use Huh
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.
I'm getting Expected expression value error
(73,19)
(80,1)
(87,1)
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.
Now I am getting lots of errors, I think this is a bit too complex
I will recreate it myself when I have the time Smile hopefully someone talented may help you
Pages: 1 2