Jump to content

First time scripter, needs some scripting help


VenomousHail

Recommended Posts

I have this script and its supposed to open a menu when a weapon is equipped. I've sorted through tons of errors so far and managed to have one error left and I can't for the life of me figure it out. The error reads: F:\SteamApps\steamapps\common\Fallout 4\Data\Scripts\Source\User\SelectAmmo10mm.psc(19,2): no viable alternative at input 'if'

Any help would be greatly appreciated.
Scriptname SelectAmmo10mm extends ObjectReference Const

 message property V_10mmAmmo auto Const
 Weapon property V_10mmWeapon auto Const
 ObjectMod property mod_10mm_Receiver_Standard auto Const
 ObjectMod property mod_10mm_Receiver_Acid auto Const
 ObjectMod property mod_10mm_Receiver_Cryo auto Const
 ObjectMod property mod_10mm_Receiver_Electric auto Const
 ObjectMod property mod_10mm_Receiver_Explosive auto Const
 ObjectMod property mod_10mm_Receiver_Frenzy auto Const
 ObjectMod property mod_10mm_Receiver_Incendiary auto Const
 ObjectMod property mod_10mm_Receiver_Paralysis auto Const
 ObjectMod property mod_10mm_Receiver_Poison auto Const
 ObjectMod property mod_10mm_Receiver_Radiation auto Const
 
Event OnItemEquipped(Form akBaseObject, ObjectReference akReference) native
		if akBaseObject == V_10mmWeapon
		int ButtonPressed = V_10mmAmmo.show()		
			if ButtonPressed == 0
			Weapon.AttachMod (mod_10mm_Receiver_Standard)			
			elseif ButtonPressed == 1 
			Weapon.AttachMod (mod_10mm_Receiver_Acid)				
			elseif ButtonPressed == 2 
			Weapon.AttachMod (mod_10mm_Receiver_Cryo)			
			elseif ButtonPressed == 3 
			Weapon.AttachMod (mod_10mm_Receiver_Electric)				
			elseif ButtonPressed == 4 
			Weapon.AttachMod (mod_10mm_Receiver_Explosive)			
			elseif ButtonPressed == 5
			Weapon.AttachMod (mod_10mm_Receiver_Frenzy)				
			elseif ButtonPressed == 6
			Weapon.AttachMod (mod_10mm_Receiver_Incendiary)				
			elseif ButtonPressed == 7
			Weapon.AttachMod (mod_10mm_Receiver_Paralysis)					
			elseif ButtonPressed == 8
			Weapon.AttachMod (mod_10mm_Receiver_Poison)					
			elseif ButtonPressed == 9
			Weapon.AttachMod (mod_10mm_Receiver_Radiation)				
			endif				
EndEvent
				
Link to comment
Share on other sites


Scriptname SelectAmmo10mm extends ObjectReference Const

message property V_10mmAmmo auto Const
Weapon property V_10mmWeapon auto Const
ObjectMod property mod_10mm_Receiver_Standard auto Const
ObjectMod property mod_10mm_Receiver_Acid auto Const
ObjectMod property mod_10mm_Receiver_Cryo auto Const
ObjectMod property mod_10mm_Receiver_Electric auto Const
ObjectMod property mod_10mm_Receiver_Explosive auto Const
ObjectMod property mod_10mm_Receiver_Frenzy auto Const
ObjectMod property mod_10mm_Receiver_Incendiary auto Const
ObjectMod property mod_10mm_Receiver_Paralysis auto Const
ObjectMod property mod_10mm_Receiver_Poison auto Const
ObjectMod property mod_10mm_Receiver_Radiation auto Const

Event OnItemEquipped(Form akBaseObject, ObjectReference akReference) native
if akBaseObject == V_10mmWeapon
int ButtonPressed = V_10mmAmmo.show()
if ButtonPressed == 0
Weapon.AttachMod (mod_10mm_Receiver_Standard)
elseif ButtonPressed == 1
Weapon.AttachMod (mod_10mm_Receiver_Acid)
elseif ButtonPressed == 2
Weapon.AttachMod (mod_10mm_Receiver_Cryo)
elseif ButtonPressed == 3
Weapon.AttachMod (mod_10mm_Receiver_Electric)
elseif ButtonPressed == 4
Weapon.AttachMod (mod_10mm_Receiver_Explosive)
elseif ButtonPressed == 5
Weapon.AttachMod (mod_10mm_Receiver_Frenzy)
elseif ButtonPressed == 6
Weapon.AttachMod (mod_10mm_Receiver_Incendiary)
elseif ButtonPressed == 7
Weapon.AttachMod (mod_10mm_Receiver_Paralysis)
elseif ButtonPressed == 8
Weapon.AttachMod (mod_10mm_Receiver_Poison)
elseif ButtonPressed == 9
Weapon.AttachMod (mod_10mm_Receiver_Radiation)
endif
endif
EndEvent
"Proper" indentation would have helped you to solve this problem early on. :smile:
Link to comment
Share on other sites

