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


Thread Rating:
  • 6 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script causing game to randomly crash (No FATAL ERROR)
RawkBandMan Offline
Posting Freak

Posts: 1,146
Threads: 35
Joined: Nov 2010
Reputation: 5
#79
RE: extra_english now is working, but I need help with a different script :)

(05-27-2011, 08:53 PM)Khyrpa Wrote:
(05-27-2011, 07:25 PM)XxRoCkBaNdMaNxX Wrote: I'd have to ask yo how it actually works, and what I could put in each thing....

I copied it from the 25_nave_tunnels.map from Main or whatever the map is called and I thought it would basically work without much editing.

Allright I try to make this as simple as possible, for I too had serious problems figuring this out.
This is a more simplified version of the code:
void TimerItself(string &in asTimer)
{    AddTimer("SPAM", 2.0f, "TimerItself"); // 1.
    AddLocalVarInt("Stage", 1); // 2.
    switch(GetLocalVarInt("Stage")) //3.
        {case 1:
            FadeOut(1.0f);
            break;
        case 2:                //
            FadeIn(1.0f);    //4.
            break;            //
        case 3:
            FadeOut(1.0f);
            break;
        }
}
I marked each particular part of the code in numbers so I can explain them here:

1. The timer inside the timer does exactly what you'd think it does. Every 2 seconds the "TimerItself" is called.

2. This makes sure the actions progress, meaning that when this first comes the "Stage" variable will become 1. And every time the "TimerItself" function is called, this adds +1 into the variable.

3. I don't know the specifics about this thing, but it checks how big the variable is (in this case its "Stage") and picks the case with the same number.

4. In between the case and break, you can put functions you want to use. And in this case the next case comes every 2 seconds



Here I'm going to complicate it a little bit so it can be utilized better. This is how it will look (color coding for easier explanation and I suggest you copy pasting this into notepad ++ and setting the Language to C++):

void TimerItself(string &in asTimer)
{float fEventSpeed = 2.0f;
AddLocalVarInt("Stage", 1);
switch(GetLocalVarInt("Stage"))
{case 1:
FadeOut(1.0f);
break;
case 2:
FadeIn(1.0f);
fEventSpeed = 5.0f;
break;
case 3:
FadeOut(1.0f);
break;
}
if(GetLocalVarInt("Stage") < 4) AddTimer("SPAM", fEventSpeed, "TimerItself");
}

So the function above does exactly the same as the simpler one except that the second FadeOut(1.0f); comes 3 seconds later.

if(GetLocalVarInt("Stage") < 4) AddTimer("SPAM", fEventSpeed, "TimerItself"); has to be placed in the end of the function so that the first float fEventSpeed = 2.0f; is before fEventSpeed = 5.0f; so that the second event speed effects the if(getblehblah litany.
Because the fEventSpeed = 5.0f; is in case 2:, case 4 would trigger 2 seconds after case 3 (the function ingnores all other cases than the one that fits to the "Stage" variable).

if(GetLocalVarInt("Stage") < 4) simply means that you can decide when the timer stops looping itself (when cases end, without this part the timer would stay and loop without anything happening. That could possibly slow the game down or something).
the < 4 part means that "TimerItself" is called 4 times then stop ("Stage" variable would be 4).

Checking the color coding and with a little logic this should be possible to understand. If anyone has any more questions, I could try and explain... again Smile

I have just one more question.

What would the function to make Daniel roll to look like he is laying, then to get back up? (I think its like FadePlayerRollTo(X Axis,Y axis, Z axis) or something). But what would be the Numbers for the X, Y, and Z axis?? (For the laying on the ground like sleeping, and the default.)

I've come to learn to not fear the living, nor the dead... But the monsters that hide in closets.
05-27-2011, 10:59 PM
Find


Messages In This Thread
RE: Where can I find water? - by Greven - 05-08-2011, 05:19 PM
RE: Where can I find water? - by RawkBandMan - 05-08-2011, 05:44 PM
RE: Where can I find water? - by Simpanra - 05-08-2011, 08:33 PM
RE: Where can I find water? - by Greven - 05-08-2011, 09:22 PM
RE: Where can I find water? - by Simpanra - 05-08-2011, 09:28 PM
RE: Where can I find water? - by Greven - 05-08-2011, 09:32 PM
RE: Where can I find water? - by Simpanra - 05-08-2011, 09:33 PM
RE: Where can I find water? - by Greven - 05-08-2011, 09:38 PM
RE: Where can I find water? - by Simpanra - 05-08-2011, 09:46 PM
RE: Where can I find water? - by RawkBandMan - 05-08-2011, 09:50 PM
RE: Where can I find water? - by Roenlond - 05-08-2011, 08:31 PM
RE: Where can I find water? - by RawkBandMan - 05-08-2011, 09:18 PM
RE: Where can I find water? - by Simpanra - 05-08-2011, 09:59 PM
RE: Where can I find water? - by RawkBandMan - 05-08-2011, 10:27 PM
RE: Where can I find water? - by Karai16 - 05-08-2011, 11:22 PM
RE: Where can I find water? - by RawkBandMan - 05-09-2011, 12:01 AM
RE: extra_english now is working, but I need help with a different script :) - by RawkBandMan - 05-27-2011, 10:59 PM



Users browsing this thread: 2 Guest(s)