haohao69869 Posted April 6, 2018 Share Posted April 6, 2018 1 Link to comment Share on other sites More sharing options...
shatsnazzle Posted April 6, 2018 Share Posted April 6, 2018 (edited) Hello haohao68869, 1 to you too sir or mam.To get the player's health the script needs to know which actor to look at and which "actor value" you want from it. To tell the script this you use "properties." This happens at the way top of the script below the script name. Cipscis guide that touches on what exactly is a property and how do I use it?Cipscis scripting beginner guidePapyrus primer from creation kit wiki ActorValue property Health auto ;You can choose any name you want instead of "Health" as long as you use it consistently in your script actor property PlayerREF auto ;You can choose any name you want instead of "PlayerREF" as long as you use it consistently in your script ;These properties are written at the top of the script below the script name. float function MyFunctionThatGetsPlayerHealth() ;This function will "return" a float float VariableWithYourHealth ; making a new variable to store the information VariableWithYourHealth = PlayerREF.GetValue(Health) ;getting the player's CURRENT health and setting your variable to equal it. If you want the BASE health use .GetBaseValue() instead return VariableWithYourHealth ;This will be the "output" of the Function endFunctionThis can be done in a more compact way too but the above was for illustrative purposes. More compact: ActorValue property Health auto actor property PlayerREF auto float function MyFunctionThatGetsPlayerHealth() return PlayerREF.GetValue(Health) endFunctionIt is very important that after you compile the script, you open the "Properties" screen on the script and choose which property you want to fill the "Health" and "PlayerREF" slot declared on the first 2 lines of this code. The Creation Kit will not do this automatically for you. You can name these anything you want instead of "Health" or "PlayerREF" but if you name your properties exactly the same as the item you are looking for, you will be able to use the "AutoFill" buttons on the property screen. When you press this button the properties will fill for you and you won't have to search or type in the drop down box. Edit: You could also put this in an event instead of a "function" if you aren't familiar or comfortable yet with functions. ActorValue property Health auto actor property PlayerREF auto Event OnInit() ;or whichever Event you are using float VariableWithYourHealth = PlayerREF.GetValue(Health) ;you've put the value in a variable endFunction Edited April 6, 2018 by shatsnazzle Link to comment Share on other sites More sharing options...
haohao69869 Posted April 7, 2018 Author Share Posted April 7, 2018 Thank you!!! Link to comment Share on other sites More sharing options...
Recommended Posts