Jump to content

Problems with getting names


YaserM

Recommended Posts

This is so frustrating.

 

I managed to get my health with this:

 

 

Scriptname YM_TestScriptOnHit extends Actor
{A script that should activate each time the player gets hit}

Float Property Health Auto
Actor Property pActor Auto
ActorValue Property HealthAV Auto Const
Event OnInit()
RegisterForHitEvent(Game.GetPlayer())
EndEvent

Event OnHit(ObjectReference akTarget, ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked, string apMaterial)

pActor == akTarget

Debug.messagebox("YM_TestScriptOnHit: " + pActor + " was hit")


Health = Game.GetPlayer().GetValue(HealthAV)
;Health = pActor.GetValue(HealthAV)
Debug.messagebox("YM_TestScriptOnHit: "+ Health )



RegisterForHitEvent(Game.GetPlayer())


EndEvent

 

But how do I get my health from the values provided by the function?

Link to comment
Share on other sites

To get name instead do: Debug.messagebox("YM_TestScriptOnHit: " + pActor.GetdisplayName() + " was hit") . Note this does require F4SE. There's a way to do it without F4SE by using a Message Form, a reference alias in a quest and using the tag <Alias=MyAlias>. So in your message form you would put "YM_TestScriptOnHit: <Alias=MyAlias> was hit" .

Then in your script you would put :

ReferenceAlias Property MyAlias Auto 
Message Property MyMessage Auto 

Event OnHit(ObjectReference akTarget, ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack,     bool abSneakAttack, bool abBashAttack, bool abHitBlocked, string apMaterial)
myAlias.ForceRefTo(akTarget) 
MyMessage.Show()

Make sure your reference alias has the Optional, Stores Text and Uses Stored Text flags checked.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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