Code:
local VERSION = "1.0"
local PLAYER_NAME = ""
local PLAYER_RACE = ""
local PLAYER_CLASS = ""
local PLAYER_LEVEL = ""
--[[=============================================================================================
'Sophisticated' Greeting NPC
o Made by Claiver
================================================================================================
=========== (General Settings ) ======================================================================
==============================================================================================]]
--[ Define your server's Name.
local SERVER_NAME = "Claiver's Funserver"
--[[====================================================================================================
=========== (WelcomeNPC Settings ) ======================================================================
=====================================================================================================]]
--[ Define the EntryID of the NPC.
local NPC_ENTRYID = 5550101
--[ Define the maximum Distance between NPC and Player in Yards.
local MAX_RANGE = 30
--[ Set the Delay between Messages in Seconds
local MESSAGE_DELAY = 5
--[ Define the Type of ChatMessages. Choose between "Yell" or "Say"
local MESSAGE_TYPE = "Yell"
--[[ Define the Messages to be sent on Initiating the Welcome Sequence.
+ You can use predefined variables, make sure you copy the ".. and .." wrapped around it too!
Example: Welcome, "..PLAYER_NAME.."! You are a "..PLAYER_CLASS.."!
+ You can choose between the following predefined variables (copy+paste):
o "..PLAYER_NAME.."
o "..PLAYER_CLASS.."
o "..PLAYER_LEVEL.."
o "..PLAYER_RACE.."
o "..SERVER_NAME.."
+ You can set the Type of the message. Wether it is sent as a Yell or a Say by the NPC (this means everyone can see it) or
simply sent only to the Player.
You can set the first string to Global (= Only viewable by Player) or set it to Everyone (= Send the Chatmessage so everyone can see it, Yell or Say)
+ Make sure to add a new message on a new line, like this: {"TYPE", " YOUR MESSAGE HERE "},
]]function WM()
WELCOME_MESSAGES =
{
{"Everyone", "Welcome "..PLAYER_NAME.." to "..SERVER_NAME.."!"},
{"Global", "We hope you enjoy your stay as a "..PLAYER_RACE.." "..PLAYER_CLASS..". "},
{"Global", "May you have any questions regarding to "..SERVER_NAME..", be sure to open a ticket. Our GameMasters will get back to you shortly!"},
{"Global", "Make sure to check your Bags!"},
}
end
--[[===================================================================================================
=========== ( HealerNPC Settings ) ======================================================================
======================================================================================================
In this configuration section you can choose wether to Enable or Disable the Healer feature of the NPC.
This feature is completely optional, and you may define several options below.
--[ Define wether the Healer Feature is Enabled or Disabled. ]]
local HEALER_FEATURE = "Enabled"
--[[ Define the Mode of the Healer Feature: Choose between Talk and Passive.
+ Talk will make the Player have to talk to the NPC in order to be healed.
+ Passive will make the NPC automatically heal the Players once they enter the NPC's Range. ]]
local HEALER_MODE = "Passive"
--[ Define the Percentage of the Player's Health before the Healing Feature is able to be used.
local MIN_HEALTHPCT = 50
--[ Define the Maximum Distance between Player and NPC in order to be Healed. Distance in Yards.
local MAX_HEALDISTANCE = 30
--[ Define wether or not the NPC will Notify the Player (messages) about heals. Disabled/Enabled.
local HEALING_MESSAGES = "Enabled"
--[ Define the Type of ChatMessages sent for healing notifications. Choose between "Yell" or "Say".
local HEAL_MESSAGETYPE = "Say"
--[[ Define the Messages to be sent on Initiating the Healing Sequence.
+ You can use predefined variables, wrap (( and )) around them. Like this:
I am healing you, ((PLAYER_NAME)) !
+ You can use the following predefined variables:
o "..PLAYER_NAME.."
o "..PLAYER_CLASS.."
o "..PLAYER_LEVEL.."
o "..PLAYER_RACE.."
+ Make sure to add a new message on a new line, like this: {" YOUR MESSAGE HERE "},
+ One message will be Randomly chosen out of the defined messages. ]]
function HM()
HEAL_MESSAGES =
{
{""..PLAYER_NAME.." you look weakened!"},
{"Hold on, "..PLAYER_NAME.."! I'll heal you!"},
}
end
-----------------------Do Not Edit Past This Point------------------
----------------------- ------------------
local type, string, table, rawget, rawset = type, string, table, rawget, rawset;
local WELCOMED_PLAYERS = {}
local mt = {
__index = (function(t,k)
local dat = rawget(t,k)
if (not dat) then
rawset(t,k,true)
return nil
end
return dat
end),
}
setmetatable(WELCOMED_PLAYERS, mt)
function Welcome_OnSpawn(pUnit, Event)
pUnit:RegisterEvent("Check_WelcomeT", 1200, 0)
if (HEALER_FEATURE == "Enabled") then
if (HEALER_MODE == "Passive") then
pUnit:RegisterEvent("Check_HealerT", 1500, 0)
end
end
end
RegisterUnitGossipEvent(NPC_ENTRYID, 1, "WelcomeNPC_OnGossipTalk")
RegisterUnitGossipEvent(NPC_ENTRYID, 2, "WelcomeNPC_OnGossipSelect")
function WelcomeNPC_OnGossipTalk(pUnit, event, Player, pMisc)
if (Player:IsInCombat() == true) then
Player:SendAreaTriggerMessage("You are in combat! Please first leave combat!")
Player:SendBroadcastMessage("You are in combat! Please first leave combat!")
Player:GossipComplete()
else
pUnit:GossipCreateMenu(5550101, Player, 0)
if (HEALER_MODE == "Talk") then
pUnit:GossipMenuAddItem(30, "Please Heal my Wounds!", 5550901, 0)
end
pUnit:GossipMenuAddItem(30, "I did not understand what you said, could you please inform me again?", 5550903, 0)
pUnit:GossipMenuAddItem(30, "Goodbye!", 5550902, 0)
pUnit:GossipSendMenu(Player)
end
end
function WelcomeNPC_OnGossipSelect(pUnit, event, Player, id, intid, Code, pMisc)
if (intid == 5550901) then
if (type(Player) == "userdata") then
if (Player:IsInCombat() == false) then
if (pUnit:GetDistance(Player) <= MAX_HEALDISTANCE*33) then
if (Player:GetHealthPct() <= MIN_HEALTHPCT) and (Player:GetHealthPct() > 0) then
if (HEALER_FEATURE == "Enabled") then
GetPlayerInformation(Player) HM()
SELECT_MESSAGE = math.random(1, #HEAL_MESSAGES)
for i,v in pairs(HEAL_MESSAGES) do
if (i == SELECT_MESSAGE) then
pUnit:SendChatMessage(GetType(HEAL_MESSAGETYPE), 0, HEAL_MESSAGES[SELECT_MESSAGE][1])
end
end
pUnit:FullCastSpellOnTarget(25840, Player)
end
end
end
end
end
Player:GossipComplete()
end
if (intid == 5550902) then
pUnit:SendAreaTriggerMessage("")
Player:GossipComplete()
end
if (intid == 5550903) then
WM() for k,v in pairs(WELCOME_MESSAGES) do
GetPlayerInformation(Player)
Player:SendBroadcastMessage(v[2])
end
Player:GossipComplete()
end
end
function GetPlayerInformation(_unit)
PLAYER_CLASS = _unit:GetPlayerClass()
PLAYER_NAME = _unit:GetName()
PLAYER_LEVEL = _unit:GetPlayerLevel()
GET_RACE = _unit:GetPlayerRace()
if (GET_RACE == 2) then PLAYER_RACE = "Orc" end
if (GET_RACE == 5) then PLAYER_RACE = "Undead" end
if (GET_RACE == 6) then PLAYER_RACE = "Tauren" end
if (GET_RACE == 8) then PLAYER_RACE = "Troll" end
if (GET_RACE == 10) then PLAYER_RACE = "Blood Elf" end
if (GET_RACE == 1) then PLAYER_RACE = "Human" end
if (GET_RACE == 3) then PLAYER_RACE = "Dwarf" end
if (GET_RACE == 4) then PLAYER_RACE = "NightElf" end
if (GET_RACE == 7) then PLAYER_RACE = "Gnome" end
if (GET_RACE == 11) then PLAYER_RACE = "Draenei" end
return PLAYER, PLAYER_CLASS, PLAYER_NAME, PLAYER_LEVEL, PLAYER_RACE
end
function Check_WelcomeT(pUnit, Event, Player)
Player_W = pUnit:GetRandomPlayer(0)
if (type(Player_W) == "userdata") then
if (pUnit:GetDistance(Player_W) <= MAX_RANGE*33) then
PLAYER_NAME = Player_W:GetName()
GetPlayerInformation(Player_W) WM()
if (not WELCOMED_PLAYERS[PLAYER_NAME]) then
for k,v in pairs(WELCOME_MESSAGES) do
if (v[1] == "Global") then
GetPlayerInformation(Player_W)
Player_W:SendBroadcastMessage(v[2])
end
if (v[1] == "Everyone") then
GetPlayerInformation(Player_W)
pUnit:SendChatMessage(GetType(MESSAGE_TYPE), 0, string.format(v[2]))
end
end
end
end
end
end
function GetType(_vdata)
if (_vdata == "Yell") then return 14 end
if (_vdata == "Say") then return 12 end
end
function Check_HealerT(pUnit,Event)
Player_H = pUnit:GetRandomPlayer(0)
if (type(Player_H) == "userdata") then
if (Player_H:IsInCombat() == false) then
if (pUnit:GetDistance(Player_H) <= MAX_HEALDISTANCE*33) then
if (Player_H:GetHealthPct() <= MIN_HEALTHPCT) and (Player_H:GetHealthPct() > 0) then
if (HEALER_FEATURE == "Enabled") then
GetPlayerInformation(Player_H) HM()
SELECT_MESSAGE = math.random(1, #HEAL_MESSAGES)
for i,v in pairs(HEAL_MESSAGES) do
if (i == SELECT_MESSAGE) then
pUnit:SendChatMessage(GetType(HEAL_MESSAGETYPE), 0, HEAL_MESSAGES[SELECT_MESSAGE][1])
end
end
pUnit:FullCastSpellOnTarget(25840, Player_H)
end
end
end
end
end
end
RegisterUnitEvent(NPC_ENTRYID, 18, "Welcome_OnSpawn")
print (" ====================================================")
print (" Loaded: 'Sophisticated' Greeting NPC (V"..VERSION..")")
print (" Made by Claiver")
print (" Please Report bugs @ MMOWNED.COM")
print (" ====================================================")
Code:
DELETE FROM creature_names WHERE entry = 5550101;
INSERT INTO creature_names
(`entry`, `name`, `subname`, `info_str`, `Flags1`, `type`, `family`, `rank`, `unk4`, `spelldataid`, `male_displayid`, `female_displayid`, `male_displayid2`, `female_displayid2`, `unknown_float1`, `unknown_float2`, `civilian`, `leader`)
VALUES
(5550101, 'Adventurer Yarnik XII', 'Master Greeter & Healer', '', 0, 0, 0, 1, 0, 0, 24356, 0, 0, 0, 1, 1, NULL, 0);
DELETE FROM creature_proto WHERE entry = 5550101;
INSERT INTO creature_proto
(`entry`, `minlevel`, `maxlevel`, `faction`, `minhealth`, `maxhealth`, `mana`, `scale`, `npcflags`, `attacktime`, `attacktype`, `mindamage`, `maxdamage`, `can_ranged`, `rangedattacktime`, `rangedmindamage`, `rangedmaxdamage`, `respawntime`, `armor`, `resistance1`, `resistance2`, `resistance3`, `resistance4`, `resistance5`, `resistance6`, `combat_reach`, `bounding_radius`, `auras`, `boss`, `money`, `invisibility_type`, `death_state`, `walk_speed`, `run_speed`, `fly_speed`, `extra_a9_flags`, `spell1`, `spell2`, `spell3`, `spell4`, `spell_flags`, `modImmunities`)
VALUES
(5550101, 80, 80, 1719, 60958, 60958, 0, 1, 1, 2000, 0, 1624, 1871, 0, 0, 0, 0, 360000, 16807, 0, 0, 0, 0, 0, 0, 2, 1, '0', 0, 0, 0, 0, 2.5, 8, 14, 0, 0, 0, 0, 0, 0, 0);
DELETE FROM npc_text WHERE entry = 5550101;
INSERT INTO npc_text
(entry, prob0, text0_0, text0_1, lang0, em0_0, em0_1, em0_2, em0_3, em0_4, em0_5, prob1, text1_0, text1_1, lang1, em1_0, em1_1, em1_2, em1_3, em1_4, em1_5, prob2, text2_0, text2_1, lang2, em2_0, em2_1, em2_2, em2_3, em2_4, em2_5, prob3, text3_0, text3_1, lang3, em3_0, em3_1, em3_2, em3_3, em3_4, em3_5, prob4, text4_0, text4_1, lang4, em4_0, em4_1, em4_2, em4_3, em4_4, em4_5, prob5, text5_0, text5_1, lang5, em5_0, em5_1, em5_2, em5_3, em5_4, em5_5, prob6, text6_0, text6_1, lang6, em6_0, em6_1, em6_2, em6_3, em6_4, em6_5, prob7, text7_0, text7_1, lang7, em7_0, em7_1, em7_2, em7_3, em7_4, em7_5)
VALUES
(5550101, 1, "May the light be with you, $n!$b$bI have seen and greeted many travelers, $c. My task is to assure everyone feels welcome and is informed about the purpose of this world.", "", 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, 0);
Take care <3!