Jump to content

script won't work => need help


theoneandonlyboiler

Recommended Posts

Hi

 

I made a Rivet City apartment and now i'm trying to make it buyable at the market place. I've managed to get one of the merchants to sell it as an item. But the script that adds the actual key and deed and removes the apartment item from the player inventory just won't work. and with my very limited understanding of how scripts work i can't find the error.

 

here is the script:

**********************************************

scn RivetCityHouseScript

 

Begin OnAdd player

 

Player.AddItem HouseDeedRivetCity 1

Player.AddItem RivetCityHouseKey 1

Player.RemoveItem RivetCityApartment 1

 

End

**********************************************

 

The script is attached to the item that is sold by the merchant. So it should run if the player buys the apartment, add the key and deed to the player, remove the item and shut down. The GECK doesn't give me any errors when saving the script.

 

So, what is wrong with it?

Link to comment
Share on other sites

I checked and rechecked everything. The item is there, the key is there, the deed is there, the names match with the script commands. I can add the key and deed with the console in game and it works fine and i can buy the item. The script is attached to the item that is sold by the merchant so it should rund as soon as i buy it. So everything is as it should be as far as i understand it. It's just the script that won't run.
Link to comment
Share on other sites

Ok, now it is getting really confusing: If i drop the apartment from my inventory after buying it and then pick it up again, the script runs!

 

So buying it does'nt count as adding it to my inventory but throwing it on the floor and picking it up again does? What the f***!?

 

So at least it works somehow. But i would prefer it to run on buying the apartment. Any ideas how to accomplish this?

Link to comment
Share on other sites

So somehow the OnAdd doesn't run when the item is bought. It's odd, I accomplished to do it just a few days ago in a mod of my own so it should be possible.

 

Anyways, you could alternatively make a quest script with a gamemode block instead, which continuously checks if you have the item in your inventory.

 

ScriptName RivetCityHouseScript

BEGIN GameMode
If Player.GetItemCount RivetCityApartment > 0
	Player.AddItem HouseDeedRivetCity 1
	Player.AddItem RivetCityHouseKey 1
	Player.RemoveItem RivetCityApartment 1 1
	StopQuest RivetCityHouseQuest
EndIf
END

 

Attach this script to a Start Game Enabled quest called RivetCityHouseQuest. It will keep running until you have the item in your inventory, at which point it will add the key and deed, remove the item and stop the quest from running as there's no further use for it.

 

Hope it helps.

Link to comment
Share on other sites

theoneandonlyboiler - Hello!

 

I'm no expert on scripting, still learning myself. :)

 

I tested OnAdd too & it seemed to work but you could also try OnSell instead:

 

 

scn RivetCityHouseScript

 

Begin OnSell

 

Player.AddItem HouseDeedRivetCity 1

Player.AddItem RivetCityHouseKey 1

Player.RemoveItem RivetCityApartment 1 1

 

end

 

You attach that script to the item being sold.

 

The addition of the space & 1 on the end of the RemoveItem line means no message will be displayed of the item being removed, that can be handy if you don't want to spoil the illusion by having an item removed that's not really meant to have been there.

 

Hope this helps!

 

Prensa

Link to comment
Share on other sites

@theoneandonlyboiler

 

Well, generally you don't want to keep scripts running unless there's a reason for it. This script, however, barely uses any system resources, it's a simple check and a few lines of code and it does serve a purpose albeit small.

 

@prensa

 

Damn, I totally forgot that blocktype existed. *facepalm* :rolleyes:

Link to comment
Share on other sites

Well that blocktype could work, or you could use the doonce command:

 

-----------------------------------------

scn RivetCityHouseScript

 

Short DoOnce

 

Begin Onadd player

 

If DoOnce == 0

 

Player.AddItem HouseDeedRivetCity 1

Player.AddItem RivetCityHouseKey 1

Player.RemoveItem RivetCityApartment 1 1

 

set DoOnce to 1

 

end

-----------------------------------------

Edited by JkKILER
Link to comment
Share on other sites

@JkKILER

 

DoOnce is not really so much a command as it is a technique, which is employed when you want something to run only one time.

 

The OnAdd block already does that by default, it runs one time when the scripted item is added to an inventory, that's it.

 

Your script is not really any different from the original one. :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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