A way to check if a player owns a house?

Post » Tue Jun 19, 2012 6:56 am

I'm working on a teleport spell, and learning Papyrus along the way, so basically the spell lets you teleport inside a house that can be owned and purchased by the player. What I would like to do is when a player clicks to teleport to the house it calls for a check if the player actually owns the house and if he does, teleports him, if not a Debug.MessageBox pops up saying like "You need to own the house first!" Should I use Functions? Or something else?
User avatar
Maddy Paul
 
Posts: 3430
Joined: Wed Feb 14, 2007 4:20 pm

Post » Mon Jun 18, 2012 11:57 pm

you can try using a condition:

GetVMQuestVariable HousePurchase, :SolitudeHouseVar_var == 1.00


this checks whether Proudspire Manor was purchased or not. a value of 1.00 means purchased, and 0 is not purchased.
User avatar
Mylizards Dot com
 
Posts: 3379
Joined: Fri May 04, 2007 1:59 pm

Post » Tue Jun 19, 2012 1:24 am

I see. I would need to add an ObjectReference property for HousePurchase to link it to the quest itself right?
User avatar
sam smith
 
Posts: 3386
Joined: Sun Aug 05, 2007 3:55 am

Post » Tue Jun 19, 2012 6:58 am

Not an 'objectReference', you would add a 'quest' object property. And link it to the quest mentioned by Amethyst above.
User avatar
Michael Russ
 
Posts: 3380
Joined: Thu Jul 05, 2007 3:33 am

Post » Tue Jun 19, 2012 2:40 pm

Never mind, got it.
User avatar
Undisclosed Desires
 
Posts: 3388
Joined: Fri Mar 02, 2007 4:10 pm

Post » Mon Jun 18, 2012 11:58 pm

Though now when I add the GetVMQuestVariable HousePurchase, :SolitudeHouseVar_var == 1.0 I get this error when compiling.

H:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\zSpellTomeTeleport.psc(34,34): no viable alternative at character ':'
H:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\zSpellTomeTeleport.psc(34,32): required (...)+ loop did not match anything at input ','
User avatar
Jack Bryan
 
Posts: 3449
Joined: Wed May 16, 2007 2:31 am

Post » Tue Jun 19, 2012 11:22 am

can you post the code using the code brackets
User avatar
Christina Trayler
 
Posts: 3434
Joined: Tue Nov 07, 2006 3:27 am

Post » Tue Jun 19, 2012 10:46 am

Sure. Though be aware, the code is properly structured in Sublime Text 2, but when I pasted in this damn forum, it goes [censored] all.

Scriptname zSpellTomeTeleport extends activemagiceffect{Teleport to a city of your choice and then back to where you were};PropertiesObjectReference property WhiterunBreezehome autoObjectReference property WhiterunMarketplace autoObjectReference property WhiterunJorrvaskr autoObjectReference property WhiterunSkyforge autoObjectReference property WhiterunDragonsreach autoObjectReference property SolitudeMainGate autoObjectReference property SolitudeCourtyard autoObjectReference property SolitudeProudspire autoObjectReference property SolitdueBluePalace autoObjectReference property DawnstarWindspeakInn autoObjectReference property TeleTarget auto   ;The XMarkerHeading that gets recalled to players locationMessage property QuestionMSGR auto   ;Points to RecallMessage property QuestionMSGM auto   ;Points to Mainbox, containing all the cities the player is able to choose fromMessage property QuestionMSGWR auto   ;Points to Whiterun locations question boxMessage property QuestionMSGS auto   ;Points to Solitude locations question boxMessage property QuestionMSGD auto   ;Points to Dawnstar locations question boxQuest property HousePurchase autoGlobalVariable property SpellSwitch auto;FunctionsFunction MessageBox(string asMessageBoxText) native global  ;Function to show debug message box in gameFunction Notification(string asNotificationText) native global  ;Function to debug the script in gameFunction Teleport(actor source, ObjectReference destination)  TeleTarget.MoveTo(source)Utility.Wait(0.2)casterRef.MoveTo(destination)SpellSwitch.SetValueInt(1)endfunctionActor casterObjectReference casterRef  int Recall   ;The return question box(offered when the spell has already been used once before.)int Mainbox   ;The main question box, containing all the cities to choose fromint Whiterun   ;The Whiterun locations question boxint Solitude   ;The Solitude locations question boxint Dawnstar   ;The Dawnstar locations question boxint mySpellSwitchEvent OnEffectStart(Actor akTarget, Actor akCaster)    caster = akCaster	     casterRef = (caster as ObjectReference)mySpellSwitch = SpellSwitch.GetValueInt()     if mySpellSwitch == 1	 Utility.Wait(0.3)   ;Waits 0.3 seconds	  SpellSwitch.SetValueInt(0)	  Recall = QuestionMSGR.Show()	 if Recall == 0	   casterRef.MoveTo(TeleTarget)	   elseif Recall == 1	   QuestionMSGM.Show()	    endif	    else   Utility.Wait(0.5)  Mainbox = QuestionMSGM.Show()   ;Shows the main location box with the cities    if Mainbox == 0  	 Whiterun = QuestionMSGWR.Show()   ;Shows Whiterun locations question box	 Utility.Wait(0.2)	    if Whiterun == 0	 GetVMQuestVariable HousePurchase, :SolitudeHouseVar_var == 1.00    Teleport(caster, WhiterunBreezehome)   	  elseif Whiterun == 1    Teleport(caster, WhiterunMarketplace)	  elseif Whiterun == 2    Teleport(caster, WhiterunJorrvaskr)	 elseif Whiterun == 3    Teleport(caster, WhiterunSkyforge)	 elseif Whiterun == 4    Teleport(caster, WhiterunDragonsreach)	    endif	   endif   if Mainbox == 1   Solitude = QuestionMSGS.Show()   ;Shows Solitude locations question box   Utility.Wait(0.2)      if Solitude == 0    Teleport(caster, SolitudeMainGate)	 elseif Solitude == 1    Teleport(caster, SolitudeCourtyard)	 elseif Solitude == 2    Teleport(caster, SolitudeProudspire)	  elseif Solitude == 3    Teleport(caster, SolitdueBluePalace)		    endif  endif   if Mainbox == 2   Dawnstar = QuestionMSGD.Show()   ;Shows Dawnstar locastions question box   Utility.Wait(0.2)    if Dawnstar == 0    Teleport(caster, DawnstarWindspeakInn)	 	  endif	  endifendifEndEvent
User avatar
Stacy Hope
 
