Jump to content

A little help with a script


Jokerine

Recommended Posts

Hello everybody! I have been working hard on a mod to rebuild Nipton, and something I'm stumped with is a script for a rentable bed I'd like to have. I know I could just make the player be given a key to a room with the bed in it, but I would have liked to go with a script that gives the player the key to a room, and simply removes it after 24 hours with a little message to let them know.

 

I have read around about this, and it seems like this requires a timer script, which is absolutely blowing my mind away. I've read the wiki and posts on the forums but I just cannot figure it out. Is there anybody who may happen to know how to make this happen, so I don't end up blowing up my computer?

 

Thank you, fingers crossed! :smile:

Edited by Jokerine
Link to comment
Share on other sites

Don't worry about timers and the like, it's actually really easy to do :)

 

Before you make your script, you need a bed. This bed needs to be a persistent reference, and it needs to have it's own reference (double-click it, give it a reference e.g. BedREF, and tick the persistent reference box). You will also need an NPC to rent the bed from, such as a receptionist. They will also need to have a reference, and be a persistent reference. You will also need top set up a quest for all of this to happen inside of. Assign the following script to your quest, and save the script as a quest.

 

scn RentBedScript

 

short rentday
begin Gamemode
if gameday != rentday
RentBedREF.SetOwnership RentNPC
endif
end
Then, go to your NPC's dialogue. Go to the topic where you rent the bed from them, and put this in the result script box:
player.removeitem caps001 x ;replace x with the caps you have to pay to rent the bed, or just delete this line if you don't want it
BedREF.SetOwnership
set RentBedQuest.rentday to gameday
This script removes the necessary caps, sets the ownership of your bed to the player, and sets the variable rentday in the script to gameday.
The main script creates a variable which is called rentday. Rentday is just a thing, you don't need to worry about it. But, basically, when the bed is rented, then it will set the rentday to gameday. When this is true, the player will own the bed, and they will therefore be able to use it. When the next day comes, the player will no longer own the bed. This will make them unable to use it.
As for a key, you can just add:
player.additem YourKeyName 1
to the topic where you rent the bed from the NPC, and then do:
player.removeitem YourKeyName 1
when the rentday is not gameday. (i.e. if rentday != gameday player.removeitem YourKeyName 1).
Link to comment
Share on other sites

Thanks! This sounds really complicated, but I'll give it a shot tomorrow. I was hoping to avoid quests because I'm bad with those and I did not want to have silent dialogue, so I just wanted to have an activator with the script attached to it, and add/remove the key with the script. But I'll see what I can do with this. WOuld it be possible to add this script to an activator instead of a quest? Thank you again - I hope I don't come across as rude, but all I was hoping for was to have the script to add and remove the key :smile:

Edited by Jokerine
Link to comment
Share on other sites

RIght, for an activator, you could do something similar:

 

scn RentBedScript

 

short rentday

 

begin onActivate Player

 

if gameday != rentday

player.additem YourKeyName 1

endif

 

end

 

You'd also need a script which removes the key from the player:

 

scn RemoveKeyScript

 

begin onTriggerEnter Player

 

if gameday == rentday

player.removeitem YourKeyName 1

endif

 

end

 

You'd have to assign that script to a trigger where you want the key to be removed from the player. Or, you could do:

 

scn RemoveKeyScript

 

begin Gamemode

 

if gameday != rentday

player.removeitem YourKeyName 1

endif

 

end

Link to comment
Share on other sites

That sounds like something I could manage, thanks! I figure the "gamemode" block to remove the key would be assigned to a quest? I figure just a blank quest could do, right? I'll read about this now and see what I can do. Thank you so much :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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