Did you change anything aside from the final endif? I noticed that too but I am still getting the same error after fixing it. Then I thought the spaces between AttachMod and ( but that didn't help either. This stuff can be pretty frustrating lol I'll be glad when I finally get the hang of it.

Link to comment
Share on other sites

Well, that's because OnItemEquipped is not part of the ObjectReference script (sorry, I didn't even think to look at that).

You want Event OnEquipped(Actor akActor) instead.

Here:

Scriptname SelectAmmo10mm extends ObjectReference Const

message property V_10mmAmmo auto Const
ObjectMod property mod_10mm_Receiver_Standard auto Const
ObjectMod property mod_10mm_Receiver_Acid auto Const
ObjectMod property mod_10mm_Receiver_Cryo auto Const
ObjectMod property mod_10mm_Receiver_Electric auto Const
ObjectMod property mod_10mm_Receiver_Explosive auto Const
ObjectMod property mod_10mm_Receiver_Frenzy auto Const
ObjectMod property mod_10mm_Receiver_Incendiary auto Const
ObjectMod property mod_10mm_Receiver_Paralysis auto Const
ObjectMod property mod_10mm_Receiver_Poison auto Const
ObjectMod property mod_10mm_Receiver_Radiation auto Const
 
Event OnEquipped(Actor akActor)
	if (akActor == Game.GetPlayer())
		int ButtonPressed = V_10mmAmmo.show()		
		if ButtonPressed == 0
			AttachMod (mod_10mm_Receiver_Standard)			
		elseif ButtonPressed == 1 
			AttachMod (mod_10mm_Receiver_Acid)				
		elseif ButtonPressed == 2 
			AttachMod (mod_10mm_Receiver_Cryo)			
		elseif ButtonPressed == 3 
			AttachMod (mod_10mm_Receiver_Electric)				
		elseif ButtonPressed == 4 
			AttachMod (mod_10mm_Receiver_Explosive)			
		elseif ButtonPressed == 5
			AttachMod (mod_10mm_Receiver_Frenzy)				
		elseif ButtonPressed == 6
			AttachMod (mod_10mm_Receiver_Incendiary)				
		elseif ButtonPressed == 7
			AttachMod (mod_10mm_Receiver_Paralysis)					
		elseif ButtonPressed == 8
			AttachMod (mod_10mm_Receiver_Poison)					
		elseif ButtonPressed == 9
			AttachMod (mod_10mm_Receiver_Radiation)				
		endif		
	endif
EndEvent
Link to comment
Share on other sites

Okay that worked but the menu wouldn't come up when I equipped the weapon so I changed it to this, which also works but menu still doesn't come up when weapon is equipped. Sadly. :confused:

 Scriptname SelectAmmo10mm extends Actor Const

 message property V_10mmAmmo auto Const
 Weapon property V_10mmWeapon auto Const
 ObjectMod property mod_10mm_Receiver_Standard auto Const
 ObjectMod property mod_10mm_Receiver_Acid auto Const
 ObjectMod property mod_10mm_Receiver_Cryo auto Const
 ObjectMod property mod_10mm_Receiver_Electric auto Const
 ObjectMod property mod_10mm_Receiver_Explosive auto Const
 ObjectMod property mod_10mm_Receiver_Frenzy auto Const
 ObjectMod property mod_10mm_Receiver_Incendiary auto Const
 ObjectMod property mod_10mm_Receiver_Paralysis auto Const
 ObjectMod property mod_10mm_Receiver_Poison auto Const
 ObjectMod property mod_10mm_Receiver_Radiation auto Const
 
 Event OnItemEquipped(Form akBaseObject, ObjectReference akReference) 
		
		if 	akBaseObject == V_10mmWeapon 	
			int ButtonPressed = V_10mmAmmo.show()		
			
			if ButtonPressed == 0
				
				AttachMod(mod_10mm_Receiver_Standard)		
			
			elseif ButtonPressed == 1 
			
				AttachMod(mod_10mm_Receiver_Acid)				
			
			elseif ButtonPressed == 2 
			
				AttachMod(mod_10mm_Receiver_Cryo)			
			
			elseif ButtonPressed == 3 
			
				AttachMod(mod_10mm_Receiver_Electric)		
			
			elseif ButtonPressed == 4 
				
				AttachMod(mod_10mm_Receiver_Explosive)		
			
			elseif ButtonPressed == 5
				
				AttachMod(mod_10mm_Receiver_Frenzy)				
			
			elseif ButtonPressed == 6
				
				AttachMod(mod_10mm_Receiver_Incendiary)				
			
			elseif ButtonPressed == 7
			
				AttachMod(mod_10mm_Receiver_Paralysis)					
			
			elseif ButtonPressed == 8
				
				AttachMod(mod_10mm_Receiver_Poison)					
			
			elseif ButtonPressed == 9
				
				AttachMod(mod_10mm_Receiver_Radiation)				
			
			endif
		
		endif
		
EndEvent
				




Link to comment
Share on other sites

Ok, sorry, I'm just not with it today. :P

 

You will need to create a Quest that uses an OnTimer event to check whether GetEquippedWeapon(int aiEquipIndex = 0) returns your Weapon. If it does, you then display the menu and set a bool to true. Unset that bool when GetEquippedWeapon(int aiEquipIndex = 0) no longer returns your weapon.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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