Posts: 3391
Joined: Thu Jun 22, 2006 6:23 am

Post » Tue Jun 19, 2012 7:22 am

if whiterun == 0 && getvmquest blah blah

try that instead of putting it inside the if statement. because you need both of them to be true, so they should both be in the conditional.
User avatar
Miss Hayley
 
Posts: 3414
Joined: Tue Jun 27, 2006 2:31 am

Post » Tue Jun 19, 2012 5:10 am

Doing that gave these errors.

H:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\zSpellTomeTeleport.psc(66,55): no viable alternative at character ':'
H:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\zSpellTomeTeleport.psc(66,21): required (...)+ loop did not match anything at input 'GetVMQuestVariable'
H:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\zSpellTomeTeleport.psc(66,53): required (...)+ loop did not match anything at input ','
User avatar
sarah simon-rogaume
 
Posts: 3383
Joined: Thu Mar 15, 2007 4:41 am

Post » Tue Jun 19, 2012 1:09 am

it could also be that getvmquestvariable is only related to dialog.

try this one instead: http://www.creationkit.com/GetQuestVariable
User avatar
Camden Unglesbee
 
Posts: 3467
Joined: Wed Aug 15, 2007 8:30 am

Post » Tue Jun 19, 2012 11:25 am

Doesn't seem to work. We're probably missing something.
User avatar
Naomi Lastname
 
Posts: 3390
Joined: Mon Sep 25, 2006 9:21 am

Post » Tue Jun 19, 2012 7:45 am

Could you check to see if the door on the house is locked or not?
If its locked, the player probably does not own it yet and has not visited it.

http://www.creationkit.com/GetLockLevel_-_ObjectReference
User avatar
STEVI INQUE
 
Posts: 3441
Joined: Thu Nov 02, 2006 8:19 pm

Post » Tue Jun 19, 2012 3:08 am

That's not really what I need. I just need a check that would tell the script if the player OWNS the house or not. If he doesn't, it doesn't let him teleport inside. If he does, it lets him.
User avatar
cassy
 
Posts: 3368
Joined: Mon Mar 05, 2007 12:57 am

Post » Tue Jun 19, 2012 11:47 am

Well, that is exactly what a check on the door being locked would do. If you own and have visited your house, the door will be unlocked. Otherwise the door is still 'key locked'.
You could check for the key in the players inventory instead. They get the key when they get the house.
User avatar
Nadia Nad
 
Posts: 3391
Joined: Thu Aug 31, 2006 3:17 pm

Post » Tue Jun 19, 2012 5:39 am

you can try using a condition:

GetVMQuestVariable HousePurchase, :SolitudeHouseVar_var == 1.00


this checks whether Proudspire Manor was purchased or not. a value of 1.00 means purchased, and 0 is not purchased.
GetVMQuestVariable is a condition function, not a papyrus one
Seriously if you don't know what you're talking about you're doing worse than not helping
User avatar
James Shaw
 
Posts: 3399
Joined: Sun Jul 08, 2007 11:23 pm

Post » Tue Jun 19, 2012 11:14 am

Well, that is exactly what a check on the door being locked would do. If you own and have visited your house, the door will be unlocked. Otherwise the door is still 'key locked'.
You could check for the key in the players inventory instead. They get the key when they get the house.

