Jump to content

[LE] Script for buying a home


Recommended Posts

Thank you for that explanation! As you can probably tell I haven't done much scripting. I added your script to the activator (changed the first line of course) and tried to save. When it tried to compile the script I got the below message. (I should also point out at this point that I am making this for Skyrim SE, I just started this thread in Skyrim knowing that there would be a wider knowledge base).

 

Starting 1 compile threads for 1 files...
Compiling "MarasRespiteBuyScript"...
C:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\MarasRespiteBuyScript.psc(16,23): variable GoldBase is undefined
C:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\MarasRespiteBuyScript.psc(9,1): the parameter types of function onactivate in state waitforplayer on script marasrespitebuyscript do not match the parent script objectreference
No output generated for MarasRespiteBuyScript, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on MarasRespiteBuyScript

Link to comment
Share on other sites

 

Keep in mind that ToiaszPL script or any script won't work if you don't "add script commands to be processed when a message button is pressed".
So if you are a newvie i'll choose a different route if you don't know how to do it, you'll encounter problems with your pop up menu (mod not working - buy key not working) that will be releated to the above.

 

I was actually looking to see if I could use this script that I found on the CreationKit website. It's for a single layer menu, which is just what I need. I just really don't know how to get a script like this and a script like the one Tobias showed to play together.

 

ScriptName OptionsMenuScript Extends ObjectReference

 

Actor Property PlayerREF Auto

Armor Property MenuARMO Auto

Message Property OptionsMESG Auto

 

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)

If akNewContainer == PlayerREF ; Only the player

Int iButton = OptionsMESG.Show() ; Shows your menu.

PlayerREF.RemoveItem(MenuARMO, 1, True) ; Silently remove token. 'Self' does not work in this context, thus the property

If iButton == 0 ; Mage

Debug.Notification("Mage selected")

ElseIf iButton == 1 ; Thief

Debug.Notification("Thief selected")

ElseIf iButton == 2 ; Warrior

Debug.Notification("Warrior selected")

EndIf

EndIf

EndEvent

Link to comment
Share on other sites

Give me 1/2 h

 

My script is working fine cause i test it on my CK and my Hosue

 

i got Key and game remove my Gold from Inventory

 

Soon ill give you 3 Videos how to make it :P

but now im finishing my mod xD

 

Here is working Script:

 

 

 

Scriptname QLG_Script_BuyHouse extends ObjectReference  


	Key Property QKey Auto
	{ Key to give Player }
	
	Int Property QGold Auto
	{ Gold to Collect from Player }
	
	Actor Property QPlayer Auto
	{ Player Ref }
	
	Message Property QMsg Auto
	{ Message to show }
	
	Miscobject Property GoldRef Auto
	
	
	
	ObjectReference Property QManage Auto
	
	ObjectReference Property QBuy Auto
	
	
	
	
	
	
	
	
	
	
	
	
	
Event OnActivate( ObjectReference AAA )
	Int QReturn = QMsg.show()
	
	If ( QReturn == 1 )
		If ( QPlayer.GetGoldAmount() > QGold )
			QPlayer.AddItem( QKey , 1 )
			QPlayer.RemoveItem( GoldRef , QGold )
			GoToState( "Done" )
		Else
			Debug.Trace( "You don't have enough Gold !..." )
		EndIf
	EndIf
EndEvent

State Done
	; Do nothing
EndState

 

 

 

in those 3 Videos you will see how to make everything :P

but give me few sec xD

Link to comment
Share on other sites

 

 

Keep in mind that ToiaszPL script or any script won't work if you don't "add script commands to be processed when a message button is pressed".
So if you are a newvie i'll choose a different route if you don't know how to do it, you'll encounter problems with your pop up menu (mod not working - buy key not working) that will be releated to the above.

 

I was actually looking to see if I could use this script that I found on the CreationKit website. It's for a single layer menu, which is just what I need. I just really don't know how to get a script like this and a script like the one Tobias showed to play together.

 

ScriptName OptionsMenuScript Extends ObjectReference

 

Actor Property PlayerREF Auto

Armor Property MenuARMO Auto

Message Property OptionsMESG Auto

 

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)

If akNewContainer == PlayerREF ; Only the player

Int iButton = OptionsMESG.Show() ; Shows your menu.

PlayerREF.RemoveItem(MenuARMO, 1, True) ; Silently remove token. 'Self' does not work in this context, thus the property

