Akatosh2903 Posted November 6, 2011 Share Posted November 6, 2011 (edited) I can't save this script because it is nested, how do I remove the nest? ScriptName 0AutoFireModScript int WeaponHealth1 begin if player.getEquipped == WeapChinesePistol begin OnEquip player set WeaponHealth1 to GetWeaponHealthPerc player.RemoveItem WeapChinesePistol 1 player.AddItem 0MauserFullAuto 1 player.EquipItem 0MauserFullAuto 0 1 player.SetWeaponHealthPerc to WeaponHealth1 end else ShowMessage 0WeapModWontWork endif end int WeaponHealth2 begin if player.getEquipped == 0MauserFullAuto begin OnEquip player set WeaponHealth2 to GetWeaponHealthPerc2 player.RemoveItem 0MauserFullAuto 1 player.AddItem WeapChinesePistol 1 player.EquipItem WeapChinesePistol player.SetWeaponHealthPerc to WeaponHealth2 end endif end Edited November 6, 2011 by Akatosh2903 Link to comment Share on other sites More sharing options...
Akatosh2903 Posted November 6, 2011 Author Share Posted November 6, 2011 bump Link to comment Share on other sites More sharing options...
ElderMalaclypse Posted November 6, 2011 Share Posted November 6, 2011 I am far from an advanced scripter but I do know that it should look more like this: ScriptName 0AutoFireModScript int WeaponHealth1 int WeaponHealth2 Begin OnEquip player if player.getEquipped == WeapChinesePistol set WeaponHealth1 to GetWeaponHealthPerc player.RemoveItem WeapChinesePistol 1 player.AddItem 0MauserFullAuto 1 player.EquipItem 0MauserFullAuto 0 1 player.SetWeaponHealthPerc to WeaponHealth1 else ShowMessage 0WeapModWontWork endif if player.getEquipped == 0MauserFullAuto set WeaponHealth2 to GetWeaponHealthPerc2 player.RemoveItem 0MauserFullAuto 1 player.AddItem WeapChinesePistol 1 player.EquipItem WeapChinesePistol player.SetWeaponHealthPerc to WeaponHealth2 endif End Like I said my scripting syntax is not terribly fluent but as far as structure this should be closer to what your looking for. Link to comment Share on other sites More sharing options...
blove Posted November 6, 2011 Share Posted November 6, 2011 Remove the "==" from the response above. Link to comment Share on other sites More sharing options...
rickerhk Posted November 7, 2011 Share Posted November 7, 2011 Besides getting rid of the ==, don't name items so they begin with a number if you want to use them in scripts. Link to comment Share on other sites More sharing options...
caramellcube Posted November 8, 2011 Share Posted November 8, 2011 (edited) The compiler shouldn't reject nested If statements, I've used a fair few before. It just means you have IF statements inside other IF statements, like this if light switch on if bulb in socket bulb lights up endifendif it looks like there's a few problems with the syntax of the script that might stop it from compiling though. I'm not sure but I don't think you can put a begin block inside an IF statement, or have a begin block without a condition (so just writing Begin on a line might not work, whereas writing Begin OnActivate, or Begin OnEquip should, because the compiler needs to know when to begin). I'd say ElderMalaclypse's code should work apart from the == in the getequipped lines.You could try this though:(sorry, had a go at editing the code before I saw yours, then posted accidentally before I'd finished, anyway hope it helps at least) ScriptName 0AutoFireModScript int WeaponHealth1 int WeaponHealth2 begin OnEquip player if player.getEquipped WeapChinesePistol set WeaponHealth1 to GetWeaponHealthPerc player.RemoveItem WeapChinesePistol 1 player.AddItem 0MauserFullAuto 1 player.EquipItem 0MauserFullAuto 0 1 player.SetWeaponHealthPerc to WeaponHealth1 elseif player.getEquipped 0MauserFullAuto set WeaponHealth2 to GetWeaponHealthPerc2 player.RemoveItem 0MauserFullAuto 1 player.AddItem WeapChinesePistol 1 player.EquipItem WeapChinesePistol player.SetWeaponHealthPerc to WeaponHealth2 else ShowMessage 0WeapModWontWork endif end Edited November 8, 2011 by caramellcube Link to comment Share on other sites More sharing options...
Akatosh2903 Posted November 15, 2011 Author Share Posted November 15, 2011 Thanks guys :thumbsup:I've got it working now. Link to comment Share on other sites More sharing options...
Recommended Posts