Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Hi, its me again ;d
NotASkrub Offline
Junior Member

Posts: 19
Threads: 2
Joined: Jun 2015
Reputation: 0
#1
Hi, its me again ;d

So, can someone tell me, where is my mistake with this?

PHP Code: (Select All)
void OnStart()
{
    
TeleportPlayer("PlayerStartArea_1");
    
AddEntityCollideCallback("Player""Quest1""Tired"true1);
    
AddEntityCollideCallback("Player""Quest1Done""TiredDone"true1);
;}
void Tired(string &in asParentstring &in asChildint alState)
{
    
AddQuest("Tired""Tired");
;}
void TiredDone(string &in asParentstring &in asChildint alState)
{
    
CompleteQuest("Tired""Tired");
    
AddTimer("FadeOutTimer"float (0.1), "FadeOutFunc");
    
;}
void FadeOutFunc(string &in asTimer)
{
    
FadeOut(float (2));
    
AddTimer("FadeInTimer"float (0.1), "FadeInFunc");
;}
void FadeInFunc(string &in asTimer)
{
    
FadeIn(float (4));
;} 
What it has to do is the following:
1. You enter an area (e.g script) and get a quest that you're tired.
2. You go in the area realy close to your bed.
3. You fadeout (go to sleep) and then fade in (wake up) with the first quest finished.
But for some reason, it only finishes the quest..
06-19-2015, 01:52 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#2
RE: Hi, its me again ;d

You're getting the idea, but it's supposed to look like this:

