Jump to content

Photo

Hit a wall with papyrus global variable

papyrus script global variable quest

  • Please log in to reply
2 replies to this topic

#1
SenorPato

SenorPato

    Enthusiast

  • Members
  • PipPip
  • 116 posts

For a stage in my quest I want the player to kill a couple of enemies in any order the player wants to. In order to keep track of how many are killed I tried to make a global variable as shown in this post. I made a new Global in the creation kit, added it to my quest in the 'Quest Data' tab and made the script below. But for some reason the global wont get updated and always stays 0. Anyone able to give me some advice?

 

Thanks in advance.

Scriptname ChickenQuestScript2 extends actor
{objective klaar als kip dood}

Quest property eenQuest auto
int property nummerObjective auto
GlobalVariable property globalNummertje auto
int nummertje 

Event OnDeath(Actor akKiller)
	eenQuest.SetObjectiveCompleted(nummerObjective)
	
	nummertje = globalNummertje.GetValueInt() + 1
	globalNummertje.SetValueInt(nummertje)
	eenQuest.UpdateCurrentInstanceGlobal(globalNummertje)
	
	Debug.Notification(nummertje)
	Debug.Notification(globalNummertje.GetValueInt())
	
EndEvent

Edited by SenorPato, 07 May 2015 - 10:10 PM.


#2
Mattiewagg

Mattiewagg

    Is Female?!

  • Supporter
  • PipPipPipPipPip
  • 5,544 posts
Make sure the global is NOT constant. And don't do that to add one to it - remove those lines and instead of the whole num = global.getvalue and setvalueint, just use:

My global.Mod(1.0)

#3
SenorPato

SenorPato

    Enthusiast

  • Members
  • PipPip
  • 116 posts

Thanks once again, works like a charm. Also "MyGlobal.GetValue() as int" seems to work instead of "MyGlobal.GetValueInt()".







Also tagged with one or more of these keywords: papyrus, script, global variable, quest

IPB skins by Skinbox
Page loaded in: 1.016 seconds