If iButton == 0 ; Mage

Debug.Notification("Mage selected")

ElseIf iButton == 1 ; Thief

Debug.Notification("Thief selected")

ElseIf iButton == 2 ; Warrior

Debug.Notification("Warrior selected")

EndIf

EndIf

EndEvent

 

It's better to go with TobiaszPL script alone and not get involved with too complicated things, sometimes simpler is better.
What TobiaszPL script logic does is :
- You walk to the container press "E" activate it, then a "message box" pops up with a single option "OK" - you press it (you interact with the message box) get the key and buy the house - DONE.
- If you don't have the requiared money a "Notification" will pop up (a message in your left top corner - that you don't interact with), warning you that you don't have the money. > So you can't activate this - you can't buy the house - DONE & come back later with the money.
Edited by maxarturo
Link to comment
Share on other sites

Lel xD

 

Here is working script ( Compile fine - no tested in game )

 

 

 

Scriptname QLG_Script_BuyHouse extends ObjectReference  
{ Script to Buy House in Braverock !... }
;===- Base Info. -===;
 ;Created: 2019-03-30
 ;Update: 2019-03-30
 ;Author: TobiPL
 ;Unit: M.PC<3>
;===- Var. setup -============================================


;===- Req. setup -================
	Key Property QKey Auto			; Key to Give Player
	{ Key to give Player }
	
	Int Property QGold Auto			; Gold to Take from Player
	{ Gold to Collect from Player }


;===- Ref. setup -================
	Actor Property QPlayer Auto						; Player
	{ Player Ref }
	
	ObjectReference Property QBuySign Auto			; Buy House Sign
	{ Reference to Activator, House not Bought }
	
	ObjectReference Property QManageSign Auto		; Magage House Sign
	{ Reference to Activator, House Bought }


