jags78 Posted September 17, 2018 Share Posted September 17, 2018 Hey Scripters I'm trying to use the 'CastAs' function to trigger regis2k's outfit switcher mod. Here a snippet from my test-script: If akTarget == PlayerRef && akCaster == PlayerRef && akEffect == WDC_PillMagicEffect ScriptObject scrOutfitSwitcher = PlayerRef.CastAs("OutfitSwitcher") If scrOutfitSwitcher int loadout = 1 bool silent = false bool force = false Var[] param = new Var[3] param[0] = loadout param[1] = silent param[2] = force scrOutfitSwitcher.CallFunction("ApplyLoadout", param) Else Debug.Notification("Ups...") EndIf RegisterForMagicEffectApplyEvent(PlayerREF, PlayerREF, WDC_PillMagicEffect, true) EndIf The Event get triggered, but i get the "Ups..." notification. Does someone c the error? Does this even work with quest-related scripts? Link to comment Share on other sites More sharing options...
Reneer Posted September 17, 2018 Share Posted September 17, 2018 You need to get the script from the other mod by using GetFormFromFile then use CastAs on that found form, not simply on the player. Link to comment Share on other sites More sharing options...
jags78 Posted September 17, 2018 Author Share Posted September 17, 2018 Jep... That was it... Thx Reneer. You're the man. I case somebody cares what the test-code looks like: Event OnMagicEffectApply(ObjectReference akTarget, ObjectReference akCaster, MagicEffect akEffect) If akTarget == PlayerRef && akCaster == PlayerRef && akEffect == WDC_PillMagicEffect If Game.IsPluginInstalled("OutfitSwitcher.esp") Quest qOutfitSwitcher = Game.GetFormFromFile(0x00000802, "OutfitSwitcher.esp") as Quest ScriptObject scrOutfitSwitcher = qOutfitSwitcher.CastAs("OutfitSwitcher") If scrOutfitSwitcher int loadout = 1 bool silent = false bool force = false Var[] param = new Var[3] param[0] = loadout param[1] = silent param[2] = force scrOutfitSwitcher.CallFunction("ApplyLoadout", param) Else Debug.Notification("Ups...") EndIf RegisterForMagicEffectApplyEvent(PlayerREF, PlayerREF, WDC_PillMagicEffect, true) Else Debug.Notification("OutfitSwitcher not installed") RegisterForMagicEffectApplyEvent(PlayerREF, PlayerREF, WDC_PillMagicEffect, true) EndIf EndIf EndEvent C u when the next problem arises ;) Link to comment Share on other sites More sharing options...
Reneer Posted September 18, 2018 Share Posted September 18, 2018 Happy to help. :) Link to comment Share on other sites More sharing options...
Recommended Posts