Log Off NPC

Share scripts you wrote for Denizen-Bukkit here!
Post Reply
n0nnie
New
New
Posts: 18
Joined: January 10th, 2018, 3:19 am
Location: München - Germany
Contact:

Log Off NPC

Post by n0nnie » September 24th, 2019, 11:06 pm

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
Spoiler!
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]>"
Last edited by n0nnie on September 25th, 2019, 9:04 pm, edited 1 time in total.

User avatar
mcmonkey
Site Admin
Site Admin
Posts: 217
Joined: August 5th, 2016, 7:27 pm
Location: Los Angeles, California, USA
Contact:

Re: Log Off NPC

Post by mcmonkey » September 25th, 2019, 1:56 pm

This script is full of outdated syntax. Please update to ":" syntax https://guide.denizenscript.com/guides/ ... mmand.html and also "- stop" in place of the old "- queue clear".
Also remove all the stray "^", none of those belong.
Denizen lead developer.
http://mcmonkey.org

n0nnie
New
New
Posts: 18
Joined: January 10th, 2018, 3:19 am
Location: München - Germany
Contact:

Re: Log Off NPC

Post by n0nnie » September 25th, 2019, 9:05 pm

mcmonkey wrote:
September 25th, 2019, 1:56 pm
This script is full of outdated syntax. Please update to ":" syntax https://guide.denizenscript.com/guides/ ... mmand.html and also "- stop" in place of the old "- queue clear".
Also remove all the stray "^", none of those belong.
Thank you for pointing this out. Updated

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest