Jump to content

Script with two MessageBox


Wyrm1331

Recommended Posts

Hi all.

 

I´ve got a problem with a script that has two messageBox (one inside the other) It works, when I press the button in te 1st messagebox, the 2nd one appears.

 

But if I press the button in the 2nd, it operates as the 1st one. I hve read that it´s a problem (bug) but there any solution? or ir there anything I can do?

 

The script is similar to this one (It´s like the SaidenStorms´s Akatosh script but in spanish and with other messagebox inside)

 

 

scn 0001CommandDragon

ref BabyBlack
short Button
short Button2
Ref MyItem
Short count
Short countRat
Short countCrab
Short countFire
Short countFrost
Short countScales
Short countVoid
Short countGold
Short countIridis


Begin ScriptEffectStart


               Set BabyBlack to BabyBlackRef
                       MessageBox "Manejar Dragón", "Invocar", "Seguir", "Esperar", "Calmar","Descansar","Despertar","Inventario","Regresar","Alimentar","Cont."

End

Begin ScriptEffectUpdate

               Set Button to GetButtonPressed
                       If Button > -1
                               If Button == 0
;       SSFireDrake.Cast 1SSMountReturnHome SSFireDrake
;       SSFrostDrake.Cast 1SSMountReturnHome SSFrostDrake
;       SSEarthDrake.Cast 1SSMountReturnHome SSEarthDrake
;       SSStormDrake.Cast 1SSMountReturnHome SSStormDrake


                                       BabyBlack.RemoveScriptPackage
                                    BabyBlack.MoveTo Player 0 0 3000


                               Elseif Button == 1
                                       If BabyBlack.IsSpellTarget 1SSMountRest
                                               Return
                                       Else
                                               BabyBlack.AddScriptPackage 1SSMountFollowPlayer
                                       Endif
                               Elseif Button == 2
                                       BabyBlack.AddScriptPackage 1SSMountWander
                               Elseif Button == 3
                                       BabyBlack.Cast 1SSMountCalm BabyBlack
                               Elseif Button == 4
                                       BabyBlack.RemoveScriptPackage
                                       BabyBlack.AddSpell 1SSMountRest
                               Elseif Button == 5
                                       BabyBlack.RemoveSpell 1SSMountRest
                               Elseif Button == 6
                                       If Player.GetDistance BabyBlack <= 150
                                               SSMountSaddlebags.Activate Player 1
                                       Else
                                               Message " Necesitas acercarte a tu dragón."
                                       Endif
                               Elseif Button == 7
                                       BabyBlack.RemoveScriptPackage
                                       BabyBlack.Cast 1SSMountReturnHome BabyBlack
                               Elseif Button == 8
                                    MessageBox "Alimentación", "Carne de Rata", "Sales de Fuego", "Sales de Escarcha", "Carne de Cangrejo", "Escamas", "Sales de Vacio", "Dorado", "Iridico", "Volver"
                                    Set Button2 to GetButtonPressed
                                               If Button2 > -1
                                               If Button2 == 0
                                                               set MyItem to Ratmeat
                                                               if player.GetItemCount MyItem == 0
                                                               MessageBox "No tienes de éste ingrediente"
                                                               endif                                                           
                                                               if player.GetItemCount MyItem == 1
                                                               player.removeitem Ratmeat 1
                                                               set countRat to (countRat+1)
                                                               endif

                                               Elseif Button2 == 1
                                                               set MyItem to FireSalts
                                                               if player.GetItemCount MyItem == 0
                                                               MessageBox "No tienes de éste ingrediente"
                                                               endif                                                           
                                                               if player.GetItemCount MyItem == 1
                                                               player.removeitem FireSalts 1
                                                               set countFire to (countFire+1)
                                                               endif

                                               Elseif Button2 == 2
                                                               set MyItem to FrostSalts
                                                               if player.GetItemCount MyItem == 0
                                                               MessageBox "No tienes de éste ingrediente"
                                                               endif                                                           
                                                               if player.GetItemCount MyItem == 1
                                                               player.removeitem FrostSalts 1
                                                               set countFrost to (countFrost+1)
                                                               endif
                                               Elseif Button2 == 3
                                                               set MyItem to CrabMeat
                                                               if player.GetItemCount MyItem == 0
                                                               MessageBox "No tienes de éste ingrediente"
                                                               endif                                                           
                                                               if player.GetItemCount MyItem == 1
                                                               player.removeitem CrabMeat 1
                                                               set countCrab to (countCrab+1)
                                                               endif
                               
                                               Elseif Button2 == 4
                                                               set MyItem to Scales
                                                               if player.GetItemCount MyItem == 0
                                                               MessageBox "No tienes de éste ingrediente"
                                                               endif                                                           
                                                               if player.GetItemCount MyItem == 1
                                                               player.removeitem Scales 1
                                                               set countScales to (countScales+1)
                                                               endif
                               
                                               Elseif Button2 == 5
                                                               set MyItem to VoidSalts
                                                               if player.GetItemCount MyItem == 0
                                                               MessageBox "No tienes de éste ingrediente"
                                                               endif                                                           
                                                               if player.GetItemCount MyItem == 1
                                                               player.removeitem VoidSalts 1
                                                               set countVoid to (countVoid+1)
                                                               endif
                                       
                                               Elseif Button2 == 6
                                                               set MyItem to Ratmeat
                                                               if player.GetItemCount MyItem == 0
                                                               MessageBox "No tienes de éste ingrediente"
                                                               endif                                                           
                                                               if player.GetItemCount MyItem == 1
                                                               player.removeitem Ratmeat 1
                                                               set countGold to (countGold+1)
                                                               endif
                               
                                               Elseif Button2 == 7     
                                                               set MyItem to Ratmeat
                                                               if player.GetItemCount MyItem == 0
                                                               MessageBox "No tienes de éste ingrediente"
                                                               endif                                                           
                                                               if player.GetItemCount MyItem == 1
                                                               player.removeitem Ratmeat 1
                                                               set countIridis to (countIridis+1)
                                                               endif
                               
                                               Elseif Button2 == 8
                                                       Return          
                               Elseif Button == 9
                                       Return
                               Endif
                       Endif
