Jump to content

[Scripting] I seem to come across this a lot and need help. :P


Korodic

Recommended Posts

I am making a script that adds a person to a faction when a door is opened to prevent hostility from happening too early. However Papyrus likes to make everything difficult and tell me that functions do not exist. I think this deals with the type of event I used... regardless, what do I need to do to get the same results in the simplest way possible?

Scriptname NTJailBreak extends ObjectReference  
{If door is open and prisoner is not already in bandit faction, add him/her to bandit faction to make them hostile.}


Event OnActivate(ObjectReference akActionRef)
Debug.Trace("Activated by " + akActionRef)
int openState = self.GetOpenState()
if (openState == 1 || openState == 2 || self.GetLinkedRef() ) ; Open or opening
 	 Debug.Trace("Door is open!")
	if self.GetLinkedRef().IsInFaction(BanditFaction)
		 Debug.Trace("Prisoner is in Bandit Faction... do nothing...")
           else
	self.GetLinkedRef().SetFactionRank(BanditFaction, 0)
	endif
endIf
EndEvent
Faction Property BanditFaction  Auto  

 

EDIT: By the way, the linked ref is a prisoner in a cell. The "self" is a door.

Link to comment
Share on other sites

Starting 1 compile threads for 1 files...

Compiling "NTJailBreak"...

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\NTJailBreak.psc(10,25): IsInFaction is not a function or does not exist

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\NTJailBreak.psc(13,22): SetFactionRank is not a function or does not exist

No output generated for NTJailBreak, compilation failed.

 

Batch compile of 1 files finished. 0 succeeded, 1 failed.

Failed on NTJailBreak

Link to comment
Share on other sites

Hmm. I can't see a problem right off.

 

Why don't you try making an object reference for the linked ref and use that instead? And I'm not sure if it matters, but place

 Faction Property BanditFaction  Auto

before the event block (double check make sure it is still assigned, sometimes this clears it)

 

edit: I'm almost positive you will have to make a property for the linked ref. The compiler claims the function will not exist if there's an issue with the reference that its calling.

Edited by PaladinRider
Link to comment
Share on other sites

Yeah I thought about that! But then forgot about it on my walk back to my room (lol) I'll be sure to try that.

EDIT: Same errors as before, I tried moving the declarations and used the object REF instead of the self.getlinkedref()

Link to comment
Share on other sites

Hmm I'm no expert but it seems like whatever GetLinkedRef() returns is not an actor. IsInFaction and SetFactionRank both only exist for actors so you need to make sure to call them on an actor type object. Try to call self.GetLinkedRef().GetActorRef().IsInFaction(BanditFaction).
Link to comment
Share on other sites

Even though the prisoners object ref's I suppose that might work... testing now, I'll edit this post in a minute once I've played around with it for a little.

 

EDIT: So now it says GetActorRef() is not a function lol. -.- the CK needs a more specific compiler...

Link to comment
Share on other sites

What Chris says makes sense.

 

 

just to verify and just to ask the obvious, but are the properties assigned?

 

Yes... the following properties are assigned (as of now):

Type: faction --- BanditFaction (points to BanditFaction)

Type: Actor --- Prisoner1 (points to NTPrisonerREF1)

Type: Object Reference --- NTPrisonerREF1 (points to NTPrisonerREF1)

Link to comment
Share on other sites

I think I got it... I cant use any references such as self.getlinkedref. This sucks, because i dont want to make 2 separate scripts to do what should be 1 scripts job. My code is as follows

Scriptname NTJailBreak extends ObjectReference  
{If door is open and prisoner is not already in bandit faction, add him/her to bandit faction to make them hostile.}


Event OnActivate(ObjectReference akActionRef)
Debug.Trace("Activated by " + akActionRef)
int openState = self.GetOpenState()
if (openState == 1 || openState == 2 || self.GetLinkedRef() ) ; Open or opening
 	 Debug.Trace("Door is open!")
	if Prisoner1.IsInFaction(BanditFaction)
		 Debug.Trace("Prisoner is in Bandit Faction... do nothing...")
            else
	Prisoner1.SetFactionRank(BanditFaction, 0)
	endif
endIf
EndEvent
Faction Property BanditFaction  Auto  

ObjectReference Property NTPrisonerREF1  Auto  

Actor Property Prisoner1  Auto  

Link to comment
Share on other sites

  • Recently Browsing   0 members

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