Frictional Games Forum (read-only)
"if" help ( again -_-'' ) - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: "if" help ( again -_-'' ) (/thread-20419.html)



"if" help ( again -_-'' ) - tonitoni1998 - 02-20-2013

Code:
void CompleteOilQuest(string &in asEntity)
{
    CompleteQuest("oil_quest", "Quest_OilQuest_Text");
    
    if(GetPlayerLampOil == 0f)
    {
    SetMessage("map2_messages", "QuestOilDone1");
    }
    else if(GetPlayerLampOil > 0f && (GetPlayerLampOil) <= 5f)
    {
        SetMessage("map2_messages", "QuestOilDone2");
    }
    else if(GetPlayerLampOil > 5f && (GetPlayerLampOil) < 12.5f)
    {
        SetMessage("map2_messages", "QuestOilDone3");
    }
    else if(GetPlayerLampOil == 12.5f)
    {
        SetMessage("map2_messages", "QuestOilDone4");
    }
}

i always get error messages ( http://imgur.com/aW6BhjZ ) here. where is my problem? it doesnt look different in the wiki.

thanks


RE: "if" help ( again -_-'' ) - OriginalUsername - 02-20-2013

Code:
void CompleteOilQuest(string &in asEntity)
{
    CompleteQuest("oil_quest", "Quest_OilQuest_Text");
    
    if(GetPlayerLampOil == 0f)
{
    SetMessage("map2_messages", "QuestOilDone1");
}
else
{
    
    if(GetPlayerLampOil > 0f && (GetPlayerLampOil) <= 5f)
{
SetMessage("map2_messages", "QuestOilDone2");
}
else
{
        if(GetPlayerLampOil > 5f && (GetPlayerLampOil) < 12.5f)
    {
    SetMessage("map2_messages", "QuestOilDone3");
    }
    else
    {
if(GetPlayerLampOil == 12.5f)
    {
        SetMessage("map2_messages", "QuestOilDone4");
    }
}}}}

That should do it. I'm not sure though


RE: "if" help ( again -_-'' ) - tonitoni1998 - 02-20-2013

nope. sr doesnt work :/


RE: "if" help ( again -_-'' ) - Adrianis - 02-20-2013

It should be 'GetPlayerLampOil() == 0' etc, instead of 'GetPlayerLampOil== 0' etc...

Also, if you could say what your trying to do, and the error that comes up when you try it, that would be very helpful for us


RE: "if" help ( again -_-'' ) - tonitoni1998 - 02-20-2013

i already tried it Sad

the player gets a quest when he picks up a lantern (that will give him 12.5 oil). this quest leads him to the basement where he will look for some more oil. when he is at the basement and picks the oil up, he will get a message that variates depending on how much oil he has left. (0, between 0 and 5, between 5 and 12.5, and 12.5)

my error message looks like this:
http://imgur.com/aW6BhjZ


RE: "if" help ( again -_-'' ) - xxxxxxxxxxxxxxxx - 02-20-2013

I'm not really good at scripting myself, so I'm not sure if I can really help. But I noticed that sometimes you're putting GetPlayerLampOil() in separate brackets and sometimes you don't. Any special reason for that? It seems to be exactly the lines that throw errors.
So maybe try this:
Code:
void CompleteOilQuest(string &in asEntity)
{
    CompleteQuest("oil_quest", "Quest_OilQuest_Text");
    
    if(GetPlayerLampOil() == 0f)
    {
    SetMessage("map2_messages", "QuestOilDone1");
    }
    else if(GetPlayerLampOil() > 0f && GetPlayerLampOil() <= 5f)
    {
        SetMessage("map2_messages", "QuestOilDone2");
    }
    else if(GetPlayerLampOil() > 5f && GetPlayerLampOil() < 12.5f)
    {
        SetMessage("map2_messages", "QuestOilDone3");
    }
    else if(GetPlayerLampOil() == 12.5f)
    {
        SetMessage("map2_messages", "QuestOilDone4");
    }
}



RE: "if" help ( again -_-'' ) - MulleDK19 - 02-20-2013

0f or 5f is not valid. You must use 0.0f and 5.0f.


RE: "if" help ( again -_-'' ) - NaxEla - 02-21-2013

PHP Code:
void CompleteOilQuest(string &in asEntity)
{
    
CompleteQuest("oil_quest""Quest_OilQuest_Text");
    
    if(
GetPlayerLampOil() == 0.0f) {
        
SetMessage("map2_messages""QuestOilDone1");
    }
        
    if(
GetPlayerLampOil() > 0.0f && GetPlayerLampOil() <= 5.0f) {
        
SetMessage("map2_messages""QuestOilDone2");
    }
        
    if(
GetPlayerLampOil() > 5.0f && GetPlayerLampOil() < 12.5f) {
        
SetMessage("map2_messages""QuestOilDone3");
    }
        
    if(
GetPlayerLampOil() == 12.5f) {
        
SetMessage("map2_messages""QuestOilDone4");
    }


Try that code.

Btw, does the quest actually get completed? Because if you called the quest "OilQuest", writing "Quest_OilQuest_Text" in this line:
Code:
CompleteQuest("oil_quest", "Quest_OilQuest_Text");
will not work. It should just be:
Code:
CompleteQuest("oil_quest", "OilQuest");



RE: "if" help ( again -_-'' ) - tonitoni1998 - 02-21-2013

okay guys it works now ^^ i just did everything you said and now it works. if i can help someone with this: this is what it looks like now

Code:
void CompleteOilQuest(string &in asEntity)
{
    CompleteQuest("oil_quest", "OilQuest");
    AddPlayerSanity(30);
    PlaySoundAtEntity("", "quest_completed.snt", "Player", 0, false);
    if(GetPlayerLampOil() == 0.0f)
    {
        SetMessage("map2_messages", "OilQuestDone1", 5.0f);
    }
    else if(GetPlayerLampOil() > 0.0f && GetPlayerLampOil() <= 5.0f)
    {
        SetMessage("map2_messages", "OilQuestDone2", 5.0f);
    }
    else if(GetPlayerLampOil() > 5.0f && GetPlayerLampOil() < 12.5f)
    {
        SetMessage("map2_messages", "OilQuestDone3", 5.0f);
    }
    else if(GetPlayerLampOil() == 12.5f)
    {
        SetMessage("map2_messages", "OilQuestDone4", 5.0f);
    }
}

thanks for the help Smile