Jump to content

Help with a script with "if" function


Hangman4358

Recommended Posts

Hey, i am trying to get this to work. I want to script to add a spell to the players inventory when they read a book. But i also want to book remain and have writing in it. That is why i do not want to add the spell through the normal way of just telling the book to teach the spell. So i came up with this script

 

Scriptname OAQ01RewardBookScript extends ObjectReference  

SPELL Property OAQ01RewardSpell  Auto  

if !(Game.GetPlayer.HasSpell(OAQ01RewardSpell))
Event OnRead()
	Game.GetPlayer().AddSpell(OAQ01RewardSpell, False)
	Debug.Trace("Dunmer Lore learned!")
EndEvent
endIf

 

The CK is telling me the problem is with "if !(Game.GetPlayer.HasSpell(OAQ01RewardSpell))". How exactly do I make the script only when the player does NOT have the spell?

Link to comment
Share on other sites

I don't know any Papyrus, but have you tried putting the if clause "inside" the Event block? If it's any close to Oblivion scripting, there can't be anything like that "outside" of the Event blocks. It's just wild guessing though.

 

Oh, and it seems you're missing the function brackets at the end of the GetPlayer inside the if clause.

Edited by DrakeTheDragon
Link to comment
Share on other sites

Hey, i am trying to get this to work. I want to script to add a spell to the players inventory when they read a book. But i also want to book remain and have writing in it. That is why i do not want to add the spell through the normal way of just telling the book to teach the spell. So i came up with this script

 

Scriptname OAQ01RewardBookScript extends ObjectReference  

SPELL Property OAQ01RewardSpell  Auto  

if !(Game.GetPlayer.HasSpell(OAQ01RewardSpell))
Event OnRead()
	Game.GetPlayer().AddSpell(OAQ01RewardSpell, False)
	Debug.Trace("Dunmer Lore learned!")
EndEvent
endIf

 

The CK is telling me the problem is with "if !(Game.GetPlayer.HasSpell(OAQ01RewardSpell))". How exactly do I make the script only when the player does NOT have the spell?

 

As commented above, plus you missed the () at the end of GetPlayer in your IF statement.

 

Scriptname OAQ01RewardBookScript extends ObjectReference  

SPELL Property OAQ01RewardSpell  Auto  


Event OnRead()

If !Game.GetPlayer().HasSpell(OAQ01RewardSpell)
	Game.GetPlayer().AddSpell(OAQ01RewardSpell, False)
	Debug.Trace("Dunmer Lore learned!")
Else
	Debug.Trace("Dunmer Lore not learned")
EndIf

EndEvent

 

PS. if you use "debug.notification" instead of "debug.trace" it will print the message at the top left you your screen while you are in-game :)

Edited by steve40
Link to comment
Share on other sites

  • Recently Browsing   0 members

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