senterpat Posted November 24, 2018 Author Share Posted November 24, 2018 (edited) Thanks again. What command can I use to get the CurrentElements base ID? I tried this: ObjectReference OldObject = FoundStuff[currentElement].GetBaseObject() But it returns and error about type mismatch Edited November 24, 2018 by senterpat Link to comment Share on other sites More sharing options...
SKKmods Posted November 24, 2018 Share Posted November 24, 2018 GetBaseObject() returns a Form not an in world ObjectReference, so: MiscObject* OldObjectBase = FoundStuff[currentElement].GetBaseObject() (*) Or Weapon or Ammo or Furniture whatever the base form is. Link to comment Share on other sites More sharing options...
senterpat Posted November 24, 2018 Author Share Posted November 24, 2018 (edited) One more thing (I hope), some of the objects being replaced are potions, the rest are Misc items, i have it set up like so: while (currentElement < FoundStuff.Length) MiscObject OldMisc = FoundStuff[currentElement].GetBaseObject() as MiscObject Potion OldPotion = FoundStuff[currentElement].GetBaseObject() as Potion if OldMisc == CigaretteCarton Do Stuff ElseIf OldPotion == Buffout Do Stuff endif My question is, when it moves onto the next element, how do I clear the baseobjects? I tried MiscObject OldMisc = None in the Do Stuff section, it won't let me define the variable a second time. Edited November 24, 2018 by senterpat Link to comment Share on other sites More sharing options...
SKKmods Posted November 25, 2018 Share Posted November 25, 2018 OK I have never done this before, where you don't know the type of thing you are finding so just an idea mess around with some less qualified tests: Form ThisItem = FoundStuff[currentElement].GetBaseObject() If (ThisItem is MiscObject) ;do MicsObject stuff Elseif (ThisItem is Potion) ;do Potion stuff Endif Link to comment Share on other sites More sharing options...
senterpat Posted November 25, 2018 Author Share Posted November 25, 2018 (edited) Awesome, I didn't know you could assign a general form like that, I have only one error when compiling, and it's a line that was copy and pasted from your script, so I don't know why. But on every line (is repeated 3 times) that I use this command: Self.RegisterForRemoteEvent((pPlayerREF), OnPlayerLoadGame) I get the error: C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\patFindScript.psc(169,43): variable OnPlayerLoadGame is undefinedC:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\patFindScript.psc(169,43): argument aseventname must be a raw string and not a variable I also tried:Self.RegisterForRemoteEvent((pPlayerREF), "OnPlayerLoadGame")but that returns this error: C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\patFindScript.psc(169,43): OnPlayerLoadGame is not an event on objectreference or one if its parents I case you need it, here's the entire current script: (I wish i knew how to make a spoiler button) ScriptName patFindScript extends Quest ObjectReference Property pPlayerREF Auto Potion Property Buffout Auto Potion Property Jet Auto Potion Property Psycho Auto Potion Property Mentats Auto Potion Property BeerBottleStandard01 Auto Potion Property Bourbon Auto Potion Property Whiskey Auto Potion Property Wine Auto Potion Property Rum Auto Potion Property Vodka Auto Potion Property NukaCola Auto Potion Property Stimpak Auto Potion Property NukaColaCherry Auto MiscObject Property Cigar_Off01 Auto MiscObject Property Cigar_SanFranOff Auto MiscObject Property CigaretteCarton_Prewar Auto MiscObject Property CigaretteCarton Auto MiscObject Property CigarettePack Auto MiscObject Property CigarettePack_Prewar Auto MiscObject Property Cigarette_Off01 Auto MiscObject Property CigarBox Auto MiscObject Property CigarBoxSanFran Auto Formlist Property ReplacerFormList Auto LeveledItem Property BuffoutReplacer Auto LeveledItem Property JetReplacer Auto LeveledItem Property PsychoReplacer Auto LeveledItem Property MentatsReplacer Auto LeveledItem Property BeerReplacer Auto LeveledItem Property BourbonReplacer Auto LeveledItem Property WhiskeyReplacer Auto LeveledItem Property WineReplacer Auto LeveledItem Property RumReplacer Auto LeveledItem Property VodkaReplacer Auto LeveledItem Property NukaColaReplacer Auto LeveledItem Property StimpakReplacer Auto LeveledItem Property CigarReplacer Auto LeveledItem Property CigaretteCartonCleanReplacer Auto LeveledItem Property CigaretteCartonReplacer Auto LeveledItem Property CigarettePackReplacer Auto LeveledItem Property CigarettePackCleanReplacer Auto LeveledItem Property CigaretteReplacer Auto LeveledItem Property CigarBoxReplacer Auto ReferenceAlias Property Alias_LocationChangeMarker Auto float fDetectionDistance = 10240.0 float fMovementDistance = 5120.0 Function FindStuff() Self.UnregisterForDistanceEvents(pPlayerREF, Alias_LocationChangeMarker.GetReference()) Self.UnRegisterForPlayerTeleport() ObjectReference[] FoundStuff = pPlayerREF.FindAllReferencesOfType(ReplacerFormList, fDetectionDistance) int currentElement = 0 while (currentElement < FoundStuff.Length) Form OldItem = FoundStuff[currentElement].GetBaseObject() if OldItem == CigaretteCarton FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(CigaretteCartonReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 ElseIf OldItem == CigarettePack FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(CigarettePackReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 ElseIf OldItem == CigarBox || OldItem == CigarBoxSanFran FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(CigarBoxReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 elseif OldItem == CigaretteCarton_Prewar FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(CigaretteCartonCleanReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 ElseIf OldItem == CigarettePack_Prewar FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(CigarettePackCleanReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 ElseIf OldItem == Cigarette_Off01 FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(CigaretteReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 ElseIf OldItem == Cigar_Off01 || OldItem == Cigar_SanFranOff FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(CigarReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 ElseIf OldItem == BeerBottleStandard01 FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(BeerReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 ElseIf OldItem == Bourbon FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(BourbonReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 ElseIf OldItem == Whiskey FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(WhiskeyReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 ElseIf OldItem == Wine FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(WineReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 ElseIf OldItem == Rum FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(RumReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 ElseIf OldItem == Vodka FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(VodkaReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 ElseIf OldItem == NukaCola || OldItem == NukaColaCherry FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(NukaColaReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 ElseIf OldItem == Buffout FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(BuffoutReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 ElseIf OldItem == Jet FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(JetReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 ElseIf OldItem == Mentats FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(MentatsReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 ElseIf OldItem == Psycho FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(PsychoReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 ElseIf OldItem == Stimpak FoundStuff[currentElement].Disable() ObjectReference NewObject = FoundStuff[currentElement].Placeatme(StimpakReplacer, 1, True, false, false) FoundStuff[currentElement].Delete() currentElement += 1 EndIf endWhile Self.SwitchEnabled() EndFunction Function SwitchEnabled() Self.RegisterForPlayerTeleport() Alias_LocationChangeMarker.GetReference().MoveTo(pPlayerREF, 0, 0, 0, True) Self.RegisterForDistanceGreaterThanEvent(pPlayerREF, Alias_LocationChangeMarker.GetReference(), fMovementDistance) EndFunction Event OnQuestInit() Self.RegisterForRemoteEvent((pPlayerREF), "OnPlayerLoadGame") Self.SwitchEnabled() EndEvent Event Actor.OnLocationChange(Actor akSender, Location akOldLoc, Location akNewLoc) Self.UnregisterForAllEvents() Self.RegisterForRemoteEvent((pPlayerREF), "OnPlayerLoadGame") Self.SwitchEnabled() EndEvent Event OnDistanceGreaterThan(ObjectReference akObj1, ObjectReference akObj2, float afDistance) If ((pPlayerREF as Actor).IsOnMount() == True) Alias_LocationChangeMarker.GetReference().MoveTo(pPlayerREF, 0, 0, 0, True) Self.RegisterForDistanceGreaterThanEvent(pPlayerREF, Alias_LocationChangeMarker.GetReference(), fMovementDistance) Else Self.FindStuff() EndIf EndEvent Event Actor.OnPlayerLoadGame(Actor akSender) Self.RegisterForRemoteEvent((pPlayerREF), "OnPlayerLoadGame") Self.SwitchEnabled() EndEvent Event OnPlayerTeleport() Self.FindStuff() EndEvent Edited November 25, 2018 by senterpat Link to comment Share on other sites More sharing options...
SKKmods Posted November 25, 2018 Share Posted November 25, 2018 The compiler is explaining the error, you need to pay attention to variable typing. Self.RegisterForRemoteEvent((pPlayerREF), "OnPlayerLoadGame") = OnPlayerLoadGame is not an event on objectreference or one if its parents. Which is absolutely correct, you have defined pPlayerREF as an ObjectReference, when OnPlayerLoadGame is an Actor function. The correct casting call is; Self.RegisterForRemoteEvent((pPlayerREF AS ACTOR), "OnPlayerLoadGame") Link to comment Share on other sites More sharing options...
Recommended Posts