;===- Msg. setup -================
	Message Property QBuyMSG Auto
	{ Message to Show when Sign Activated 
		Button Setup:
		 Index > :0: > No
		 Index > :1: > Yes
	}
	
	Message Property QSoldMSG Auto
	{ Message to Show on Succes Bought 
		Button Setup:
		 Index > :0: Yey < or something :P 
	}
	
	Message Property QNoGoldMSG Auto
	{ Message to Show on Failed Bought 
		Button Setup:
		 Index > :0: > Ohh :( < or somethign :P 
	}
	

;===- Var. setup -================
	Miscobject Property GoldRef Auto
	{ Reference to Gold ( Item ) }
	
	bool IsSold = false


;===- Script -Main- -================================================
Event OnInit()
	If ( IsSold )
		
		GoToState( "Done" )
		QManageSign.Enable()
		QBuySign.Disable()
		
	Else
		
		GoToState( "WaitForPlayer" )
		QManageSign.Disable()
		QBuySign.Enable()
		
	EndIf
EndEvent


;===- Wait for Player to Activate Sign !... -========================
State WaitForPlayer
	Event OnActivate( ObjectReference QRef )
		If ( QRef == QPlayer )
			Int QReturn = QBuyMSG.show()
			
			If ( QReturn == 0 )			; Index 0{ Yes } Selected by Player
				If ( QPlayer.GetGoldAmount() >= QGold )
					
					QPlayer.AddItem( QKey , 1 )
					QPlayer.RemoveItem( GoldRef , QGold )
					GoToState( "Done" )
					
					Utility.Wait( 3.7 )
					
					QSoldMSG.show()
					
				Else
					
					Utility.Wait( 1.3 )
					
					QNoGoldMSG.show()
					
				EndIf
			EndIf
		EndIf
	EndEvent
EndState


;===- Player already have this House, do nothing -===================
State Done
	; Do nothing
EndState
 

 

 

 

How it Work?

 

 

You have Sign in game that is Activator

and ofc. you can activate this Sign by Pressing E on it

 

if you do it Message show for example

 

w8. ill copy from my house :smile:

"Do you want to Buy this House for 7400 Septims?"

and you can choice 2 answers "Yes" or "No"

 

if you Press No you just close this message Box

if you Press Yes game test your Gold if your have more than required and if you have game show you

from my script: "Yey, now Gray House is your !..." and Button with answer "Yey !..."

 

if you dont have gold Game show you: "Sorry, you don't have Gold to buy this House !" and single answer "Ohh... ok :("

 

 

Once you bought house "Buy Sign" is disabling and "Manage House" is enabling allowing you to Upgrade your house

 

and now im working on this Manage Sign :tongue: but first test and Videos on YT xD

 

but in Manage Sign you be able to Make your house bigger and even manage Production :tongue:

 

 

cause my Idea in Braverock 3 was like in Braverock 2 and like in BDO xD ( Black Desert Online )

 

so you can buy house and choice produciton in this house :tongue:

lel xD

 

 

 

but if all you need is just Buy sign / etc. you have already working script :tongue:

if you need something more, w8 4 more videos from me and more scripts xD lel

 

 

//Edit:

Y i know i can still improve this script :P

but ill do it later xD

Edited by TobiaszPL
Link to comment
Share on other sites

First off thank you again for all the help, I really appreciate it!

 

The script you have posted above is essentially exactly what I need. Though I don't need the manage house option, unless that can be made to disable the strongbox I'm using as the purchase activator and enable some other activator elsewhere. The player buys the house in Maras Temple, but the house itself is outside the city.

Link to comment
Share on other sites

So my Script is working fine... Tested and everything is OK

 

well maybe Sign is not changing to Manage but... its fine :D

 

here is my Script:

 

 

 

Scriptname QLG_Script_BuyHouse extends ObjectReference  
{ Script to Buy House in Braverock !... }
;===- Base Info. -===;
 ;Created: 2019-03-30
 ;Update: 2019-03-31
 ;Author: TobiPL
 ;Unit: M.PC<3>
;===- Var. setup -============================================


;===- Req. setup -================
	Key Property QKey Auto			; Key to Give Player
	{ Key to give Player }
	
	Int Property QGold Auto			; Gold to Take from Player
	{ Gold to Collect from Player }


;===- Ref. setup -================
	Actor Property QPlayer Auto
	{ Player Ref }
	
	ObjectReference Property QBuySign Auto
	{ Reference to Activator, House not Bought }
	
	ObjectReference Property QManageSign Auto
	{ Reference to Activator, House Bought }


;===- Msg. setup -================
	Message Property QBuyMSG Auto
	{ Message to Show when Sign Activated 
		Button Setup:
		 Index > :0: > Yes
		 Index > :1: > No
	}
	
	Message Property QSoldMSG Auto
	{ Message to Show on Succes Bought 
		Button Setup:
		 Index > :0: Yey < or something :P 
	}
	
	Message Property QNoGoldMSG Auto
	{ Message to Show on Failed Bought 
		Button Setup:
		 Index > :0: > Ohh :( < or somethign :P 
	}
	

;===- Var. setup -================
	MiscObject Property GoldRef Auto
	{ Reference to Gold ( Item ) }
	
	bool IsSold = false


;===- Script -Main- -================================================
Event OnInit()
	If ( IsSold )
		
		GoToState( "Done" )
		QManageSign.Enable()
		QBuySign.Disable()
		
	Else
		
		GoToState( "WaitForPlayer" )
		QManageSign.Disable()
		QBuySign.Enable()
		
	EndIf
EndEvent
;****************************
;===- Wait for Player to Activate Sign !... -========================
State WaitForPlayer
	Event OnActivate( ObjectReference QRef )
		If ( QRef == QPlayer )
			Int QReturn = QBuyMSG.show()
			If ( QReturn == 0 )
				If ( QPlayer.GetGoldAmount() >= QGold )
		;**********************************************************************
					QPlayer.AddItem( QKey , 1 )				; Give Player House Key
					QPlayer.RemoveItem( GoldRef , QGold )	; Take Gold from Player
					GoToState( "Done" )						; Stop Working
					QManageSign.Enable()					; Enable Manage Sign
					QBuySign.Disable()						; Disable Buy Sign
					IsSold = true							; Set House to Bought
					Utility.Wait( 3.7 )						; Wait to Show Succes Message
					QSoldMSG.show()							; Show Succes Bought Message
		;**********************************************************************
				Else					; But if Player don't have Enough Gold
					Utility.Wait( 1.3 )	; Wait to Show Fail Message
					QNoGoldMSG.show()	; Show Fail Bought Message
				EndIf					; Much Message !...
			EndIf
		EndIf
	EndEvent
EndState
;****************************
;===- Player already have this House, do nothing -===================
State Done
	; Do nothing
	; Btw. i Have Cat, Nicole <3 
	; she's best Epic and Amazing Cat !... Much Meow !...
EndState
;**************************** 

 

 

 

And here are Images:

 

 

 

Edited by TobiaszPL
Link to comment
Share on other sites

Yes :tongue:

 

QGold is how much Player have to Pay

QGoldRef is Reference to Item "Gold01" :smile:

 

if you don't need to Manage house but only purchase Key You can just delete all Lines for Manage

 

here is script without Manage Sign:

 

 

Scriptname QLG_Script_BuyHouse extends ObjectReference  
{ Script to Buy House in Braverock !... }
;===- Base Info. -===;
 ;Created: 2019-03-30
 ;Update: 2019-04-01
 ;Author: TobiPL
 ;Unit: M.PC<3>
;===- Var. setup -============================================


;===- Req. setup -================
	Key Property QKey Auto			; Key to Give Player
	{ Key to give Player }
	
	Int Property QGold Auto			; Gold to Take from Player
	{ Gold to Collect from Player }


;===- Ref. setup -================
	Actor Property QPlayer Auto
	{ Player Ref }
	
	ObjectReference Property QBuySign Auto
	{ Reference to Activator, House not Bought }


;===- Msg. setup -================
	Message Property QBuyMSG Auto
	{ Message to Show when Sign Activated 
		Button Setup:
		 Index > :0: > Yes
		 Index > :1: > No
	}
	
	Message Property QSoldMSG Auto
	{ Message to Show on Succes Bought 
		Button Setup:
		 Index > :0: Yey < or something :P 
	}
	
	Message Property QNoGoldMSG Auto
	{ Message to Show on Failed Bought 
		Button Setup:
		 Index > :0: > Ohh :( < or somethign :P 
	}
	

;===- Var. setup -================
	MiscObject Property GoldRef Auto
	{ Reference to Gold ( Item ) }
	
	bool IsSold = false


;===- Script -Main- -================================================
Event OnInit()
	If ( IsSold )
		
		GoToState( "Done" )
		QBuySign.Disable()
		
	Else
		
		GoToState( "WaitForPlayer" )
		QBuySign.Enable()
		
	EndIf
EndEvent
;****************************
;===- Wait for Player to Activate Sign !... -========================
State WaitForPlayer
	Event OnActivate( ObjectReference QRef )
		If ( QRef == QPlayer )
			Int QReturn = QBuyMSG.show()
			If ( QReturn == 0 )
				If ( QPlayer.GetGoldAmount() >= QGold )
		;**********************************************************************
					QPlayer.AddItem( QKey , 1 )				; Give Player House Key
					QPlayer.RemoveItem( GoldRef , QGold )	; Take Gold from Player
					GoToState( "Done" )						; Stop Working
					QBuySign.Disable()						; Disable Buy Sign
					IsSold = true							; Set House to Bought
					Utility.Wait( 3.7 )						; Wait to Show Succes Message
					QSoldMSG.show()							; Show Succes Bought Message
		;**********************************************************************
				Else					; But if Player don't have Enough Gold
					Utility.Wait( 1.3 )	; Wait to Show Fail Message
					QNoGoldMSG.show()	; Show Fail Bought Message
				EndIf					; Much Message !...
			EndIf
		EndIf
	EndEvent
EndState
;****************************
;===- Player already have this House, do nothing -===================
State Done
	; Do nothing
	; Btw. i Have Cat, Nicole <3 
	; she's best Epic and Amazing Cat !... Much Meow !...
EndState
;****************************  

 

 

 

or you can just ignore no needed references

they should be NULL and Function should be ignored...

 

but its bethesda so script maybe will try to enable NULL item or whatever it is if not setted xD

 

//Edit:

You can also just make door and then change it to Activator :P

and you can buy key from door :D

 

Activator door will disapear and normal door will show :P

cause this ObjectReference to ManageSign can be anything, dont have to be Sign or even activator :P

 

it can be also Static Rock or Tree :)

Edited by TobiaszPL
Link to comment
Share on other sites

Ok so I've got that right then. Good.

 

Was your manage sign going to require the player to spend money or resources for their upgrades? Or is it something they'll just toggle on and off? I kind of want to require the player to pay for their upgrades.

Edited by KiokothePirate
Link to comment
Share on other sites

  • Recently Browsing   0 members

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