Jump to content

[Help] With Script for a Benchpress


reaper9111

Recommended Posts

Hello guy's can't get this to work...

It's a script attach to an activator, that is supposed to give the player 1 point of stamina everytime it's activated, but can only be activated once a day !

Anyone can help please ?

 

Auto State Ready  
 
Event OnBeginState()  
    Debug.MessageBox("The bench is ready to give stamina")  
EndEvent  
 
Event OnActivate(ObjectReference akActionRef)  
       
int playersHealth = Game.GetPlayer().GetActorValue("Stamina") as int      
       
     if akActionRef == Game.GetPlayer()  
          Game.DisablePlayerControls(True, True, True, False, True, False, True)  
          Utility.Wait(10)  
          Game.GetPlayer().SetActorValue("Stamina", playersHealth +1)  
          Debug.Notification("You fell stronger")  
          Game.EnablePlayerControls()  
     endif  
     GoToState("NotReady")  
EndEvent  
EndState  
 
State NotReady  
Event OnBeginState()  
   Self.RegisterForSingleUpdateGameTime(24)  
   Debug.MessageBox("State correctly switched")  
EndEvent  
 
Event OnUpdateGameTime()  
    GoToState("Ready")  
EndEvent  
EndState

Edited by reaper9111
Link to comment
Share on other sites

The script seems to work correctly except for the stamina value. GetActorValue will read the current actor value. If the player is unlucky, his current stamina is at 0 and the script will set his base stamina to 1. :P

 

Try this:

 

Auto State Ready  
 
Event OnBeginState()  
    Debug.MessageBox("The bench is ready to give stamina")  
EndEvent  
 
Event OnActivate(ObjectReference akActionRef)  
          Actor Player = Game.GetPlayer()		
     if akActionRef == Player 		   
          Game.DisablePlayerControls(True, True, True, False, True, False, True)  
          Utility.Wait(10)  
          Player.ModActorValue("Stamina", 1)  
          Debug.Notification("You fell stronger")  
          Game.EnablePlayerControls()  
     endif  
     GoToState("NotReady")  
EndEvent  
EndState  
 
State NotReady  
Event OnBeginState()  
   Self.RegisterForSingleUpdateGameTime(24)  
   Debug.MessageBox("State correctly switched")  
EndEvent  
 
Event OnUpdateGameTime()  
    GoToState("Ready")  
EndEvent  
EndState

Link to comment
Share on other sites

  • Recently Browsing   0 members

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