Paste #58655: Log Off NPC

Date: 2019/09/25 21:03:19 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# ███████████████████████████████████████████████████████
# █                    Log Off NPC                      █
# █                                                     █
# █    This script requires Citizens!                   █
# █    It will check on Serverstart if you have         █
# █    it installed and will do nothing, if there       █
# █    is no Citizens installed!                        █
# █                                                     █
# █    This script should not need any editing          █
# █    except of the proximity trigger messages.        █
# █    I do not know more then zzzz in English          █
# █    for a sleeping person.                           █
# █                                                     █
# █    What does script do?                             █
# █    If someone with the permission offlinenpc        █
# █    logs out (disconnects) a NPC is created          █
# █    with the same Skin and the Name:                 █
# █    OFFLINE_<player.name>                            █
# █                                                     █
# █    On clicking the NPC it will tell you since       █
# █    when the player is offline. (Date of logout)     █
# █                                                     █
# █    If the Player logs back in, the NPC gets         █
# █    deleted. Why a permission?                       █
# █    If many players join on your Server, just to     █
# █    see if they can grief, and never come back       █
# █    the spawn would become very crowded,             █
# █    very soon ;)                                     █
# █                                                     █
# ███████████████████████████████████████████████████████ 

log_off_npc:
  type: world
  debug: false
  events:
    on server start:
    - if <server.list_plugin_names.contains[Citizens]> && <server.has_flag[log_off_npc].not>:
      - announce to_console "Welcome First Timer. Enabling Log Off NPCs for you"
      - flag server log_off_npc
      - stop

    on player quit:
    - if <server.has_flag[log_off_npc]>:
      - if <player.has_permission[offlinenpc]>:
        - define npcname "<red>OFFLINE_<&r><player.name>"
        - define npclocation <player.location>
        - define npcskin <player.skin_blob>
        - define player <player>
        - flag player offline:true
        - create player <def[npcname]> <def[npclocation]> save:<player.name>log_off_npc
        - flag <def[player]> offlinenpc:<entry[<player.name>log_off_npc].created_npc>
        - adjust <entry[<player.name>log_off_npc].created_npc> skin_blob:<def[npcskin]>
        - assignment set script:log_off_npc_assignment npc:<entry[<player.name>log_off_npc].created_npc>
        - flag <entry[<player.name>log_off_npc].created_npc> logoff:<util.date.time.day><&dot><util.date.time.month><&dot><util.date.time.year>
        - stop



    on player join:
    - if <player.has_flag[offline]>:
      - remove <player.flag[offlinenpc]>
      - flag player offlinenpc:!
      - flag player offline:!
      - stop




log_off_npc_assignment:
  type: assignment
  debug: false
  actions:
    on assignment:
    - trigger name:click state:true
    - trigger name:proximity state:true radius:5
    - lookclose true
    on enter proximity:
    - random:
      # █---  You might edit this to fit your language  ---█
      - chat targets:<npc.location.find.players.within[5]> "zzzz"
      - chat targets:<npc.location.find.players.within[5]> "Rapüüüh"
      - chat targets:<npc.location.find.players.within[5]> "*schnarch*"
      - chat targets:<npc.location.find.players.within[5]> "grummel"
    on click:
    - chat targets:<player> "Psst! I am offline since <npc.flag[logoff]>"