pxd2050 Posted April 8, 2021 Share Posted April 8, 2021 (edited) I make a mod to change npc wigs color,but when load game,wigs color change back.I try event onload(),It don't work when load game until npc go to another cell.someone can help. Scriptname outfit__MainScript extends ReferenceAlias ............. ColorForm _hairColor = None EVENT OnLoad() wait(0.25) UnStrip() HairColorSet EndEVENT Function HairColorSet() ActorRef = self.GetActorRef() ActorBase ActorB = ActorRef.GetActorBase() int red int green int blue if !HasIntValue(ActorRef, "Red0") int hp = ActorB.GetIndexOfHeadPartByType(3) string hpname = ActorB.GetNthHeadPart(hp).GetPartName() int HairTintColor = NiOverride.GetNodePropertyInt(ActorRef,false,hpname,7,-1) red = GetRed(HairTintColor) green = GetGreen(HairTintColor) blue = GetBlue(HairTintColor) SetIntValue(ActorRef,"Red0",Red) SetIntValue(ActorRef,"Green0",Green) SetIntValue(ActorRef,"Blue0",Blue) else red = GetIntValue(ActorRef,"Red0") green = GetIntValue(ActorRef,"Green0") blue = GetIntValue(ActorRef,"Blue0") endif red = red/2 green = green/2 blue = blue/2 int color = 65536*red + 256*green + blue _hairColor = ActorB.GetHairColor() _hairColor.setcolor(color) ActorB.SetHairColor(_hairColor) ActorRef.QueueNiNodeUpdate() EndFunction .....................ps:this mod work with skee.dll(racemenu) Edited April 8, 2021 by pxd2050 Link to comment Share on other sites More sharing options...
AnishaDawn Posted April 8, 2021 Share Posted April 8, 2021 https://www.creationkit.com/index.php?title=OnPlayerLoadGame_-_Actor Link to comment Share on other sites More sharing options...
pxd2050 Posted April 8, 2021 Author Share Posted April 8, 2021 https://www.creationkit.com/index.php?title=OnPlayerLoadGame_-_ActorThank you for your reply. I tried this and it didn't work. Link to comment Share on other sites More sharing options...
dylbill Posted April 8, 2021 Share Posted April 8, 2021 For OnPlayerLoadGame you have to use it on a reference alias pointing to the player, or on an ability's magic effect that's on the player. Link to comment Share on other sites More sharing options...
pxd2050 Posted April 8, 2021 Author Share Posted April 8, 2021 For OnPlayerLoadGame you have to use it on a reference alias pointing to the player, or on an ability's magic effect that's on the player.Thank, this mod is used on npcs,so OnPlayerLoadGame is not a correct event. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted April 9, 2021 Share Posted April 9, 2021 Looking at your code, pretty sure you've got SKSE involved somewhere. You can still use OnPlayerLoadGame to remotely trigger functions on the NPC aliases. Here is a solution that will work (needs tested for compilation and function). It uses the following:OnPlayerLoadGameRegisterForSingleUpdateOnUpdateRegisterForModEvent -- requires SKSESendModEvent -- requires SKSE Script on NPC aliases: Scriptname outfit__MainScript extends ReferenceAlias ............. ColorForm _hairColor = None EVENT OnInit() RegisterForSingleUpdate(0.25) ;short update registration -- allows bypassing that some quests trigger OnInit twice EndEVENT Event OnUpdate() RegisterForModEvent("pxd_LoadGame","pxdOnLoadGame") EndEvent Event pxdOnLoadGame(string eventName, string strArg, float numArg, Form sender) UnStrip() HairColorSet() EndEvent Function UnStrip() ; do stuff EndFunction Function HairColorSet() ; do stuff EndFunction The player alias script: Scriptname SomePlayerAliasScript Extends ReferenceAlias Event OnPlayerLoadGame() RegisterForSingleUpdate(5.0) ; wait to ensure the NPC aliases have setup and registered for the mod event EndEvent Event OnUpdate() SendModEvent("pxd_LoadGame") EndEvent Link to comment Share on other sites More sharing options...
pxd2050 Posted April 9, 2021 Author Share Posted April 9, 2021 (edited) Looking at your code, pretty sure you've got SKSE involved somewhere. You can still use OnPlayerLoadGame to remotely trigger functions on the NPC aliases. Here is a solution that will work (needs tested for compilation and function). It uses the following:OnPlayerLoadGameRegisterForSingleUpdateOnUpdateRegisterForModEvent -- requires SKSESendModEvent -- requires SKSE Script on NPC aliases: Scriptname outfit__MainScript extends ReferenceAlias ............. ColorForm _hairColor = None EVENT OnInit() RegisterForSingleUpdate(0.25) ;short update registration -- allows bypassing that some quests trigger OnInit twice EndEVENT Event OnUpdate() RegisterForModEvent("pxd_LoadGame","pxdOnLoadGame") EndEvent Event pxdOnLoadGame(string eventName, string strArg, float numArg, Form sender) UnStrip() HairColorSet() EndEvent Function UnStrip() ; do stuff EndFunction Function HairColorSet() ; do stuff EndFunction The player alias script: Scriptname SomePlayerAliasScript Extends ReferenceAlias Event OnPlayerLoadGame() RegisterForSingleUpdate(5.0) ; wait to ensure the NPC aliases have setup and registered for the mod event EndEvent Event OnUpdate() SendModEvent("pxd_LoadGame") EndEvent thank you very much,I have solved this problem with onplayerloadgame (). But I find your method more useful. Next, I will try the method you provided. :thumbsup: :thumbsup: :thumbsup: Edited April 9, 2021 by pxd2050 Link to comment Share on other sites More sharing options...
Recommended Posts