Frictional Games Forum (read-only)

Full Version: Where
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Where here error? Huh

void OnStart()
{
AddEntityCollideCallback("Player", "InsanityHall", "FuncInsanityHall", false, 0);
}

void FuncInsanityHall(string &in asParent, string &in asChild, int alState)
{
if(alState == 1) {
SetLocalVarFloat("init_sanity", GetPlayerSanity());
AddTimer("start_drain", 0.01, "SanityDrain");
}
if(alState == -1) {
SetPlayerSanity(GetLocalvarFloat("init_sanity"));
RemoveTimer("drain_loop");
RemoveTimer("start_drain");
}
}

void SanityDrain(string &in asTimer)
{
if(asTimer == "start_drain") return;
if(GetPlayerSanity() > 20) GiveSanityDamage(5, false);
AddTimer("drain_loop", 1, "SanityDrain");
}
Well, what does the error message say? It usually tells you which line doesn't work and what kind of error it is.
You should get an error message saying what line that's wrong.
(04-26-2013, 01:14 PM)Icaab2607 Wrote: [ -> ]void SanityDrain(string &in asTimer)
{
if(asTimer == "start_drain") return;
if(GetPlayerSanity() > 20) GiveSanityDamage(5, false);
AddTimer("drain_loop", 1, "SanityDrain");
}

You have an if that is not bracketed.
Try changing it to this:

PHP Code:
void SanityDrain(string &in asTimer)
{
    if(
asTimer == "start_drain") return;
    if(
GetPlayerSanity() > 20
    {
    
GiveSanityDamage(5false);
    
AddTimer("drain_loop"1"SanityDrain");
    }


And also, in your 12th line, where it says
Quote:if(alState == -1)

You can make it "else". So it looks like this:

PHP Code:
else(alState == -1
Quote:And also, in your 12th line, where it says
Quote:if(alState == -1)

You can make it "else". So it looks like this:

PHP Code:
else(alState == -1

You're thinking of else if. =p An else if statement will execute if the condition before it isn't true.

An else statement will execute if no previous condition is true.

PHP Code:
else if(alState == -1

*edit*

Just replace it with this.

PHP Code:
void FuncInsanityHall(string &in asParentstring &in asChildint alState)
{
    if(
alState == 1)
    {
        
SetLocalVarFloat("init_sanity"GetPlayerSanity());
        
AddTimer("start_drain"0.01"SanityDrain");
        
AddDebugMessage("Adding start_drain",false);
    }
    
        else if(
alState == -1)
        {
            
SetPlayerSanity(GetLocalVarFloat("init_sanity"));
            
RemoveTimer("drain_loop");
            
RemoveTimer("start_drain");
            
AddDebugMessage("Removing timers",false);
            }
}

void SanityDrain(string &in asTimer)
{
    if(
asTimer == "start_drain")
    {
        if(
GetPlayerSanity() > 20
        {
        
GiveSanityDamage(5false);
        
AddDebugMessage("Giving sanity damage",false);
        }
    }
    
    else if(
asTimer == "drain_loop")
    {
        if(
GetPlayerSanity() > 20
        {
        
GiveSanityDamage(5false);
        
AddDebugMessage("Giving sanity damage",false);
        
AddDebugMessage("Player sanity at "+GetPlayerSanity(),false);
        }
    }
    
AddTimer("drain_loop"1"SanityDrain");
    
AddDebugMessage("Adding drain_loop",false);

[b]Mr Credits look:[/b]

[video=youtube]http://youtu.be/o6jift9j6-8[/video][b]
[/b]
Uh, what is it you're trying to do exactly?
(04-28-2013, 02:33 PM)Mr Credits Wrote: [ -> ]Uh, what is it you're trying to do exactly?

I think he wants to swim.
(04-28-2013, 02:39 PM)JustAnotherPlayer Wrote: [ -> ]
(04-28-2013, 02:33 PM)Mr Credits Wrote: [ -> ]Uh, what is it you're trying to do exactly?

I think he wants to swim.

Can that even be done? o.o
Я море знаем, не получилось Sad.

I speak that does not work