Log Off NPC

n0nnie

Active member
I read a forum post on spigotmc.org where someone searched for a plugin to spawn a NPC if a player logs out. I decided to give it a try in Denizen and here is the result. Feel free to tell me Bugs or Suggestions.

This Script requires Citizens to work and will do nothing if you haven't installed it!

Here is the linke to the Paste:
https://one.denizenscript.com/haste/58655

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]>"
 

mcmonkey

Administrator
Staff member
Helper
This script is full of outdated syntax. Please update to ":" syntax https://guide.denizenscript.com/guides/basics/if-command.html and also "- stop" in place of the old "- queue clear".
Also remove all the stray "^", none of those belong.