
If script>0 Then

	;Texte
	;Sterben
	If script=2 Then
		Color 255,0,0
		SetFont font_menu
		Text opt_sx/2, opt_sy/2-20, "Du bist gestorben!",1
		SetFont font_norm
		Text opt_sx/2, opt_sy/2, "< drücke Escape zum fortfahren >",1
	;Gewinnen
	ElseIf script=4 Then
		Color 0,255,0
		SetFont font_menu
		Text opt_sx/2, opt_sy/2-50, "Herzlichen Glückwunsch!",1
		Text opt_sx/2, opt_sy/2-30, "Du hast es geschafft die Insel zu verlassen",1
		Text opt_sx/2, opt_sy/2-10, "und nach Hause zu fahren!",1
		SetFont font_norm
		Text opt_sx/2, opt_sy/2+10, "< drücke Enter zum fortfahren >",1
	;Custom Mission: Gewinnen
	ElseIf script=5 Then
		Color 0,255,0
		SetFont font_menu
		Text opt_sx/2, opt_sy/2-20, "Gewonnen! Glückwunsch!",1
		SetFont font_norm
		Text opt_sx/2, opt_sy/2, "< drücke Escape zum fortfahren >",1
	;Custom Mission: Timeout
	ElseIf script=6 Then
		Color 255,0,0
		SetFont font_menu
		Text opt_sx/2, opt_sy/2-20, "Verloren! Zeit vorbei!",1
		SetFont font_norm
		Text opt_sx/2, opt_sy/2, "< drücke Escape zum fortfahren >",1

	EndIf
	

	If ms-script_timer>=25 Then
		script_timer=ms
			
		Select script
		
		
			;Aufstehen
			Case 1
				EntityAlpha lspr, (100.0-script_timer2)/100.0
				RotateEntity camera, EntityPitch(camera),EntityYaw(camera),script_timer2-100
				PositionEntity camera, 95, 4.0+(script_timer2/20.0), 50
				If script_timer2=5 Then PlaySound sfx_standup
				If script_timer2=100 Then script_run(0)
				
			;Sterben
			Case 2
				EntityAlpha lspr, (script_timer2)/100.0
				If script_timer2=100 Then
					script_timer2=100
				EndIf
				If Not ChannelPlaying(sfx_track) Then
					sfx_track=PlaySound(sfx_track_gameover)
				EndIf
				ChannelVolume sfx_track, (script_timer2)/100.0
				If script_timer2=5 Then PlaySound sfx_die
				
			;Schlafen
			Case 3
				If script_timer2>100 Then
					If pl_tired>0 Then pl_tired=pl_tired-1
					If pl_tilebuild=2 And pl_tilebuildb=0 And pl_health<pl_health_max Then pl_health=pl_health+1
				EndIf
				If script_timer2<=100
					EntityAlpha lspr, (script_timer2)/100.0
				ElseIf script_timer2=101 Then
					PlaySound sfx_sleep
					sleep(1)
				ElseIf script_timer2>=200 Then
					EntityAlpha lspr, (300.0-script_timer2)/100.0
				EndIf
				If script_timer2=300 Then
					game_save("autosave",0)
					If (pl_health_cache-pl_health)<0 Then
						msg("Du hast geschlafen (0 Müde, +"+(-(pl_health_cache-pl_health))+" Energie)",1,1)
					Else
						msg("Du hast geschlafen (0 Müde, -"+(pl_health_cache-pl_health)+" Energie)",1,1)	
					EndIf
					script_run(0)
				EndIf
				
			;Gewinnen
			Case 4
				EntityAlpha lspr, (script_timer2)/100.0
				If script_timer2=100 Then
					script_timer2=100
				EndIf
				If Not ChannelPlaying(sfx_track) Then
					sfx_track=PlaySound(sfx_track_won)
				EndIf
				ChannelVolume sfx_track, (script_timer2)/100.0
				If script_timer2=1 Then PlaySound sfx_skill
				If KeyHit(28) Then
					StopChannel sfx_track
					clear()
					menu_set(10)
					Goto menu
				EndIf
				
			;Custom Mission: Gewinnen
			Case 5
				EntityAlpha lspr, (script_timer2)/100.0
				If script_timer2=100 Then
					script_timer2=100
				EndIf
				If Not ChannelPlaying(sfx_track) Then
					sfx_track=PlaySound(sfx_track_won)
				EndIf
				ChannelVolume sfx_track, (script_timer2)/100.0
				If script_timer2=5 Then PlaySound sfx_skill

			;Custom Mission: Timeout
			Case 6
				EntityAlpha lspr, (script_timer2)/100.0
				If script_timer2=100 Then
					script_timer2=100
				EndIf
				If Not ChannelPlaying(sfx_track) Then
					sfx_track=PlaySound(sfx_track_gameover)
				EndIf
				ChannelVolume sfx_track, (script_timer2)/100.0
				If script_timer2=5 Then PlaySound sfx_die

				
		
		
		
		End Select
		script_timer2=script_timer2+1
	EndIf
EndIf