Talk:IsSneaking - Actor
Revision as of 10:01, 11 February 2012 by imported>MaboroshiDaikon
Syntax
I can get the following to work as expected:
If (Game.GetPlayer().IsWeaponDrawn() == 1)
;Do Something
EndIf
But the following does not:
If (Game.GetPlayer().IsSneaking() == 1)
;Do Something
EndIf
Tried the following syntax and still no luck:
If (Game.GetPlayer().IsSneaking())
;Do Something
EndIf
- This script worked exactly as I expected:
Scriptname CodeTestScript extends Quest
Event OnInit()
RegisterForUpdate(3)
EndEvent
Event OnUpdate()
if (Game.GetPlayer().IsSneaking())
Debug.Notification("Player is sneaking")
else
Debug.Notification("Player is not sneaking")
endif
EndEvent
- As a side note, this function returns a bool, so why are you comparing it with 1? It's more semantically correct, but just as superfluous, to compare it with true
- -- Cipscis 23:11, 10 February 2012 (EST)
- I was originally using just as you did, but when that didn't work, I switched to the comparison with 1. I'm wondering if this is an issue with the ReferenceAlias type script instead of the command itself. Here's the complete code I'm having issues with:
Scriptname PlayerHorseScript extends ReferenceAlias
Event OnDeath(Actor akKiller)
MySelf = GetActorReference()
EndEvent
Event OnUnload()
If MySelf.IsDead() == 1
; disable the dead horse if it is unloaded
MySelf.Disable()
MySelf.Delete()
; added a new horse that can be bought at the stables
Myself = StablesPosition.PlaceActorAtMe(LvlHorseSaddled)
Alias_HorseRef.ForceRefTo(MySelf)
Alias_HorseRef.GetRef().SetFactionOwner(StablesFaction)
EndIf
EndEvent
Event OnActivate(ObjectReference akActionRef)
If (akActionRef == Game.GetPlayer())
If Game.GetPlayer().IsSneaking()
Debug.MessageBox("Sneak Activate Horse!!")
HorseChest.Activate(Game.GetPlayer(), true)
Else
Debug.MessageBox("Normal Activate Horse!! " + HorseChest)
;HorseChest.Activate(Game.GetPlayer(), true)
EndIf
EndIf
EndEvent
Actor Property MySelf Auto
ObjectReference Property StablesPosition Auto
ActorBase Property LvlHorseSaddled Auto
ReferenceAlias Property Alias_HorseRef Auto
Faction Property StablesFaction Auto
ObjectReference Property HorseChest Auto
Replacing IsSneaking() with IsWeaponDrawn() works.