Landlord Script - Offline Money Handling/Lock
Author: SplenectomY
Created: 2013-04-14T23:07:10-0400
Edited: 2013-04-15T21:34:06-0400
Denizen Version: 0.8.8 pre-release
Views: 33
Downloads: 901
Likes: 0
Description: Landlord Script by SplenectomY (John Cutlip)
Created April 14, 2013
Last modified April 14, 2013
REQUIRED MODS: WorldGuard, Vault+Economy
This script uses per-room "computer" (size 1 slime named Roomy on my server) to allow tenants to rent apartments for an indefinate amount of time.
Money is automatically taken from players' accounts, even if they are offline.
Users are automatically evicted if their money runs out. This is a no-hassle, very little configuration plugin.
NOTE: I have my Denizens config to allow you to chat-interface with NPCs through walls.
You might find this useful if your talking to this NPC through a locked door.
Users use a chat menu to interface with the slime NPC.
Options include manipulating a lever to lock/unlock an iron door when they leave the apartment,
allowing tours of vacant rooms, status (tenant) of room on inquiry, and contract cancellations.
Feel free to edit as you need to.
Questions? Want a demo? Hop on our server at mcserver.teamasshat.com. I'm on it during the evening hours (USA Eastern time).
I'm really busy and I don't write too many notes (I have a serious RPG server that I'm running. It's a full-time job.)
Hope you find this useful!
#####################################################
# Landlord Script by SplenectomY (John Cutlip)
# Created April 14, 2013
# Last modified April 14, 2013
#
# REQUIRED MODS: WorldGuard, Vault+Economy
#
# This script uses per-room "computer" (size 1 slime named Roomy on my server) to allow tenants to rent apartments for an indefinate amount of time.
# Money is automatically taken from players' accounts, even if they are offline.
# Users are automatically evicted if their money runs out. This is a no-hassle, very little configuration plugin.
# NOTE: I have my Denizens config to allow you to chat-interface with NPCs through walls.
# You might find this useful if your talking to this NPC through a locked door.
# Users use a chat menu to interface with the slime NPC.
# Options include manipulating a lever to lock/unlock an iron door when they leave the apartment,
# allowing tours of vacant rooms, status (tenant) of room on inquiry, and contract cancellations.
#
# Feel free to edit as you need to.
# Questions? Want a demo? Hop on our server at mcserver.teamasshat.com. I'm on it during the evening hours (USA Eastern time).
# I'm really busy and I don't write too many notes (I have a serious RPG server that I'm running. It's a full-time job.)
# Hope you find this useful!
#####################################################
#CHANGE THE SCRIPT NAME BELOW
'Rent Trigger An Bai Affordable 1':
type: world
#default constants: THESE DONT WORK - JUST FOR REFERENCE
# SEE NOTES IN ACTIVITY SCRIPT BELOW FOR EXPLANATIONS
#RoomName: An Bai Affordable Room 1
#Cost: 5
#RegionName: anbaipoor1
#NPCID: 188
###EDIT THIS AND USE FOR EVENTS### (REMOVE ALL # WHEN READY)
#events:
#on player join:
#- if "<flag.g:HomelessList#ROOMNAME GOES HERE#>" contains "<player.name>" flag player "Tenant:Homeless"
#- if "<flag.g:HomelessList#ROOMNAME GOES HERE#>" contains "<player.name>" execute as_op "region removemember #REGIONNAME GOES HERE# <player.name>"
#- if "<flag.g:HomelessList#ROOMNAME GOES HERE#>" contains "<player.name>" narrate "<gray>You were unable to pay rent and was evicted from <red>#ROOMNAME GOES HERE#<gray>!"
# else if "<player.name>" == "<flag.g:Tenant#ROOMNAME GOES HERE#>" flag global "TenantMoney#ROOMNAME GOES HERE#:<player.money>"
#on player quit:
#- if "<player.name>" == "<flag.g:Tenant#ROOMNAME GOES HERE#>" flag global "TenantMoney#ROOMNAME GOES HERE#:<player.money>"
#on 0:00 in world:
#- if "<flag.g:TenantMoney#ROOMNAME GOES HERE#>" < "#COST GOES HERE#" flag global "HomelessList#ROOMNAME GOES HERE#:<flag.g:Tenant#ROOMNAME GOES HERE#"
#- if "<flag.g:TenantMoney#ROOMNAME GOES HERE#>" < "#COST GOES HERE#" flag global "Tenant#ROOMNAME GOES HERE#:Evicted"
# else if "<flag.g:Tenant#ROOMNAME GOES HERE#>" != "Vacant" execute as_server "pay <flag.g:Tenant#ROOMNAME GOES HERE#> -<flag.g:Cost#ROOMNAME GOES HERE#>"
#on player chats:
#- if "<player.name>" == "<flag.g:Tenant#ROOMNAME GOES HERE#>" flag global "TenantMoney#ROOMNAME GOES HERE#:<player.money>"
##################################
events:
on player join:
- if "<flag.g:HomelessListAn Bai Affordable Room 1>" contains "<player.name>" flag player "Tenant:Homeless"
- if !<flag.p:Tenant> flag player "Tenant:Homeless"
- if "<flag.g:HomelessListAn Bai Affordable Room 1>" contains "<player.name>" execute as_op "region removemember anbaipoor1 <player.name>"
- if "<flag.g:HomelessListAn Bai Affordable Room 1>" contains "<player.name>" narrate "<gray>You were unable to pay rent and was evicted from <red>An Bai Affordable Room 1<gray>!"
else if "<player.name>" == "<flag.g:TenantAn Bai Affordable Room 1>" flag global "TenantMoneyAn Bai Affordable Room 1:<player.money>"
on player quit:
- if "<player.name>" == "<flag.g:TenantAn Bai Affordable Room 1>" flag global "TenantMoneyAn Bai Affordable Room 1:<player.money>"
on 7:00 in world:
- if "<flag.g:TenantMoneyAn Bai Affordable Room 1>" < "5" flag global "HomelessListAn Bai Affordable Room 1:<flag.g:TenantAn Bai Affordable Room 1>"
- if "<flag.g:TenantMoneyAn Bai Affordable Room 1>" < "5" flag global "TenantAn Bai Affordable Room 1:Evicted"
else if "<flag.g:TenantAn Bai Affordable Room 1>" != "Vacant" execute as_server "pay <flag.g:TenantAn Bai Affordable Room 1> -<flag.g:CostAn Bai Affordable Room 1>"
on player chats:
- if "<player.name>" == "<flag.g:TenantAn Bai Affordable Room 1>" flag global "TenantMoneyAn Bai Affordable Room 1:<player.money>"
#CHANGE THE SCRIPT NAME BELOW
'An Bai Affordable 1':
type: assignment
actions:
on assignment:
#NOTE ABOUT RADIUS FOR CHAT - Make sure a player can talk to your npc from outside the apartment!
#Otherwise, he/she will not be able to interact if there's a closed door.
# NOTE: I have my Denizens config to allow you to chat-interface with NPCs through walls.
# You might find this useful if your talking to this NPC through a locked door.
- trigger name:chat toggle:true radius:7 cooldown:1
- trigger name:proximity toggle:true radius:3 cooldown:10
- trigger name:click toggle:true cooldown:3
on despawn:
- execute as_server "npc spawn <npc.id>"
on death:
- execute as_server "npc spawn <npc.id>"
default constants:
# Update all of these constants.
RoomNumber: "room yi (one)"
#Cost is the amount of money taken from a player's account every in-game day (20 minutes).
Cost: 5
RoomName: "An Bai Affordable Room 1"
BuildingName: "the An Bai Affordable Housing Project"
#RegionName is a WorldGuard region. Should define the area that tenants can modify.
RegionName: "anbaipoor1"
#LockCoords is the location of the door lock lever so Roomy (NPC) can lock/unlock it. Coordinates are x,y,z,world.
LockCoords: "2252,100,9425,world"
interact scripts:
- 10 Rent Dialogue
'Rent Dialogue':
type: interact
steps:
"Intro*":
click trigger:
script:
#First, make record of current tenant's money (if player is current tenant) for use in evicting later
- if "<player.name>" == "<flag.g:Tenant<cons:RoomName>>" flag global "TenantMoney<cons:RoomName>:<player.money>"
#Then, we run the script as normal.
- chat "Hello <player.name>. How can I help you?"
- if "<flag.p:Tenant>" == "<cons:RoomName>" narrate "<gray>Options - '<red>Lock<gray>'/'<red>open<gray>' door. '<red>Cancel<gray>' contract. '<red>Nevermind<gray>'"
else narrate "<gray>Options - '<red>Info<gray>' about/rent this room. '<red>Nevermind<gray>'"
- if "<flag.n:IsRoomRented>" != "yes" narrate "<gray>You can also take a '<red>tour<gray>'."
- ^zap duration:30 "step:Choices"
proximity trigger:
entry:
script:
#First, make record of current tenant's money (if player is current tenant) for use in evicting later
- if "<player.name>" == "<flag.g:Tenant<cons:RoomName>>" flag global "TenantMoney<cons:RoomName>:<player.money>"
#Then, we run the script as normal.
# Check if current tenant is evicted
- ^if "<flag.g:Tenant<cons:RoomName>>" == "Evicted" runtask "script:Evict Tenant"
# Then start normal script here
- chat "Hello <player.name>."
- narrate "<gray>Say '<red>Roomy<gray>' to bring up the menu."
chat trigger:
'Roomy':
trigger: /Roomy/!
script:
#First, make record of current tenant's money (if player is current tenant) for use in evicting later
- if "<player.name>" == "<flag.g:Tenant<cons:RoomName>>" flag global "TenantMoney<cons:RoomName>:<player.money>"
# Check if current tenant is evicted
- ^if "<flag.g:Tenant<cons:RoomName>>" == "Evicted" runtask "script:Evict Tenant"
# Then start normal script here
- chat "How can I help you?"
- if "<flag.p:Tenant>" == "<cons:RoomName>" narrate "<gray>Options - '<red>Lock<gray>'/'<red>open<gray>' door. '<red>Cancel<gray>' contract. '<red>Nevermind<gray>'"
else narrate "<gray>Options - '<red>Info<gray>' about/rent this room. '<red>Nevermind<gray>'"
- if "<flag.n:IsRoomRented>" != "yes" narrate "<gray>You can also take a '<red>tour<gray>'."
- ^zap duration:30 "step:Choices"
"Choices":
chat trigger:
'Nevermind':
trigger: /Nevermind/.
script:
- chat "Signing off."
- ^zap "step:Intro"
'Info':
trigger: I need some /info/ about this room.
script:
# Check if current tenant is evicted
- ^if "<flag.g:Tenant<cons:RoomName>>" == "Evicted" runtask "script:Evict Tenant"
# Then start normal script here
- chat "This is <cons:RoomNumber> of <cons:BuildingName>."
- chat "This room costs $<cons:Cost> per day."
- if "<flag.p:Tenant>" == "<cons:RoomName>" chat "You are the current tenant here."
else if "<flag.n:IsRoomRented>" == "yes" chat "The current tenant is <flag.g:Tenant<cons:RoomName>>."
else chat "The room is currently vacant. Would you like to rent it?"
- if "<flag.n:IsRoomRented>" != "yes" narrate "<gray>Options - '<red>Sign<gray>' me up! '<red>No<gray>'."
else narrate "<gray>Dialogue finished. Options - '<red>Info<gray>' about this room. '<red>Nevermind<gray>'"
'Tour':
trigger: I'd like a /tour/.
script:
- if "<flag.n:IsRoomRented>" != "yes" switch location:<cons:LockCoords> state:on
else if "<flag.p:Tenant>" == "<cons:RoomName>" switch location:<cons:LockCoords> state:on
- if "<flag.n:IsRoomRented>" != "yes" narrate "<gray>The room door has been unlocked and opened."
else if "<flag.p:Tenant>" == "<cons:RoomName>" chat "You own this room, <player.name>. Let me open the door."
else chat "Sorry. This room is being rented by <red><flag.n:Renter><white> and is not open for touring."
- wait 2
- zap "step:Intro"
- narrate "<gray>Dialogue finished. Say '<red>Roomy<gray>' to bring up the menu."
'Lock':
trigger: /Lock/ the door.
script:
- if "<flag.p:Tenant>" == "<cons:RoomName>" switch location:<cons:LockCoords> state:off
else chat "You are not this room's tenant. I can't do that."
- if "<flag.p:Tenant>" == "<cons:RoomName>" narrate "<gray>The room door has been locked."
- zap "step:Intro"
- narrate "<gray>Dialogue finished. Say '<red>Roomy<gray>' to bring up the menu."
'Open':
trigger: /Open/ the door.
script:
- if "<flag.p:Tenant>" == "<cons:RoomName>" switch location:<cons:LockCoords> state:on
else chat "You are not this room's tenant. I can't do that."
- if "<flag.p:Tenant>" == "<cons:RoomName>" narrate "<gray>The room door has been unlocked."
- zap "step:Intro"
- narrate "<gray>Dialogue finished. Say '<red>Roomy<gray>' to bring up the menu."
'Cancel':
trigger: /Cancel/ my contract.
script:
- if "<flag.p:Tenant>" == "<cons:RoomName>" runtask "script:Cancel Contract"
else chat "I'm sorry. This is not your room. <red><flag.n:Renter><white> is the current tenant."
- if "<flag.p:Tenant>" != "<cons:RoomName>" narrate "<gray>Dialogue finished. Say '<red>Roomy<gray>' to bring up the menu."
- ^zap "step:Intro"
'Sign':
trigger: /Sign/ me up!
script:
- if "<flag.p:Tenant>" == "<cons:RoomName>" chat "You are already this room's tenant!"
else if "<flag.p:Tenant>" != "<Homeless>" chat "You are already renting <flag.p:Tenant>. Cancel that contract first."
else if "<player.money>" < "<cons:Cost>" chat "Sorry. You only have <red>$<player.money><white>."
else if "<flag.p:Tenant>" == "<Homeless>" runtask "script:Rent Room"
- ^zap "step:Intro"
- if "<flag.p:Tenant>" == "<cons:RoomName>" narrate "<gray>Dialogue finished. Say '<red>Roomy<gray>' to bring up the menu."
else if "<flag.p:Tenant>" != "<Homeless>" narrate "<gray>Dialogue finished. Say '<red>Roomy<gray>' to bring up the menu."
'No':
trigger: /No/, I'm not interested.
script:
- chat "Acknowledged. Signing off."
- ^zap "step:Intro"
- narrate "<gray>Dialogue finished. Say '<red>Roomy<gray>' to bring up the menu."
'Rent Room':
type: task
script:
- ^flag npc "IsRoomRented:Yes"
- ^flag player "Tenant:<cons:RoomName>"
- ^flag global "Tenant<cons:RoomName>:<player.name>"
- ^flag global "Cost<cons:RoomName>:<cons:Cost>"
- ^take money qty:<cons:Cost>
- narrate "<gold><npc.name> <gray>takes <red>$<cons:Cost><gray> as your security deposit."
- execute as_op "region addmember <cons:RegionName> <player.name>"
- narrate "<gray>You are now the tenant of this room."
- narrate "<gray>Rent money will be automatically taken from your account every in-game day (20 minutes)."
- narrate "<gray>If you run out of money, you will be evicted."
- ^execute as_server "denizen save"
'Cancel Contract':
type: task
script:
- ^flag npc "IsRoomRented:No"
- ^flag player "Tenant:Homeless"
- ^flag global "Tenant<cons:RoomName>:Vacant"
- execute as_op "region removemember <cons:RegionName> <player.name>"
- narrate "You cancelled your contract."
- narrate "You can no longer modify the room <cons:RoomName> at <cons:BuildingName>."
- ^execute as_server "denizen save"
'Evict Tenant':
type: task
script:
- ^flag global "Tenant<cons:RoomName>:Vacant"
- ^flag npc "IsRoomRented:No"
- ^execute as_server "denizen save"
This is an awesome advanced script.. and your first one too? Geez, well done man!
Thank you for the kind words :) It's the first one I've posted. I've got a few cool ones up my sleeves still ... I wish I had a little more time to write notes in. There's a lot I can talk about with this script!
Thank you for the kind words :) It's the first one I've posted. I've got a few cool ones up my sleeves still ... I wish I had a little more time to write notes in. There's a lot I can talk about with this script!