VenomousHail Posted June 9, 2016 Share Posted June 9, 2016 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 More sharing options...
Reneer Posted June 9, 2016 Share Posted June 9, 2016 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 More sharing options...
VenomousHail Posted June 9, 2016 Author Share Posted June 9, 2016 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 More sharing options...
Reneer Posted June 10, 2016 Share Posted June 10, 2016 Oh, also remove the "native" bit from your Event code. It shouldn't be there. Link to comment Share on other sites More sharing options...
VenomousHail Posted June 10, 2016 Author Share Posted June 10, 2016 When I do that I get a bunch of errors the first one being, new event onitemequipped cannot be defined because the script is not flagged as native Link to comment Share on other sites More sharing options...
Reneer Posted June 10, 2016 Share Posted June 10, 2016 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 More sharing options...
VenomousHail Posted June 10, 2016 Author Share Posted June 10, 2016 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 More sharing options...
Reneer Posted June 10, 2016 Share Posted June 10, 2016 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 More sharing options...
VenomousHail Posted June 10, 2016 Author Share Posted June 10, 2016 Oh you're great, just one more question for the night, do I need to attach that quest to this script or make a new one? It would be this one right? Link to comment Share on other sites More sharing options...
Reneer Posted June 10, 2016 Share Posted June 10, 2016 You would need to make a new quest, then attach the script to the quest. Make sure that the quest is "Start Game Enabled" and not "Runs Once". Link to comment Share on other sites More sharing options...
Recommended Posts