MadGodMods Posted September 29, 2016 Share Posted September 29, 2016 I've attached this script to an Actor, and I want it to fire up as soon as the game loads up, but for some reason it does not. I've tried using OnInit(), OnLoad(), and OnPlayerLoadGame() as events, and none of them seem to do the trick. Just from looking at the script can anybody tell me why it won't fire up when the game starts? Scriptname ICOM_FindMySquadScript extends Actor Faction Property ICOM_AlphaFaction Auto Faction Property ICOM_BravoFaction Auto Faction Property ICOM_CharlieFaction Auto Faction Property ICOM_DeltaFaction Auto Faction Property ICOM_EchoFaction Auto Faction Property ICOM_FoxtrotFaction Auto Faction Property ICOM_GolfFaction Auto Faction Property ICOM_HotelFaction Auto Faction Property ICOM_IndiaFaction Auto Faction Property ICOM_JuliettFaction Auto RefCollectionAlias Property AlphaCollection Auto RefCollectionAlias Property BravoCollection Auto RefCollectionAlias Property CharlieCollection Auto RefCollectionAlias Property DeltaCollection Auto RefCollectionAlias Property EchoCollection Auto RefCollectionAlias Property FoxtrotCollection Auto RefCollectionAlias Property GolfCollection Auto RefCollectionAlias Property HotelCollection Auto RefCollectionAlias Property IndiaCollection Auto RefCollectionAlias Property JuliettCollection Auto Event OnInit() If IsInFaction(ICOM_AlphaFaction) == 1; Alpha AlphaCollection.AddRef(self) BravoCollection.RemoveRef(self) CharlieCollection.RemoveRef(self) DeltaCollection.RemoveRef(self) EchoCollection.RemoveRef(self) FoxtrotCollection.RemoveRef(self) GolfCollection.RemoveRef(self) HotelCollection.RemoveRef(self) IndiaCollection.RemoveRef(self) JuliettCollection.RemoveRef(self) Debug.MessageBox("Alpha is working!") ElseIf IsInFaction(ICOM_BravoFaction) == 1 ; Bravo AlphaCollection.RemoveRef(self) BravoCollection.AddRef(self) CharlieCollection.RemoveRef(self) DeltaCollection.RemoveRef(self) EchoCollection.RemoveRef(self) FoxtrotCollection.RemoveRef(self) GolfCollection.RemoveRef(self) HotelCollection.RemoveRef(self) IndiaCollection.RemoveRef(self) JuliettCollection.RemoveRef(self) ElseIf IsInFaction(ICOM_CharlieFaction) == 1 ; Charlie AlphaCollection.RemoveRef(self) BravoCollection.RemoveRef(self) CharlieCollection.AddRef(self) DeltaCollection.RemoveRef(self) EchoCollection.RemoveRef(self) FoxtrotCollection.RemoveRef(self) GolfCollection.RemoveRef(self) HotelCollection.RemoveRef(self) IndiaCollection.RemoveRef(self) JuliettCollection.RemoveRef(self) ElseIf IsInFaction(ICOM_DeltaFaction) == 1 ; Delta AlphaCollection.RemoveRef(self) BravoCollection.RemoveRef(self) CharlieCollection.RemoveRef(self) DeltaCollection.AddRef(self) EchoCollection.RemoveRef(self) FoxtrotCollection.RemoveRef(self) GolfCollection.RemoveRef(self) HotelCollection.RemoveRef(self) IndiaCollection.RemoveRef(self) JuliettCollection.RemoveRef(self) ElseIf IsInFaction(ICOM_EchoFaction) == 1 ; Echo AlphaCollection.RemoveRef(self) BravoCollection.RemoveRef(self) CharlieCollection.RemoveRef(self) DeltaCollection.RemoveRef(self) EchoCollection.AddRef(self) FoxtrotCollection.RemoveRef(self) GolfCollection.RemoveRef(self) HotelCollection.RemoveRef(self) IndiaCollection.RemoveRef(self) JuliettCollection.RemoveRef(self) ElseIf IsInFaction(ICOM_FoxtrotFaction) == 1 ; Foxtrot AlphaCollection.RemoveRef(self) BravoCollection.RemoveRef(self) CharlieCollection.RemoveRef(self) DeltaCollection.RemoveRef(self) EchoCollection.RemoveRef(self) FoxtrotCollection.AddRef(self) GolfCollection.RemoveRef(self) HotelCollection.RemoveRef(self) IndiaCollection.RemoveRef(self) JuliettCollection.RemoveRef(self) ElseIf IsInFaction(ICOM_GolfFaction) == 1 ; Golf AlphaCollection.RemoveRef(self) BravoCollection.RemoveRef(self) CharlieCollection.RemoveRef(self) DeltaCollection.RemoveRef(self) EchoCollection.RemoveRef(self) FoxtrotCollection.RemoveRef(self) GolfCollection.AddRef(self) HotelCollection.RemoveRef(self) IndiaCollection.RemoveRef(self) JuliettCollection.RemoveRef(self) ElseIf IsInFaction(ICOM_HotelFaction) == 1 ; Hotel AlphaCollection.RemoveRef(self) BravoCollection.RemoveRef(self) CharlieCollection.RemoveRef(self) DeltaCollection.RemoveRef(self) EchoCollection.RemoveRef(self) FoxtrotCollection.RemoveRef(self) GolfCollection.RemoveRef(self) HotelCollection.AddRef(self) IndiaCollection.RemoveRef(self) JuliettCollection.RemoveRef(self) ElseIf IsInFaction(ICOM_IndiaFaction) == 1 ; India AlphaCollection.RemoveRef(self) BravoCollection.RemoveRef(self) CharlieCollection.RemoveRef(self) DeltaCollection.RemoveRef(self) EchoCollection.RemoveRef(self) FoxtrotCollection.RemoveRef(self) GolfCollection.RemoveRef(self) HotelCollection.RemoveRef(self) IndiaCollection.AddRef(self) JuliettCollection.RemoveRef(self) ElseIf IsInFaction(ICOM_JuliettFaction) == 1 ; Juliett AlphaCollection.RemoveRef(self) BravoCollection.RemoveRef(self) CharlieCollection.RemoveRef(self) DeltaCollection.RemoveRef(self) EchoCollection.RemoveRef(self) FoxtrotCollection.RemoveRef(self) GolfCollection.RemoveRef(self) HotelCollection.RemoveRef(self) IndiaCollection.RemoveRef(self) JuliettCollection.AddRef(self) EndIf EndEvent Link to comment Share on other sites More sharing options...
steve40 Posted September 30, 2016 Share Posted September 30, 2016 (edited) OnInit() only ever fires once, when the reference is first spawned, or when the game starts (if the reference is persistent). If self does not have its 3d loaded (it won't at the time OnInit runs) then functions that require the ref ("self" in this case) to be fully loaded will fail. I'm not sure if AddRef requires the refs to be loaded first, but it's possible. Check your logs for possible errors, and add another trace to the top of OnInit (not within the IF statement) to check if it is firing or not. Edited September 30, 2016 by steve40 Link to comment Share on other sites More sharing options...
Recommended Posts