Jump to content

Script help for a mod


tdx73

Recommended Posts

I was wondering if anyone could help me write a script for a mod. I am trying to get a script to disable player controls while playing a sound and then enable when the sound stops playing..In other words I need a script with a timer to disable player controls for said amount of time. I can not figure out how the timer works. Any help would be appreciated. Thanks

Edited by tdx73
Link to comment
Share on other sites

There are two ways to write a simple timer, you can count down or up. I prefer to count down, so that's what I'll show you how to do.

 

First, you need a variable that can act as your timer. So, you need something that looks like this to start with:

Scn MyScriptNameExample
 
float fTimer

Now, "fTimer" will act as the timer, although it doesn't do anything yet. As a side note, you can enter anything after "float" "fTimer" just makes the most sense to me.

 

Next you need to implement the actual timing itself. To do this you need the function GetSecondsPassed. So you'll need a script that looks something like:

Scn MyScriptNameExample
 
float fTimer
short bDoOnce
 
begin GameMode
 
    if fTimer <= 0
        if bDoOnce == 0
            set fTimer to 5
            set bDoOnce to 1
        else
            ;Do stuff
        endif
    else
        Set fTimer to fTimer - GetSecondsPassed
    endif
end

This script will set up a timer that runs for five seconds. You will need to replace ";Do stuff" with the functions that you want to call. If anything's unclear feel free to ask!

Edited by Jojash
Link to comment
Share on other sites

This is how I would do it:

 

1. Create a new quest, name it VehicleFastTravelQuest (or whatever), and set the processing delay to 0.01

2. Create a new quest script and use this code:

scn	VehicleFastTravelQuestScript

short	iLocation
float	fTimer
short	bSound

begin GameMode

	if fTimer == 0
		Location01CarREF.Disable			; These are the reference IDs of the cars you placed in each travelable location.
		Location02CarREF.Disable
		Location03CarREF.Disable
		Location04CarREF.Disable
		Location05CarREF.Disable
		DisablePlayerControls
		ApplyImageSpaceModifier FadeToBlackAndBackQuickExtendedISFX	; Plays a fade-in-fade-out effect, lasting 6 seconds.
		set fTimer to 4
	elseif fTimer > 0
		if (fTimer < 2) && (bSound == 0)					; After two seconds had passed, plays the driving sound.
			set bSound to 1
			PlaySound YourDrivingSound
		endif
		set fTimer to fTimer - GetSecondsPassed
	else									; After four seconds had passed, Moves the player to the selected location.
		if iLocation == 1
			Location01CarREF.Enable
			player.MoveTo LocationMarker01REF
		elseif iLocation == 2
			Location02CarREF.Enable
			player.MoveTo LocationMarker02REF
		elseif iLocation == 3
			Location03CarREF.Enable
			player.MoveTo LocationMarker03REF
		elseif iLocation == 4
			Location04CarREF.Enable
			player.MoveTo LocationMarker04REF
		elseif iLocation == 5
			Location05CarREF.Enable
			player.MoveTo LocationMarker05REF
		endif
		EnablePlayerControls
		ResetQuest VehicleFastTravelQuest
	endif

end

Note: You will probably need to tweak the timings here, according to the duration of the driving sound you use. If 6 seconds for the fade effect is too short/too long, create a copy of FadeToBlackAndBackQuickExtendedISFX and set Duration (it's at the bottom) to how long you want the effect to last.

 

3. In the terminal, have each location option run this result script when selected (you said you intend to use a terminal for location selection before editing your post):

set VehicleFastTravelQuest.iLocation to 1	; (or 2, or 3, etc.)
StartQuest VehicleFastTravelQuest
ForceTerminalBack

BTW, what's the current status with Abby? Will you bring her back any time soon?

Link to comment
Share on other sites

Yeah, this is exactly what I was looking for. I was already trying to do it through a quest script but couldn't quite figure it out. Thanks so much! As for Abby, I don't know if she will be back. Between all the negative remarks and the frustration of trying to fix all the little bugs and errors I gave up.And I also deleted my only copy of Her by accident. So now I would have to try to find someone to get it from or start over. I still have all the voice files plus the stuff I didn't incorporate yet, so maybe. Thanks again.

 

 

 

Edit: Everything seems to be working the way I want now except the fade to black fx isn't working. Don't know why but it is not that big of a deal anyway. Thanks again.

Edited by tdx73
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...