PHP Code: (Select All)
void OnStart()
{
    
TeleportPlayer("PlayerStartArea_1");
    
AddEntityCollideCallback("Player""Quest1""Tired"true1);
    
AddEntityCollideCallback("Player""Quest1Done""TiredDone"true1);
}
void Tired(string &in asParentstring &in asChildint alState)
{
    
AddQuest("Tired""Tired");
}
void TiredDone(string &in asParentstring &in asChildint alState)
{
    
CompleteQuest("Tired""Tired");
    
AddTimer("FadeOutTimer"0.1f"FadeOutFunc");
    
}
void FadeOutFunc(string &in asTimer)
{
    
FadeOut(2);
    
AddTimer("FadeInTimer"0.1f"FadeInFunc");
}
void FadeInFunc(string &in asTimer)
{
    
FadeIn(5)


Mistakes
When you have to write a float, all you have to do is write a number with a decimal, and then follow up with f.
Example:
1.0f

When ending a function you wrote ";}". It's just "}"
Example:
void Function()
{

}

Trying is the first step to success.
(This post was last modified: 06-19-2015, 02:14 AM by FlawlessHappiness.)
06-19-2015, 02:12 AM
Find
NotASkrub Offline
Junior Member

Posts: 19
Threads: 2
Joined: Jun 2015
Reputation: 0
#3
RE: Hi, its me again ;d

(06-19-2015, 02:12 AM)FlawlessHappiness Wrote: You're getting the idea, but it's supposed to look like this:

PHP Code: (Select All)
void OnStart()
{
    
TeleportPlayer("PlayerStartArea_1");
    
AddEntityCollideCallback("Player""Quest1""Tired"true1);
    
AddEntityCollideCallback("Player""Quest1Done""TiredDone"true1);
}
void Tired(string &in asParentstring &in asChildint alState)
{
    
AddQuest("Tired""Tired");
}
void TiredDone(string &in asParentstring &in asChildint alState)
{
    
CompleteQuest("Tired""Tired");
    
AddTimer("FadeOutTimer"0.1f"FadeOutFunc");
    
}
void FadeOutFunc(string &in asTimer)
{
    
FadeOut(2);
    
AddTimer("FadeInTimer"0.1f"FadeInFunc");
}
void FadeInFunc(string &in asTimer)
{
    
FadeIn(5)


Mistakes
When you have to write a float, all you have to do is write a number with a decimal, and then follow up with f.
Example:
1.0f

When ending a function you wrote ";}". It's just "}"
Example:
void Function()
{

}
Thank you for the code help, and no, for me if I dont write ";" before the end of the "}"
it will give me an error expecting a ";" before "}"
;d
06-19-2015, 02:24 AM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#4
RE: Hi, its me again ;d

(06-19-2015, 02:24 AM)NotASkrub Wrote: Thank you for the code help, and no, for me if I dont write ";" before the end of the "}"
it will give me an error expecting a ";" before "}"
;d

Really? o.0

That is awfully strange. The reason for that error is to explain that at a certain line (it could be the one they mention, or any before it, usually within the same function bracket), that you're missing a semicolon at the end of a function.

Say I have these:
PHP Code: (Select All)
AddEntityCollideCallback("Player""scr_jumpscare""activate_jumpscare"true0)
AddEntityCollideCallback("Playee""scr_scarymusic""activate_scarymusic"true0); 

The first Callback above will error the whole code, since it is missing a semicolon. It can be fixed by putting a semicolon on the new line, but it looks wrong from a coder's perspective.
So if we put a semicolon on the end, or delete the whole line, then the error should not show. (And in my case, I would delete it, because very little jumpscares are good scares).

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 06-19-2015, 02:46 AM by Romulator.)
06-19-2015, 02:46 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#5
RE: Hi, its me again ;d

I believe the error you got was because of the "float (4)".
Try with my fixed version. See if you get any errors.

Trying is the first step to success.
06-19-2015, 02:52 AM
Find
NotASkrub Offline
Junior Member

Posts: 19
Threads: 2
Joined: Jun 2015
Reputation: 0
#6
RE: Hi, its me again ;d

I tried, I dont get errors, its just that the fade out does not start and also same goes for fade in..

Edit, its 05:00 am here and I'm going to sleep, feel free to answer and do suggestions, when I get back from school I will check them out ;d
(This post was last modified: 06-19-2015, 02:59 AM by NotASkrub.)
06-19-2015, 02:58 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#7
RE: Hi, its me again ;d

(From Flawless' example. PS: You missed a semi-colon by the end)

PHP Code: (Select All)
void FadeOutFunc(string &in asTimer)
{
    
FadeOut(2);
    
AddTimer("FadeInTimer"0.1f"FadeInFunc");
}

void FadeInFunc(string &in asTimer)
{
    
FadeIn(5);


@OP
This right here won't work the way you want it. It starts off going towards black, but before it manages to do anything, it starts going towards being visible again. The timer that follows FadeOut is too quick for you to notice the FadeOut. Make sure your timer starts AFTER the time of the FadeOut (unless you don't want it to be fully black).

So to fix this, you either edit the time of the FadeOut to be shorter than the timer, or edit the timer to be longer than the FadeOut. For example:

PHP Code: (Select All)
void FadeOutFunc(string &in asTimer)
{
    
FadeOut(2);
    
AddTimer("FadeInTimer"2.1f"FadeInFunc");
}

void FadeInFunc(string &in asTimer)
{
    
FadeIn(5);


06-19-2015, 08:03 AM
Find
NotASkrub Offline
Junior Member

Posts: 19
Threads: 2
Joined: Jun 2015
Reputation: 0
#8
RE: Hi, its me again ;d

(06-19-2015, 08:03 AM)Mudbill Wrote: (From Flawless' example. PS: You missed a semi-colon by the end)

PHP Code: (Select All)
void FadeOutFunc(string &in asTimer)
{
    
FadeOut(2);
    
AddTimer("FadeInTimer"0.1f"FadeInFunc");
}

void FadeInFunc(string &in asTimer)
{
    
FadeIn(5);


@OP
This right here won't work the way you want it. It starts off going towards black, but before it manages to do anything, it starts going towards being visible again. The timer that follows FadeOut is too quick for you to notice the FadeOut. Make sure your timer starts AFTER the time of the FadeOut (unless you don't want it to be fully black).

So to fix this, you either edit the time of the FadeOut to be shorter than the timer, or edit the timer to be longer than the FadeOut. For example:

PHP Code: (Select All)
void FadeOutFunc(string &in asTimer)
{
    
FadeOut(2);
    
AddTimer("FadeInTimer"2.1f"FadeInFunc");
}

void FadeInFunc(string &in asTimer)
{
    
FadeIn(5);


Ah, I see what you mean MudbillI, I guess I misunderstood the script.. I started watching TechOFreak128 in youtube and from him I started learning how to script and make CS..
What he said was that every command(code) is followed from top to bottom, and I trough that it will not execute the next code before the ones first:
1. I have the fadeout code, and untill that is fully executed, it will not proceed to the next one (e.g the timer)..
Again, thank you for the help!
Will keep that in mind!
Expect further questions if I get stuck again ;d
06-19-2015, 09:45 AM
Find
NotASkrub Offline
Junior Member

Posts: 19
Threads: 2
Joined: Jun 2015
Reputation: 0
#9
RE: Hi, its me again ;d

Heya, I'm here with another question! ;d

PHP Code: (Select All)
void PlayerScare(string &in asParentstring &in asChildstring &in alState)
{
    if (
GetSwingDoorClosed() == false)
        {
            
SetSwingDoorClosed("AwaysLockedDoor"bool (true), "");
            
AddTimer("Lock"float (1.0), "LockDoor");
        }
;}

void LockDoor(string &in asTimer)
{
    
SetSwingDoorLocked("AwaysLockedDoor"bool (true), "");
    
PlaySoundAtEntity("""lock_door.snt""Player"float (0.0), bool (false));
    
SetEntityActive("JumpScare"bool (true));
    
ShowEnemyPlayerPosition("JumpScare");
;} 
This is the code.
[Image: 38tOKDG.png]
This is the error, where is my mistake here? Because, as I saw others to do the same in their tutorials, like techofreak, mudbill etc..
06-20-2015, 01:00 PM
Find
DnALANGE Offline
Banned

Posts: 1,549
Threads: 73
Joined: Jan 2012
#10
RE: Hi, its me again ;d

void PlayerScare(string &in asParent, string &in asChild, string &in alState)
{
if(GetSwingDoorClosed(asEntity) == false)
{
SetSwingDoorClosed("AwaysLockedDoor", true, "true");
AddTimer("Lock", float (1.0), "LockDoor");
}
}

Quote:SetSwingDoorClosed(string& asName, bool abClosed, bool abEffects);
has to be like this :
SetSwingDoorClosed("""Name of your door", true or false, true or false);

So choose OR true OR false,like :
PHP Code: (Select All)
SetSwingDoorClosed("""Name of your door"true,false); 

For your script as it is now no need to write bool AND true.
Bool = true or false.

Here is an example from me, try playing with it :
PHP Code: (Select All)
SetSwingDoorLocked("door1"falsefalse);
SetSwingDoorClosed("door1"falsefalse); 
-
PHP Code: (Select All)
void Bathroomdoor(string &in asEntity)
{
    if(
GetSwingDoorLocked(asEntity) == true)

//DO SOMETHING HERE/ Put your script here. Only when touching the door and have (Bathroomdoor) set in your leveleditor as PlayerInteractCallBack.


(This post was last modified: 06-20-2015, 02:10 PM by DnALANGE.)
06-20-2015, 02:02 PM
Find




Users browsing this thread: 1 Guest(s)