Ah, yes. Good idea. That should be simpler to do. I'll look into it.
User avatar
Vickey Martinez
 
Posts: 3455
Joined: Thu Apr 19, 2007 5:58 am

Post » Tue Jun 19, 2012 12:10 pm

You could check for the key in the players inventory instead. They get the key when they get the house.

I also had this idea, you beat me to it; however I was thinking that it may be possible to drop the key once the house has been visited and it would no longer be a quest item.... I know it's unlikely that a player would drop the key for any reason but I suppose you gotta consider every possibility.
User avatar
Jerry Jr. Ortiz
 
Posts: 3457
Joined: Fri Nov 23, 2007 12:39 pm

Post » Tue Jun 19, 2012 1:28 pm

I also had this idea, you beat me to it; however I was thinking that it may be possible to drop the key once the house has been visited and it would no longer be a quest item.... I know it's unlikely that a player would drop the key for any reason but I suppose you gotta consider every possibility.

Yes, true. That's why I wanted to run a check if the player owns the house but not by checking if the door is locked or if the player owns the key. I think it would be possible to check the ownership of it through the script. Perhaps maybe check to see if PlayerFaction is Owner of the house? Since when you buy it, it sets the ownership to PlayerFaction. Though, I gotta figure out how.

Edit: Or maybe even use this http://www.creationkit.com/GetActorOwner_-_ObjectReference
User avatar
Misty lt
 
Posts: 3400
Joined: Mon Dec 25, 2006 10:06 am

Post » Tue Jun 19, 2012 5:46 am

cell Property cellInterior  Auto	;set this property to the cell in question, eg. WhiterunBreezehomefaction Property factionPlayer auto  ;set this to the PlayerFaction factionif (cellInterior.GetFactionOwner() == factionPlayer)   ;do stuff hereendif
That will work on the 5 existing houses - it'll be up to you to set the owner faction for the cell if it's a new house.
User avatar
Sista Sila
 
Posts: 3381
Joined: Fri Mar 30, 2007 12:25 pm

Post » Tue Jun 19, 2012 2:25 am

Thank you! I will check it out as soon as I can.
User avatar
tiffany Royal
 
Posts: 3340
Joined: Mon Dec 25, 2006 1:48 pm

Post » Tue Jun 19, 2012 6:47 am

Well, that is exactly what a check on the door being locked would do. If you own and have visited your house, the door will be unlocked. Otherwise the door is still 'key locked'.
You could check for the key in the players inventory instead. They get the key when they get the house.

I don't think this is a good solution, since you can just unlock the door by opening the console command prompt, select the door and type "Unlock" to unlock the door without having the key.
User avatar
Alex [AK]
 
Posts: 3436
Joined: Fri Jun 15, 2007 10:01 pm

Post » Tue Jun 19, 2012 12:16 pm

That will work on the 5 existing houses - it'll be up to you to set the owner faction for the cell if it's a new house.

Thanks a bunch, that worked perfectly! I now have only one minor issue. Since I've put a Debug.MessageBox("You need to own the house first!") to show if you don't own it, and it DOES show that, so that's fine, but the problem is, if I teleport to the location right after the Breezehome in the list of locations, I get the Debug messagebox again.

Here's the part of the script with Whiterun.

if Mainbox == 0  	 Whiterun = QuestionMSGWR.Show()   ;Shows Whiterun locations question box	 Utility.Wait(0.2)	if Whiterun == 0 && WhiterunCell.GetFactionOwner() == FactionPlayer	   Teleport(caster, WhiterunBreezehome)	    elseif Debug.MessageBox("You need to own the house first!")elseif Whiterun == 1	   Teleport(caster, WhiterunMarketplace)elseif Whiterun == 2	  Teleport(caster, WhiterunJorrvaskr)elseif Whiterun == 3	   Teleport(caster, WhiterunSkyforge)elseif Whiterun == 4	   Teleport(caster, WhiterunDragonsreach)   	endif	   endif
User avatar
Shannon Lockwood
 
Posts: 3373
Joined: Wed Aug 08, 2007 12:38 pm

Post » Tue Jun 19, 2012 4:19 am

if Whiterun == 0   if WhiterunCell.GetFactionOwner() == FactionPlayer	  Teleport(caster, WhiterunBreezehome)   else	  Debug.MessageBox("You need to own the house first!")   endifelseif   whiterun == 1;followed by the rest of the "elseif"s
Not sure about using the debug stuff tho - requires an ini change to work which other users may not have.
User avatar
Laura Mclean
 
Posts: 3471
Joined: Mon Oct 30, 2006 12:15 pm

Post » Tue Jun 19, 2012 8:07 am

Thanks. And what do you mean it requires an ini change to work? I did not touch anything Debug related in my ini file, yet it still works O.o Though I could always use a Message property for it.
User avatar
*Chloe*
 
Posts: 3538
Joined: Fri Jul 07, 2006 4:34 am

Next

Return to V - Skyrim