Jump to content

[Help with script] GetSitState() not working


Recommended Posts

Posted

So basically, i'm trying to create a script that play sound whenever a npc or player character get in the trigger box and currently sitting, here is the code

Scriptname Testp5 extends ObjectReference  

int instanceID
Sound Property mySound Auto

Event OnTriggerEnter(ObjectReference akActionRef)
     if (akActionRef.GetSitState() == 3)
     instanceID = mySound.play(akActionRef)
     endif
EndEvent

Event OnTriggerLeave(ObjectReference akActionRef)
     Sound.StopInstance(instanceID)
EndEvent

but it return the error

"GetSitState is not a function or does not exist" and "cannot compare a none to a int (cast missing or types unrelated)"

 

the first error is weird because that function definitely exist https://www.creationkit.com/index.php?title=GetSitState_-_Actor

the second one im not sure

Posted
2 hours ago, Pandoriux said:

So basically, i'm trying to create a script that play sound whenever a npc or player character get in the trigger box and currently sitting, here is the code

Scriptname Testp5 extends ObjectReference  

int instanceID
Sound Property mySound Auto

Event OnTriggerEnter(ObjectReference akActionRef)
     if (akActionRef.GetSitState() == 3)
     instanceID = mySound.play(akActionRef)
     endif
EndEvent

Event OnTriggerLeave(ObjectReference akActionRef)
     Sound.StopInstance(instanceID)
EndEvent

but it return the error

"GetSitState is not a function or does not exist" and "cannot compare a none to a int (cast missing or types unrelated)"

 

the first error is weird because that function definitely exist https://www.creationkit.com/index.php?title=GetSitState_-_Actor

the second one im not sure

 

You need to run GetSitState() on an Actor, not ObjectReference.

 

It should look something like:

 

if (akActionRef as Actor).GetSitState() == 3

Posted (edited)
On 2/24/2023 at 12:54 AM, AndrewLRG said:

 

You need to run GetSitState() on an Actor, not ObjectReference.

 

It should look something like:

 

if (akActionRef as Actor).GetSitState() == 3

Thanks it worked now.

On 2/24/2023 at 1:31 AM, ghastley said:

Also the OnTriggerEnter event happens before the actor sits down. I doubt that test will ever evaluate true.

Thanks for pointing it out, i use OnTrigger instead and it work now. However, because OnTrigger run constantly, do you happen to know anyway to put cooldown between checks? Or a condition to see if mySound is already running

NVM, i figured it out

Edited by Pandoriux

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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