Jump to content

Scripting Problems...


monkmidon

Recommended Posts

So I'm scripting a misc. item that has the following script attached to it:

 


scn MDEmptyPitcher

short controlvar
short button

Begin OnEquip Player
set controlvar to 1
End

Begin GameMode
If Controlvar == 1 && player.getdistance MDZoneRef >= 10 
	MessageBox "Fill the enchanted pitcher with water?" "Yes" "No"
	set button to getbuttonpressed	
	set controlvar to 0
	If button == -1
		return
	Elseif button == 1
		set controlvar to 0
		Else
			player.additem MDPitcherFullScroll 1
			player.removeitem MDPitcherEmpty 1
			set controlvar to 0
	Endif
Endif
End

 

What I want to happen is when the player "equips" the pitcher (it's a misc. item, so you can't really equip it), a messagebox then opens when the player exits menumode, but only if the player is within range of the specified object (MDZoneRef).

 

If the player answers yes to the messagebox then the pitcher is removed from inventory, and a "full" pitcher is then added to the inventory.

 

The problems are that the messagebox opens up just about anywhere I am in relation to MDZoneRef, and the script does not add or remove the specified items. :wallbash:

 

Help would be much appreciated! Thanks

Link to comment
Share on other sites

The problem is that you're having the messagebox run every frame. You need to set it up so that the message box only runs for a single frame, but the result runs in the next frame. Button detection also needs to wait a frame before it can register.

 

scn MDEmptyPitcher

short controlvar
short button

Begin OnEquip Player
set controlvar to 1
End

Begin GameMode
If Controlvar == 1 && player.getdistance MDZoneRef >= 10
set controlvar to 2
MessageBox "Fill the enchanted pitcher with water?" "Yes" "No"
return
endif
if controlvar == 2
set button to getbuttonpressed
If button == -1
return
Elseif button == 1
set controlvar to 0
Else
player.additem MDPitcherFullScroll 1
player.removeitem MDPitcherEmpty 1
set controlvar to 0
Endif
Endif
End

Or something like that. To be honest, I kinda suck with message box scripts, so this probably won't work. Hopefully it gives you some ideas though.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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