Stewb Posted May 10, 2009 Share Posted May 10, 2009 Hi, i have a problem with my script that i can't work out. Basically it should count the amount of items you wish to turn into scrap metal and give you the relevant amount back and also take all of the item to be scrapped. I've had numerous bugs with it, First people have reported to me when using my mod that it gives the correct amount of scrap metal but only takes one of the intended item (which should be impossible as it is the same Short string for both item removal and item receiving). The second bug is one i encounter myself, it takes the correct amount of items but gives the amount of scrap that the last item gave. I.e i scrapped 50 irons for 250 scrap metal, then scrapped 3 tin cans and still got 250 scrap metal, when i should of got 3 scrap metal. Anyway here is the code, i've just posted the full thing despite it's size so you can see everything that is going on in case something else is affecting it: scn SchematicsWorkbenchAmmoPortableScript short button1 short button1a short button1b short button1c short button2 short button3 short button4 short button5 short HasItems short MenuCh Short Ammo1 Short Ammo2 Short Ammo3 Short Ammo5 Short Ammo25 Short AmmoAll Short AmmoRe short AmmoMult short item1 short item2 short item3 Ref Powder Ref AmmoType Begin OnActivate if IsActionRef player == 1 set HasItems to 0 if GetHasNote Schematics10Note == 1 || GetHasNote Schematics308Note == 1 || GetHasNote Schematics32Note == 1 || GetHasNote Schematics44Note == 1 set HasItems to 1 endif if GetHasNote Schematics556Note == 1 || GetHasNote Schematics5Note == 1 || GetHasNote SchematicsbbNote == 1 || GetHasNote SchematicsmissileNote == 1 set HasItems to 1 endif if GetHasNote SchematicsshellNote == 1 || GetHasNote Schematics10Note10 == 1 || GetHasNote Schematics308Note10 == 1 || GetHasNote Schematics32Note10 == 1 set HasItems to 1 endif if GetHasNote Schematics44Note10 == 1 || GetHasNote Schematics556Note10 == 1 || GetHasNote Schematics5Note10 == 1 || GetHasNote SchematicsbbNote10 == 1 set HasItems to 1 endif if GetHasNote SchematicsmissileNote10 == 1 || GetHasNote SchematicsshellNote10 == 1 || GetHasNote Schematics10Note20 == 1 || GetHasNote Schematics308Note20 == 1 set HasItems to 1 endif if GetHasNote Schematics32Note20 == 1 || GetHasNote Schematics44Note10 == 1 || GetHasNote Schematics556Note20 == 1 || GetHasNote Schematics5Note20 == 1 set HasItems to 1 endif if GetHasNote SchematicsbbNote20 == 1 || GetHasNote SchematicsmissileNote10 == 1 || GetHasNote SchematicsshellNote20 == 1 || GetHasNote SchematicsWorkbenchMetalMeltNote == 1 set HasItems to 1 endif if GetHasNote SchematicsdartNote == 1 || GetHasNote SchematicsecpNote == 1 || GetHasNote SchematicsecNote == 1 || GetHasNote SchematicsffNote == 1 set HasItems to 1 endif if GetHasNote SchematicsmfcNote == 1 || GetHasNote SchematicsnukeNote == 1 || GetHasNote SchematicsrspikeNote == 1 || GetHasNote SchematicsdartNote10 == 1 set HasItems to 1 endif if GetHasNote SchematicsecpNote10 == 1 || GetHasNote SchematicsecNote10 == 1 || GetHasNote SchematicsffNote10 == 1 || GetHasNote SchematicsmfcNote10 == 1 set HasItems to 1 endif if GetHasNote SchematicsnukeNote10 == 1 || GetHasNote SchematicsrspikeNote10 == 1 || GetHasNote SchematicsdartNote20 == 1 || GetHasNote SchematicsecpNote20 == 1 set HasItems to 1 endif if GetHasNote SchematicsecNote20 == 1 || GetHasNote SchematicsffNote20 == 1 || GetHasNote SchematicsmfcNote20 == 1 || GetHasNote SchematicsnukeNote20 == 1 set HasItems to 1 endif if GetHasNote SchematicsplgNote == 1 || GetHasNote SchematicsplmNote == 1 || GetHasNote SchematicspugNote == 1 || GetHasNote SchematicspumNote == 1 set HasItems to 1 endif if GetHasNote SchematicsplgNote10 == 1 || GetHasNote SchematicsplmNote10 == 1 || GetHasNote SchematicspugNote10 == 1 || GetHasNote SchematicspumNote10 == 1 set HasItems to 1 endif if GetHasNote SchematicsplgNote20 == 1 || GetHasNote SchematicsplmNote20 == 1 || GetHasNote SchematicspugNote20 == 1 || GetHasNote SchematicspumNote20 == 1 set HasItems to 1 endif if HasItems == 1 set button1 to -1 ShowMessage SchematicsWorkbenchAmmo0aMsg else ShowMessage SchematicsWorkbenchNoneMsg endif endif End Begin GameMode ; Main Menu if button1 == -1 Set button1 to GetButtonPressed if button1 == 1 ShowMessage SchematicsWorkbenchPCMsg Set MenuCh to 1 Set button1a to -1 return elseif button1 == 2 ShowMessage SchematicsWorkbenchAmountMsg Set MenuCh to 2 Set button1b to -1 return elseif button1 == 3 ShowMessage SchematicsWorkbenchAmountMsg Set MenuCh to 3 Set button1b to -1 return elseif button1 == 4 ShowMessage SchematicsAmmoMeltChoiceMsg Set button1c to -1 return elseif button1 == 5 Activate return endif endif ;Powder Choice if button1a == -1 set button1a to GetButtonPressed if button1a == 0 ShowMessage SchematicsWorkbenchAmountMsg Set Powder to WeapGrenadeFrag Set button1b to -1 return elseif button1a == 1 ShowMessage SchematicsWorkbenchAmountMsg Set Powder to WeapMineFrag Set button1b to -1 return endif endif ;Amount Choice Ammo if button1b == -1 set button1b to GetButtonPressed if button1b == 0 Set Ammo1 to 1 Set Ammo2 to 2 Set Ammo3 to 3 Set Ammo5 to 5 Set Ammo25 to 25 If MenuCh == 1 ShowMessage SchematicsWorkbenchAmmoMsg Set button2 to -1 ElseIf MenuCh == 2 ShowMessage SchematicsWorkbenchAmmo2Msg Set button3 to -1 ElseIf MenuCh == 3 ShowMessage SchematicsWorkbenchAmmo3Msg Set button4 to -1 EndIf return elseif button1b == 1 Set Ammo1 to 10 Set Ammo2 to 20 Set Ammo3 to 30 Set Ammo5 to 50 Set Ammo25 to 250 If MenuCh == 1 ShowMessage SchematicsWorkbenchAmmoMsg Set button2 to -1 ElseIf MenuCh == 2 ShowMessage SchematicsWorkbenchAmmo2Msg Set button3 to -1 ElseIf MenuCh == 3 ShowMessage SchematicsWorkbenchAmmo3Msg Set button4 to -1 EndIf return endif endif ;Amount Choice Scrap if button1c == -1 set button1c to GetButtonPressed if button1c == 1 Set Ammo1 to 1 Set AmmoAll to 0 ShowMessage SchematicsWorkbenchAmmo3aMsg Set button5 to -1 return elseif button1c == 2 Set Ammo1 to 10 Set AmmoAll to 0 ShowMessage SchematicsWorkbenchAmmo3aMsg Set button5 to -1 return elseif button1c == 3 Set Ammo1 to 1 Set AmmoAll to 1 ShowMessage SchematicsWorkbenchAmmo3aMsg Set button5 to -1 return endif endif ;Gunpowder Ammo Menu if button2 == -1 set button2 to GetButtonPressed ; 10mm if button2 == 1 Set AmmoType to Ammo10mm Set AmmoRe to AmmoNorm*Ammo1 if player.gethasNote Schematics10Note Set AmmoMult to 1 elseif player.gethasNote Schematics10Note10 Set AmmoMult to 2 elseif player.gethasNote Schematics10Note20 Set AmmoMult to 3 endif ; .308 elseif button2 == 2 Set AmmoType to Ammo308caliber Set AmmoRe to AmmoScope*Ammo1 if player.gethasNote Schematics308Note Set AmmoMult to 1 elseif player.gethasNote Schematics308Note10 Set AmmoMult to 2 elseif player.gethasNote Schematics308Note20 Set AmmoMult to 3 endif ; .32 elseif button2 == 3 Set AmmoType to Ammo32caliber Set AmmoRe to AmmoNorm*Ammo1 if player.gethasNote Schematics32Note Set AmmoMult to 1 elseif player.gethasNote Schematics32Note10 Set AmmoMult to 2 elseif player.gethasNote Schematics32Note20 Set AmmoMult to 3 endif ; .44 elseif button2 == 4 Set AmmoType to Ammo44magnum Set AmmoRe to AmmoScope*Ammo1 if player.gethasNote Schematics44Note Set AmmoMult to 1 elseif player.gethasNote Schematics44Note10 Set AmmoMult to 2 elseif player.gethasNote Schematics44Note20 Set AmmoMult to 3 endif ; 5.56mm elseif button2 == 5 Set AmmoType to Ammo556mm Set AmmoRe to AmmoAuto*Ammo1 if player.gethasNote Schematics556Note Set AmmoMult to 1 elseif player.gethasNote Schematics556Note10 Set AmmoMult to 2 elseif player.gethasNote Schematics556Note20 Set AmmoMult to 3 endif ; 5mm elseif button2 == 6 Set AmmoType to Ammo5mm Set AmmoRe to AmmoAuto*Ammo1 if player.gethasNote Schematics5Note Set AmmoMult to 1 elseif player.gethasNote Schematics5Note10 Set AmmoMult to 2 elseif player.gethasNote Schematics5Note20 Set AmmoMult to 3 endif ; BB elseif button2 == 7 Set AmmoType to AmmoBB Set AmmoRe to AmmoNorm*Ammo1 if player.gethasNote SchematicsBBNote Set AmmoMult to 1 elseif player.gethasNote SchematicsBBNote10 Set AmmoMult to 2 elseif player.gethasNote SchematicsBBNote20 Set AmmoMult to 3 endif ;Missile elseif button2 == 8 if ( player.GetItemCount SpareParts >= Ammo5) && ( player.GetItemCount Powder >= Ammo5) player.RemoveItem SpareParts Ammo5 1 player.RemoveItem Powder Ammo5 1 if player.gethasNote SchematicsmissileNote Set AmmoRe to (Ammo1*AmmoMiss) player.AddItem Ammomissile AmmoRe elseif player.gethasNote SchematicsmissileNote10 Set AmmoRe to (Ammo1*AmmoMiss*2) player.AddItem Ammomissile AmmoRe elseif player.gethasNote SchematicsmissileNote20 Set AmmoRe to (Ammo1*AmmoMiss*3) player.AddItem Ammomissile AmmoRe endif else set item1 to player.GetItemCount SpareParts set item2 to player.GetItemCount Powder ShowMessage SchematicsWorkbenchFailureAmmoMsg, item1, item2 endif ; Shell elseif button2 == 9 if ( player.GetItemCount SpareParts >= Ammo2) && ( player.GetItemCount Powder >= Ammo1) player.RemoveItem SpareParts Ammo2 1 player.RemoveItem Powder Ammo1 1 if player.gethasNote SchematicsshellNote Set AmmoRe to (Ammo1*AmmoNorm) player.AddItem AmmoShotgunShell AmmoRe elseif player.gethasNote SchematicsshellNote10 Set AmmoRe to (Ammo1*AmmoNorm*2) player.AddItem AmmoShotgunShell AmmoRe elseif player.gethasNote SchematicsshellNote20 Set AmmoRe to (Ammo1*AmmoNorm*3) player.AddItem AmmoShotgunShell AmmoRe endif else set item1 to player.GetItemCount SpareParts set item2 to player.GetItemCount Powder ShowMessage SchematicsWorkbenchFailureAmmoMsg, item1, item2 endif endif endif ;Energy Ammo Menu if ( Button3 == -1 ) Set Powder to FissionBattery set button3 to GetButtonPressed ; Dart if button3 == 1 Set Powder to AmmoIngBlank Player.additem AmmoIngBlank 1 Set AmmoType to AmmoDart Set AmmoRe to AmmoNorm*Ammo1 if player.gethasNote SchematicsDartNote Set AmmoMult to 1 elseif player.gethasNote SchematicsDartNote10 Set AmmoMult to 2 elseif player.gethasNote SchematicsDartNote20 Set AmmoMult to 3 endif ; ECP elseif button3 == 2 Set AmmoType to AmmoElectronChargePack Set AmmoRe to AmmoAuto*Ammo1 if player.gethasNote SchematicsECPNote Set AmmoMult to 1 elseif player.gethasNote SchematicsECPNote10 Set AmmoMult to 2 elseif player.gethasNote SchematicsECPNote20 Set AmmoMult to 3 endif ; EC elseif button3 == 3 Set AmmoType to AmmoSmallEnergyCell Set AmmoRe to AmmoNorm*Ammo1 if player.gethasNote SchematicsECNote Set AmmoMult to 1 elseif player.gethasNote SchematicsECNote10 Set AmmoMult to 2 elseif player.gethasNote SchematicsECNote20 Set AmmoMult to 3 endif ; FF elseif button3 == 4 if ( player.GetItemCount SpareParts >= Ammo1) && ( player.GetItemCount Scotch >= Ammo1) && ( player.GetItemCount Whiskey >= Ammo1) player.RemoveItem SpareParts Ammo1 1 player.RemoveItem Scotch Ammo1 1 player.RemoveItem Whiskey Ammo1 1 if player.gethasNote SchematicsffNote Set AmmoRe to (Ammo1*AmmoAuto) player.AddItem AmmoFlamerFuel AmmoRe elseif player.gethasNote SchematicsffNote10 Set AmmoRe to (Ammo1*AmmoAuto*2) player.AddItem AmmoFlamerFuel AmmoRe elseif player.gethasNote SchematicsffNote20 Set AmmoRe to (Ammo1*AmmoAuto*3) player.AddItem AmmoFlamerFuel AmmoRe endif else set item1 to player.GetItemCount SpareParts set item2 to player.GetItemCount Scotch set item3 to player.GetItemCount Whiskey ShowMessage SchematicsWorkbenchFailureAmmoFlameMsg, item1, item2, item3 endif ; MFC elseif button3 == 5 Set AmmoType to AmmoMicroFusionCell Set AmmoRe to AmmoNorm*Ammo1 if player.gethasNote SchematicsMFCNote Set AmmoMult to 1 elseif player.gethasNote SchematicsMFCNote10 Set AmmoMult to 2 elseif player.gethasNote SchematicsMFCNote20 Set AmmoMult to 3 endif ; Nuke elseif button3 == 6 if ( player.GetItemCount SpareParts >= Ammo5) && ( player.GetItemCount AbraxoCleaner >= Ammo5) && ( player.GetItemCount Turpentine >= Ammo5) player.RemoveItem SpareParts Ammo5 1 player.RemoveItem AbraxoCleaner Ammo5 1 player.RemoveItem Turpentine Ammo5 1 if player.gethasNote SchematicsnukeNote Set AmmoRe to (Ammo1*AmmoNuke) player.AddItem AmmoFatMan AmmoRe elseif player.gethasNote SchematicsnukeNote10 Set AmmoRe to (Ammo1*AmmoNuke*2) player.AddItem AmmoFatMan AmmoRe elseif player.gethasNote SchematicsnukeNote20 Set AmmoRe to (Ammo1*AmmoNuke*3) player.AddItem AmmoFatMan AmmoRe endif else set item1 to player.GetItemCount SpareParts set item2 to player.GetItemCount AbraxoCleaner set item3 to player.GetItemCount Turpentine ShowMessage SchematicsWorkbenchFailureAmmoNukeMsg, item1, item2, item3 endif ; Spike elseif button3 == 7 Set Powder to SpareParts Set AmmoType to AmmoRailwaySpikes Set AmmoRe to AmmoNorm*Ammo1 if player.gethasNote SchematicsRSpikeNote Set AmmoMult to 1 elseif player.gethasNote SchematicsRSpikeNote10 Set AmmoMult to 2 elseif player.gethasNote SchematicsRSpikeNote20 Set AmmoMult to 3 endif endif endif ;Adding Ammo If AmmoMult > 0 if ( player.GetItemCount SpareParts >= Ammo1) && ( player.GetItemCount Powder >= Ammo1) player.RemoveItem SpareParts Ammo1 1 player.RemoveItem Powder Ammo1 1 Set AmmoRe to (AmmoRe*AmmoMult) player.AddItem AmmoType AmmoRe Set AmmoMult to 0 else set item1 to player.GetItemCount SpareParts set item2 to player.GetItemCount Powder ShowMessage SchematicsWorkbenchFailureAmmoMsg, item1, item2 endif EndIf ;Explosives Menu if ( button4 == -1 ) set button4 to GetButtonPressed ;PLG if button4 == 1 if ( player.GetItemCount SpareParts >= Ammo1) && ( player.GetItemCount AmmoMicroFusionCell >= Ammo25) player.RemoveItem SpareParts Ammo1 1 player.RemoveItem AmmoMicroFusionCell Ammo25 1 if player.gethasNote SchematicsplgNote Set AmmoRe to (Ammo1) player.AddItem WeapGrenadePlasma AmmoRe elseif player.gethasNote SchematicsplgNote10 Set AmmoRe to (Ammo1*2) player.AddItem WeapGrenadePlasma AmmoRe elseif player.gethasNote SchematicsplgNote20 Set AmmoRe to (Ammo1*3) player.AddItem WeapGrenadePlasma AmmoRe endif else set item1 to player.GetItemCount SpareParts set item2 to player.GetItemCount AmmoMicroFusionCell ShowMessage SchematicsWorkbenchFailureAmmoPlasmaMsg, item1, item2 endif ; PLM elseif button4 == 2 if ( player.GetItemCount SpareParts >= Ammo1) && ( player.GetItemCount AmmoMicroFusionCell >= Ammo25) player.RemoveItem SpareParts Ammo1 1 player.RemoveItem AmmoMicroFusionCell Ammo25 1 if player.gethasNote SchematicsplmNote Set AmmoRe to (Ammo1) player.AddItem WeapMinePlasma AmmoRe elseif player.gethasNote SchematicsplmNote10 Set AmmoRe to (Ammo1*2) player.AddItem WeapMinePlasma AmmoRe elseif player.gethasNote SchematicsplmNote20 Set AmmoRe to (Ammo1*3) player.AddItem WeapMinePlasma AmmoRe endif else set item1 to player.GetItemCount SpareParts set item2 to player.GetItemCount AmmoMicroFusionCell ShowMessage SchematicsWorkbenchFailureAmmoPlasmaMsg, item1, item2 endif ; PUG elseif button4 == 3 if ( player.GetItemCount SpareParts >= Ammo1) && ( player.GetItemCount AmmoSmallEnergyCell >= Ammo25) player.RemoveItem SpareParts Ammo1 1 player.RemoveItem AmmoSmallEnergyCell Ammo25 1 if player.gethasNote SchematicspugNote Set AmmoRe to (Ammo1) player.AddItem WeapGrenadePulse AmmoRe elseif player.gethasNote SchematicspugNote10 Set AmmoRe to (Ammo1*2) player.AddItem WeapGrenadePulse AmmoRe elseif player.gethasNote SchematicspugNote20 Set AmmoRe to (Ammo1*3) player.AddItem WeapGrenadePulse AmmoRe endif else set item1 to player.GetItemCount SpareParts set item2 to player.GetItemCount AmmoSmallEnergyCell ShowMessage SchematicsWorkbenchFailureAmmoPulseMsg, item1, item2 endif ; PUM elseif button4 == 4 if ( player.GetItemCount SpareParts >= Ammo1) && ( player.GetItemCount AmmoSmallEnergyCell >= Ammo25) player.RemoveItem SpareParts Ammo1 1 player.RemoveItem AmmoSmallEnergyCell Ammo25 1 if player.gethasNote SchematicspumNote Set AmmoRe to (Ammo1) player.AddItem WeapMinePulse AmmoRe elseif player.gethasNote SchematicspumNote10 Set AmmoRe to (Ammo1*2) player.AddItem WeapMinePulse AmmoRe elseif player.gethasNote SchematicspumNote20 Set AmmoRe to (Ammo1*3) player.AddItem WeapMinePulse AmmoRe endif else set item1 to player.GetItemCount SpareParts set item2 to player.GetItemCount AmmoSmallEnergyCell ShowMessage SchematicsWorkbenchFailureAmmoPulseMsg, item1, item2 endif endif endif ; Scrap Metal if ( button5 == -1) Set button5 to GetButtonPressed ; Iron if button5 == 1 if (player.GetItemCount Iron >= Ammo1) If AmmoAll == 1 Set Ammo1 to (player.GetItemCount Iron) EndIf player.removeitem Iron Ammo1 1 Set AmmoRe to (Ammo1*5) player.additem SpareParts AmmoRe else set item1 to player.GetItemCount Iron ShowMessage SchematicsWorkbenchFailureMetalMsg, item1 endif ; TPO elseif button5 == 2 if (player.GetItemCount ToasterPostWar >= Ammo1) If AmmoAll == 1 Set Ammo1 to (player.GetItemCount ToasterPostWar) EndIf player.removeitem ToasterPostWar Ammo1 1 Set Ammo1 to (Ammo1*3) player.additem SpareParts AmmoRe else set item1 to player.GetItemCount ToasterPostWar ShowMessage SchematicsWorkbenchFailureMetalMsg, item1 endif ; TPR elseif button5 == 3 if (player.GetItemCount ToasterPreWar >= Ammo1) If AmmoAll == 1 Set Ammo1 to (player.GetItemCount ToasterPreWar) EndIf player.removeitem ToasterPreWar Ammo1 1 player.additem SpareParts AmmoRe else set item1 to player.GetItemCount ToasterPreWar ShowMessage SchematicsWorkbenchFailureMetalMsg, item1 endif ; Nuka elseif button5 == 4 if (player.GetItemCount NukaTruck >= Ammo1) If AmmoAll == 1 Set Ammo1 to (player.GetItemCount NukaTruck) EndIf player.removeitem NukaTruck Ammo1 1 player.additem SpareParts AmmoRe else set item1 to player.GetItemCount NukaTruck ShowMessage SchematicsWorkbenchFailureMetalMsg, item1 endif ; Pot elseif button5 == 5 if (player.GetItemCount BigPot >= Ammo1) If AmmoAll == 1 Set Ammo1 to (player.GetItemCount BigPot) EndIf player.removeitem BigPot Ammo1 1 player.additem SpareParts AmmoRe else set item1 to player.GetItemCount BigPot ShowMessage SchematicsWorkbenchFailureMetalMsg, item1 endif ; BTC elseif button5 == 6 if (player.GetItemCount TinCan02 >= Ammo1) If AmmoAll == 1 Set Ammo1 to (player.GetItemCount TinCan02) EndIf player.removeitem TinCan02 Ammo1 1 player.additem SpareParts AmmoRe else set item1 to player.GetItemCount TinCan02 ShowMessage SchematicsWorkbenchFailureMetalMsg, item1 endif ; TC elseif button5 == 7 if (player.GetItemCount TinCan01 >= Ammo1) If AmmoAll == 1 Set Ammo1 to (player.GetItemCount TinCan01) EndIf player.removeitem TinCan01 Ammo1 1 player.additem SpareParts AmmoRe else set item1 to player.GetItemCount TinCan01 ShowMessage SchematicsWorkbenchFailureMetalMsg, item1 endif ; MCPo elseif button5 == 8 if (player.GetItemCount PotCookingMetal >= Ammo1) If AmmoAll == 1 Set Ammo1 to (player.GetItemCount PotCookingMetal) EndIf player.removeitem PotCookingMetal Ammo1 1 player.additem SpareParts AmmoRe else set item1 to player.GetItemCount PotCookingMetal ShowMessage SchematicsWorkbenchFailureMetalMsg, item1 endif ; MCPa elseif button5 == 9 if (player.GetItemCount PanCookingMetal >= Ammo1) If AmmoAll == 1 Set Ammo1 to (player.GetItemCount PanCookingMetal) EndIf player.removeitem PanCookingMetal Ammo1 1 player.additem SpareParts AmmoRe else set item1 to player.GetItemCount PanCookingMetal ShowMessage SchematicsWorkbenchFailureMetalMsg, item1 endif endif endif End Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.