Hangman4358 Posted June 12, 2012 Share Posted June 12, 2012 (edited) Ok, i finally have some more time in my schedule and I am again working on my Obsidian Armor Mod but I have run into trouble. At a certain point in time I want the player to pick up a dagger and this will open a door. To do this I duplicated the NorPullRod activator and have made it use a modified version of the dagger's mesh. This works fine. I then Set the doors I want to open as having the activator as an Activate Parent. This works fine. But Now I want to player to have a dagger added to his inventory when they activate the activator, so I added this script to the activator as per the CK wiki: Scriptname DaggerActivatorScript extends ObjectReference WEAPON Property ObsidianDagger Auto Actor Property PlayerRef Auto Event OnActivate(ObjectReference akActionRef) if akActionRef == PlayerRef Game.GetPlayer().AddItem(ObsidianDagger, 1) endif EndEvent But it does not work. I do not get an error when I save the script so I don't know what is going on. And of course at the end I want to disable the activator so the player can only get 1 dagger and only open the closed doors. Is there maybe an easier way to do this whole thing? I tried to look at the red eagle quest and figure out what was happening there but I could not understand it. Edited June 12, 2012 by Hangman4358 Link to comment Share on other sites More sharing options...
steve40 Posted June 12, 2012 Share Posted June 12, 2012 (edited) Scriptname DaggerActivatorScript extends ObjectReference WEAPON Property ObsidianDagger Auto Event OnActivate(ObjectReference akActionRef) if akActionRef == Game.GetPlayer() akActionRef.AddItem(ObsidianDagger, 1) self.disable() endif EndEvent Edit: added the disable() call to disable the activator. Edited June 12, 2012 by steve40 Link to comment Share on other sites More sharing options...
Hangman4358 Posted June 12, 2012 Author Share Posted June 12, 2012 It just id not working. The problem I have is that it does not even give me the dagger when I activate it. So the addItem is not even working. Is it because it is an activator? Link to comment Share on other sites More sharing options...
Hangman4358 Posted June 12, 2012 Author Share Posted June 12, 2012 So I did some more testing. I moved everything to the quest practically. I moved the disable and the giving of the dagger to a quest stage. I made the activator have an alias and have it enabled in the world at stage 10 of the quest. If i manually set the stage to 10 the activator appears no problem. And when I then activate it the doors I have it set as controlling open and close. I also gave the activator, via the alias it gets from the quest a script to set the quest stage to 11 when activated. This does not work. In this quest stage I have it give the player the dagger and disable the activator. If I manually set the stage to 11 via the consle it does both. So the problem looks to lie with the fact that for some reason the onActivation script on the activator is not working. Anybody have any ideas? Link to comment Share on other sites More sharing options...
steve40 Posted June 12, 2012 Share Posted June 12, 2012 (edited) Did you use my version of the script? It is slightly different than yours in an important way. Try this script with debug messages. Attach it directly to the activator object, not to the alias.*** NB: There must not be any other scripts acting on the object that have an OnActivate block in them. Scriptname DaggerActivatorScript extends ObjectReference WEAPON Property ObsidianDagger Auto Event OnActivate(ObjectReference akActionRef) Debug.MessageBox("[DaggerActivatorScript] OnActivate was called.") if akActionRef == Game.GetPlayer() Debug.MessageBox("[DaggerActivatorScript] Attempting to give dagger to player.") akActionRef.AddItem(ObsidianDagger, 1) self.disable() else Debug.MessageBox("[DaggerActivatorScript] Error: Player was not the activator.") EndIf EndEvent If OnActivate is working you will get a message box appear. If OnActivate is not getting called, then I'd say that you have two competing scripts acting on the activator, both with an OnActivate block in them. The game would pick only one of them to run, so you would need to merge the two scripts. Edited June 12, 2012 by steve40 Link to comment Share on other sites More sharing options...
Hangman4358 Posted June 12, 2012 Author Share Posted June 12, 2012 ah, that worked. Ok, i did not know you could only have one onActivate block, i am guessing that means you can only have one of each block. The activator still had the Traplevel script on it which has an onActivate block in it. I thought that script was needed for it to work like a lever to open a portcullis which is what i based my activator on, but I guess it is not. I removed that script and tried yours at the same time. And it works, still opens the doors and gives the dagger. Thanks very much. I am horrible lost when it comes to anything more than basic scripting. Though most people would probably call this basic :) Kudos to you! Link to comment Share on other sites More sharing options...
steve40 Posted June 13, 2012 Share Posted June 13, 2012 (edited) ah, that worked. Ok, i did not know you could only have one onActivate block, i am guessing that means you can only have one of each block. The activator still had the Traplevel script on it which has an onActivate block in it. I thought that script was needed for it to work like a lever to open a portcullis which is what i based my activator on, but I guess it is not. I removed that script and tried yours at the same time. And it works, still opens the doors and gives the dagger. Thanks very much. I am horrible lost when it comes to anything more than basic scripting. Though most people would probably call this basic :) Kudos to you! Hi Hangman, Basically what happens is that in most cases an event block on a script will override the event block on its parent script (eg the script that it is extending). Not always though. The wiki for that event usually tells you what will happen. I read somewhere (can't remember where, maybe in these forums) and also discovered from experience, that when you have multiple scripts with similar blocks (ie. more than one child script) then the game will (randomly??) pick one script and run that script's block only. In this case you can either combine the two scripts into one, or call the event block of the other script from the script that executes. Combining the two scripts is safer, neater, imho. The other problem that can occur is having simultaneous calls to the same event. That's explained here, but I don't think that was your problem. Cheers. Edited June 13, 2012 by steve40 Link to comment Share on other sites More sharing options...
Recommended Posts