Jump to content

Need some scripting help


tobbe84

Recommended Posts

I'm trying to make a script to an armor which is supposed to add the actor to a faction when equipped and remove the actor from that faction when unequipped, but it isn't working. When I press Save, a little box tells me that a compilation failed. There is a message in the Compiler Output window

that says "variable myfaction is undefined". How do I fix this?

Edited by tobbe84
Link to comment
Share on other sites

To fix an undefined variable error, you define your variable.

 

Guessing from what little context you've given us to work with (for future reference, please provide your script, or at least the relevant part of your script, for us to see what's going on), you want a faction property, so you'll need to add a line like this to your script:

Faction property myfaction auto

You'll then have to use the Properties dialog in the CK to "hook up" your faction to this property, or you can change the name "myfaction" to match the name of the faction and leave the default value (it will default to the faction named the same as the property, if there is one).

Link to comment
Share on other sites

Here it is:

 

Scriptname XXXXXX extends ObjectReference

 

Event OnEquipped(Actor akActor)

akActor.AddToFaction(YYYYYY)

EndEvent

 

Event OnUnEquipped(Actor akActor)

akActor.RemoveFromFaction(YYYYYY)

EndEvent

 

(I guess the name of my script and faction is irrelevant, so I replaced it with XXXXXX and YYYYYY)

Link to comment
Share on other sites

Yup, ahead of your first Event block (but after your Scriptname line) you'll need to declare your YYYYYY faction property:

Faction property YYYYYY auto

Then when you hook into this script in the CK, you'll have to open the Properties dialog and connect YYYYYY to the faction you want the armor to add the player to.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...