endif
endif

end
Begin ScriptEffectFinish

End

 

 

 

Thanks a lot.

Link to comment
Share on other sites

I'm not sure how well I can explain it, but the problem is you need an extra variable. Right now, you have:

 

set Button to GetButtonPressed

 

and

 

set Button2 to GetButtonPressed

 

So even when it's displaying the second message box, the choice still gets sent to "Button". You should have something like:

 

if menu == 0
set Button to GetButtonPressed
elseif menu == 1
set Button2 to GetButtonPressed
endif

 

EDIT: I made a change to your script which should make it work correctly:

 

 

scn 0001CommandDragon

ref BabyBlack
short menu
short Button
short Button2
Ref MyItem
Short count
Short countRat
Short countCrab
Short countFire
Short countFrost
Short countScales
Short countVoid
Short countGold
Short countIridis


Begin ScriptEffectStart

Set BabyBlack to BabyBlackRef
MessageBox "Manejar Dragón", "Invocar", "Seguir", "Esperar", "Calmar","Descansar","Despertar","Inventario","Regresar","Alimentar","Cont."

End


Begin ScriptEffectUpdate

if (menu == 0)

	Set Button to GetButtonPressed
	If Button > -1
		If Button == 0
;				SSFireDrake.Cast 1SSMountReturnHome SSFireDrake
;				SSFrostDrake.Cast 1SSMountReturnHome SSFrostDrake
;				SSEarthDrake.Cast 1SSMountReturnHome SSEarthDrake
;				SSStormDrake.Cast 1SSMountReturnHome SSStormDrake
			BabyBlack.RemoveScriptPackage
			BabyBlack.MoveTo Player 0 0 3000
		Elseif Button == 1
			If BabyBlack.IsSpellTarget 1SSMountRest
				Return
			Else
				BabyBlack.AddScriptPackage 1SSMountFollowPlayer
			Endif
		Elseif Button == 2
			BabyBlack.AddScriptPackage 1SSMountWander
		Elseif Button == 3
			BabyBlack.Cast 1SSMountCalm BabyBlack
		Elseif Button == 4
			BabyBlack.RemoveScriptPackage
			BabyBlack.AddSpell 1SSMountRest
		Elseif Button == 5
			BabyBlack.RemoveSpell 1SSMountRest
		Elseif Button == 6
			If Player.GetDistance BabyBlack <= 150
				SSMountSaddlebags.Activate Player 1
			Else
				Message "Necesitas acercarte a tu dragón."
			Endif
		Elseif Button == 7
			BabyBlack.RemoveScriptPackage
			BabyBlack.Cast 1SSMountReturnHome BabyBlack
		Elseif Button == 8
			set menu to 1
			MessageBox "Alimentación", "Carne de Rata", "Sales de Fuego", "Sales de Escarcha", "Carne de Cangrejo", "Escamas", "Sales de Vacio", "Dorado", "Iridico", "Volver"
		Elseif Button == 9
			Return
		Endif
	endif
	
