Script Trouble?

Post » Sat Aug 27, 2011 6:26 am

So I've been trying to make a consle which when activated displays one of two messages, either that the player can make a nuclear grenade or that they don't have the right components. The former displays perfectly but when I try to actvate the latter nothing happens. Here's the script:

Scn DSVampireNukeMakerScript

int Button
short EndImmediately

Begin OnActivate
if Player.GetItemCount FissionBattery >= 5
if Player.GetItemCount SpareParts >= 10
if Player.GetItemCount WeapGrenadeFrag >= 2
Set EndImmediately to 0
ShowMessage DSVampireNuclearHandgrenades

Elseif Player.GetItemCount FissionBattery < 5
if Player.GetItemCount SpareParts < 10
if Player.GetItemCount WeapGrenadeFrag < 2
Set EndImmediately to 1
ShowMessage DSVampireNoItems

Endif
Endif
Endif
Endif
Endif
End

Begin Gamemode
If EndImmediately != 1

Set Button to GetButtonPressed

if Button == 0
Player.additem WeapNVGrenadeFragHoly 1
Player.RemoveItem WeapGrenadeFrag 2
Player.RemoveItem SpareParts 10
Player.RemoveItem FissionBattery 5


Elseif Button == 1

Endif
Endif
Endif
End


Any help would be greatly appreciated!
User avatar
Smokey
 
Posts: 3378
Joined: Mon May 07, 2007 11:35 pm

Post » Sat Aug 27, 2011 8:39 pm

Those nested ifs are a little messy. Try this version and see if works:

Begin OnActivate
If (Player.GetItemCount FissionBattery >= 5) && (Player.GetItemCount SpareParts >= 10) && (Player.GetItemCount WeapGrenadeFrag >= 2)
Set EndImmediately to 0
ShowMessage DSVampireNuclearHandgrenades
Elseif (Player.GetItemCount FissionBattery < 5) || (Player.GetItemCount SpareParts < 10) || (Player.GetItemCount WeapGrenadeFrag < 2)
Set EndImmediately to 1
ShowMessage DSVampireNoItems
Endif
End

Assuming this works, then there was something about one of the item counts you tested with that made it fall out of the if's.


Scratch that, if you don't have enough items to pass the first check you don't need to check again. Try this instead:

Begin OnActivate
If (Player.GetItemCount FissionBattery >= 5) && (Player.GetItemCount SpareParts >= 10) && (Player.GetItemCount WeapGrenadeFrag >= 2)
Set EndImmediately to 0
ShowMessage DSVampireNuclearHandgrenades
Else
Set EndImmediately to 1
ShowMessage DSVampireNoItems
Endif
End
User avatar
Imy Davies
 
Posts: 3479
Joined: Fri Jul 14, 2006 6:42 pm

Post » Sat Aug 27, 2011 5:47 pm

Thank you so much! That worked like a charm!
User avatar
James Baldwin
 
Posts: 3366
Joined: Tue Jun 05, 2007 11:11 am


Return to Fallout: New Vegas