darthbdaman Posted June 23, 2016 Share Posted June 23, 2016 So this script is supposed to set the shellcasing of all the weapons someone has loaded depending on the ammotype of the weapons. The problem I have is that every single weapon is set to use the whatever the first ammo check is. Currently that is 10mm. Every weapons is recognized as being 10mm, and given 45cal shells, no matter what ammo list it has. I feel like I am making a simple mistake somewhere, but I need a second opinion scn IMPACTWeaponsScript array_var Entry ref rGun ref rAmmo string_var sTestShell begin GameMode if GetGameRestarted GetLoadedType IMPACTWeapons 40 foreach Entry <- (GetListForms IMPACTWeapons) let rGun := *Entry let rAmmo := GetWeaponAmmo rGun if rAmmo ;10mm if ((rAmmo == AmmoList10mm) || (IsRefInList AmmoList10mm rAmmo)) SetWeaponShellCasingModel rGun "EVE\shellcasings\45cal_shellcasing.nif" ;308, 50mg else if ((rAmmo == AmmoList308) || (IsRefInList AmmoList308 rAmmo) || (rAmmo == AmmoList50MG) || (IsRefInList AmmoList50MG rAmmo)) SetWeaponShellCasingModel rGun "EVE\shellcasings\762mm_shellcasing.nif" ;5mm else if ((rAmmo == AmmoList5mm) || (IsRefInList AmmoList5mm rAmmo)) SetWeaponShellCasingModel rGun "EVE\shellcasings\762mm_shellcasing.nif" ;12ga else if ((rAmmo == AmmoList12Ga) || (IsRefInList AmmoList12Ga rAmmo)) SetWeaponShellCasingModel rGun "EVE\shellcasings\12ga_shotgunshell.nif" ;556mm else if ((rAmmo == AmmoList556mm) || (IsRefInList AmmoList556mm rAmmo)) SetWeaponShellCasingModel rGun "EVE\shellcasings\556mm_shellcasing.nif" ;44 else if ((rAmmo == AmmoList44Magnum) || (IsRefInList AmmoList44Magnum rAmmo)) SetWeaponShellCasingModel rGun "EVE\shellcasings\44mag_shellcasing.nif" ;20ga else if ((rAmmo == AmmoList20Ga) || (IsRefInList AmmoList20Ga rAmmo)) SetWeaponShellCasingModel rGun "EVE\shellcasings\20ga_shotgunshell.nif" ;12.7 else if ((rAmmo == AmmoList127mm) || (IsRefInList AmmoList127mm rAmmo)) SetWeaponShellCasingModel rGun "EVE\shellcasings\45cal_shellcasing.nif" ;45.70 else if ((rAmmo == AmmoList4570) || (IsRefInList AmmoList4570 rAmmo)) SetWeaponShellCasingModel rGun "EVE\shellcasings\4570mm_shellcasing.nif" ;357 else if ((rAmmo == AmmoList357Magnum) || (IsRefInList AmmoList357Magnum rAmmo)) SetWeaponShellCasingModel rGun "EVE\shellcasings\357mag_shellcasing.nif" ;9mm else if ((rAmmo == AmmoList9mm) || (IsRefInList AmmoList9mm rAmmo)) SetWeaponShellCasingModel rGun "EVE\shellcasings\9mm_shellcasing.nif" ;22lr else if ((rAmmo == AmmoList22LR) || (IsRefInList AmmoList22LR rAmmo)) SetWeaponShellCasingModel rGun "EVE\shellcasings\556mm_shellcasing.nif" endif loop let sTestShell := GetWeaponShellCasingModel WeapNV9mmPistol print $sTestShell endif end Link to comment Share on other sites More sharing options...
Ladez Posted June 23, 2016 Share Posted June 23, 2016 You have a missing endif statement causing the loop to fail in the first iteration. Also, I think that the way you're checking with IsRefInList is ineffective. The function returns the index which can be zero, if the form is not in the list it returns -1. Link to comment Share on other sites More sharing options...
darthbdaman Posted June 23, 2016 Author Share Posted June 23, 2016 Alright. Is this better? rAmmo.IsInList AmmoList308 Link to comment Share on other sites More sharing options...
Ladez Posted June 23, 2016 Share Posted June 23, 2016 Pretty sure that won't work, you're getting a base form from GetWeaponAmmo, not a reference. I was thinking more like this: IsRefInList AmmoList9mm rAmmo >= 0 Link to comment Share on other sites More sharing options...
darthbdaman Posted June 23, 2016 Author Share Posted June 23, 2016 Alright, so stuff is much weirder now. That fixes the first one, but after that, it doesn't. All weapons will get the shellcasing listed in the first "else if" statement, no matter what that is, unless they meet the criteria for the first check, in which case they actually have the correct casings. (i've rearranged it multiple times) scn IMPACTWeaponsScript array_var Entry ref rGun ref rAmmo string_var sTestShell begin GameMode if GetGameRestarted GetLoadedType IMPACTWeapons 40 foreach Entry <- (GetListForms IMPACTWeapons) let rGun := *Entry let rAmmo := GetWeaponAmmo rGun if rAmmo ;9mm if ((rAmmo == AmmoList9mm) || (IsRefInList AmmoList9mm rAmmo >= 0)) SetWeaponShellCasingModel rGun "EVE\shellcasings\9mm_shellcasing.nif" ;10mm else if ((rAmmo == AmmoList10mm) || (IsRefInList AmmoList10mm rAmmo >= 0)) SetWeaponShellCasingModel rGun "EVE\shellcasings\45cal_shellcasing.nif" ;308, 50mg else if ((rAmmo == AmmoList308) || (IsRefInList AmmoList308 rAmmo >= 0) || (rAmmo == AmmoList50MG) || (IsRefInList AmmoList50MG rAmmo >= 0)) SetWeaponShellCasingModel rGun "EVE\shellcasings\762mm_shellcasing.nif" ;5mm else if ((rAmmo == AmmoList5mm) || (IsRefInList AmmoList5mm rAmmo >= 0)) SetWeaponShellCasingModel rGun "EVE\shellcasings\762mm_shellcasing.nif" ;12ga else if ((rAmmo == AmmoList12Ga) || (IsRefInList AmmoList12Ga rAmmo >= 0)) SetWeaponShellCasingModel rGun "EVE\shellcasings\12ga_shotgunshell.nif" ;556mm else if ((rAmmo == AmmoList556mm) || (IsRefInList AmmoList556mm rAmmo >= 0)) SetWeaponShellCasingModel rGun "EVE\shellcasings\556mm_shellcasing.nif" ;44 else if ((rAmmo == AmmoList44Magnum) || (IsRefInList AmmoList44Magnum rAmmo >= 0)) SetWeaponShellCasingModel rGun "EVE\shellcasings\44mag_shellcasing.nif" ;20ga else if ((rAmmo == AmmoList20Ga) || (IsRefInList AmmoList20Ga rAmmo >= 0)) SetWeaponShellCasingModel rGun "EVE\shellcasings\20ga_shotgunshell.nif" ;12.7 else if ((rAmmo == AmmoList127mm) || (IsRefInList AmmoList127mm rAmmo >= 0)) SetWeaponShellCasingModel rGun "EVE\shellcasings\45cal_shellcasing.nif" ;45.70 else if ((rAmmo == AmmoList4570) || (IsRefInList AmmoList4570 rAmmo >= 0)) SetWeaponShellCasingModel rGun "EVE\shellcasings\4570mm_shellcasing.nif" ;357 else if ((rAmmo == AmmoList357Magnum) || (IsRefInList AmmoList357Magnum rAmmo >= 0)) SetWeaponShellCasingModel rGun "EVE\shellcasings\357mag_shellcasing.nif" ;22lr else if ((rAmmo == AmmoList22LR) || (IsRefInList AmmoList22LR rAmmo >= 0)) SetWeaponShellCasingModel rGun "EVE\shellcasings\556mm_shellcasing.nif" endif endif loop let sTestShell := GetWeaponShellCasingModel WeapNV9mmPistol ;Returns 9mm shell casing, correct print $sTestShell let sTestShell := GetWeaponShellCasingModel WeapNVHuntingRevolver ;Returns 45 casing from 10mm check, incorrect print $sTestShell endif end Link to comment Share on other sites More sharing options...
Ladez Posted June 23, 2016 Share Posted June 23, 2016 The problem seems to be that your elseif statements are separated into "else if". They need to be collapsed into single words. Link to comment Share on other sites More sharing options...
darthbdaman Posted June 23, 2016 Author Share Posted June 23, 2016 Im f*#@ing retarded. Thank you Link to comment Share on other sites More sharing options...
Ladez Posted June 23, 2016 Share Posted June 23, 2016 No problem. Easy to glance over obvious problems like this. :P Link to comment Share on other sites More sharing options...
Recommended Posts