elseif (menu == 1)

	Set Button2 to GetButtonPressed
	If Button2 > -1
		If Button2 == 0
			set MyItem to Ratmeat
			if player.GetItemCount MyItem == 0
				MessageBox "No tienes de éste ingrediente"
			endif
			if player.GetItemCount MyItem == 1
				player.removeitem Ratmeat 1
				set countRat to (countRat+1)
			endif
		Elseif Button2 == 1
			set MyItem to FireSalts
			if player.GetItemCount MyItem == 0
				MessageBox "No tienes de éste ingrediente"
			endif
			if player.GetItemCount MyItem == 1
				player.removeitem FireSalts 1
				set countFire to (countFire+1)
			endif
		Elseif Button2 == 2
			set MyItem to FrostSalts
			if player.GetItemCount MyItem == 0
				MessageBox "No tienes de éste ingrediente"
			endif
			if player.GetItemCount MyItem == 1
				player.removeitem FrostSalts 1
				set countFrost to (countFrost+1)
			endif
		Elseif Button2 == 3
			set MyItem to CrabMeat
			if player.GetItemCount MyItem == 0
				MessageBox "No tienes de éste ingrediente"
			endif
			if player.GetItemCount MyItem == 1
				player.removeitem CrabMeat 1
				set countCrab to (countCrab+1)
			endif
		Elseif Button2 == 4
			set MyItem to Scales
			if player.GetItemCount MyItem == 0
				MessageBox "No tienes de éste ingrediente"
			endif
			if player.GetItemCount MyItem == 1
				player.removeitem Scales 1
				set countScales to (countScales+1)
			endif
		Elseif Button2 == 5
			set MyItem to VoidSalts
			if player.GetItemCount MyItem == 0
				MessageBox "No tienes de éste ingrediente"
			endif
			if player.GetItemCount MyItem == 1
				player.removeitem VoidSalts 1
				set countVoid to (countVoid+1)
			endif
		Elseif Button2 == 6
			set MyItem to Ratmeat
			if player.GetItemCount MyItem == 0
				MessageBox "No tienes de éste ingrediente"
			endif
			if player.GetItemCount MyItem == 1
				player.removeitem Ratmeat 1
				set countGold to (countGold+1)
			endif
		Elseif Button2 == 7
			set MyItem to Ratmeat
			if player.GetItemCount MyItem == 0
				MessageBox "No tienes de éste ingrediente"
			endif
			if player.GetItemCount MyItem == 1
				player.removeitem Ratmeat 1
			set countIridis to (countIridis+1)
			endif
		Elseif Button2 == 8
			Return
		Endif
	Endif
	
endif

End

 

Edited by fg109
Link to comment
Share on other sites

Your main problem is that you cannot have 2 GetButtonPressed in one cycle of ScriptEffectUpdate. You have to wait one tik.

 

So what you have to do after your 2nd messagebox, is return from the script and check GetButtonPressed during the next cycle. So you should distinguish your ScriptEffectUpdate between page1 and page2.

 

EDIT: oh sorry, didn't see that fg has probably solved it that way

Link to comment
Share on other sites

EDIT: oh sorry, didn't see that fg has probably solved it that way

:thumbsup:

 

By the way, the script still looks very messy so it should be cleaned it up. One thing that still needs to be worked on is button 8 of the second menu. It needs to be scripted so that it actually returns to the first menu. Also, there are a couple of "counter" variables in the script. Since the variables don't stay initialized once the spell ends (as in the values are purged), they're useless the way they are now.

Edited by fg109
Link to comment
Share on other sites

Your main problem is that you cannot have 2 GetButtonPressed in one cycle of ScriptEffectUpdate. You have to wait one tik.

 

So what you have to do after your 2nd messagebox, is return from the script and check GetButtonPressed during the next cycle. So you should distinguish your ScriptEffectUpdate between page1 and page2.

 

EDIT: oh sorry, didn't see that fg has probably solved it that way

 

 

EDIT: oh sorry, didn't see that fg has probably solved it that way

:thumbsup:

 

By the way, the script still looks very messy so it should be cleaned it up. One thing that still needs to be worked on is button 8 of the second menu. It needs to be scripted so that it actually returns to the first menu. Also, there are a couple of "counter" variables in the script. Since the variables don't stay initialized once the spell ends (as in the values are purged), they're useless the way they are now.

 

Thanks all, i will try the script that fg posted, and then I tell you if it works well.Thanks.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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