function onCreatureAppear(cid)
end
local focuses = {}
local function isFocused(cid)
for i, v in pairs(focuses) do
if(v == cid) then
return true
end
end
return false
end
local function addFocus(cid)
if(not isFocused(cid)) then
table.insert(focuses, cid)
end
end
local function removeFocus(cid)
for i, v in pairs(focuses) do
if(v == cid) then
table.remove(focuses, i)
break
end
end
end
local function NpcLookDirection(cid, direction) --1(west), 2(north), 3(east), 4(south) --
doCreatureSetLookDirection(cid, direction)
end
local function lookAtFocus()
for i, v in pairs(focuses) do
if(isPlayer(v)) then
doNpcSetCreatureFocus(v)
return
end
end
doNpcSetCreatureFocus(0)
end
function onCreatureDisappear(cid)
if(isFocused(cid)) then
selfSay("Hmph!")
removeFocus(cid)
if(isPlayer(cid)) then --Be sure he's online
closeShopWindow(cid)
end
end
end
function onPlayerCloseChannel(cid)
if(isFocused(cid)) then
selfSay("Hmph!")
closeShopWindow(cid)
removeFocus(cid)
end
end
function onThink()
for i, focus in pairs(focuses) do
if(not isCreature(focus)) then
removeFocus(focus)
else
local distance = getDistanceTo(focus) or -1
if((distance > 4) or (distance == -1)) then
closeShopWindow(focus)
removeFocus(focus)
end
end
end
lookAtFocus()
end
function onPlayerCloseChannel(cid)
if(isFocused(cid)) then
selfSay("Hmph!")
closeShopWindow(cid)
removeFocus(cid)
end
end
local storage = {
progress = 40001,
players_killed = 4002
}
local GREET_MESSAGE = {"hi", "Hi", "hello", "Hello", "hey", "Hey"}
local BYE_MESSAGE = {"bye", "Bye", "goodbye", "Goodbye", "cya", "Cya"}
function onCreatureSay(cid, type, msg)
if((isInArray(GREET_MESSAGE, msg)) and not (isFocused(cid)) and getDistanceTo(cid) <= 3 and getPlayerStorageValue(cid, storage.progress) < 0) then
selfSay("Hello "..getPlayerName(cid).." I have a {quest} for you.", cid)
addFocus(cid)
-------------50 kills quest script--------------------
elseif(isFocused(cid) and msg == "quest" and getDistanceTo(cid) <= 3 and getPlayerStorageValue(cid, storage.progress) < 0) then
selfSay("I need to to {kill 50 players}. Once you have done so, come back and I will reward you and give you your next quest.", cid)
setPlayerStorageValue(cid, storage.progress, 0)
setPlayerStorageValue(cid, storage.players_killed, 0)
elseif((isInArray(GREET_MESSAGE, msg)) and not (isFocused(cid)) and getDistanceTo(cid) <= 3 and getPlayerStorageValue(cid, storage.progress) == 0) then
if getPlayerStorageValue(cid, storage.player_killed) == 50 then
selfSay("I see you have been killing well. Here is your reward.", cid)
selfSay("Now, I need you to kill 100 players. Come back and I will reward you again.", cid)
setPlayerStorageValue(cid, storage.progress, 1)
setPlayerStorageValue(cid, storage.player_killed, 0)
addFocus(cid)
----------Place quest reward for 50 players killed here.-------------
else
local kills_left = 50 - getPlayerStorageValue(cid, storage.players_killed)
selfSay("You have killed "..getPlayerStorageValue(cid, storage.player_killed).." players. You need "..kills_left.." kills more.", cid)
addFocus(cid)
end
------------100 kills quest script----------------
elseif((isInArray(GREET_MESSAGE, msg)) and not (isFocused(cid)) and getDistanceTo(cid) <= 3 and getPlayerStorageValue(cid, storage.progress) == 1) then
if getPlayerStorageValue(cid, storage.player_killed) == 100 then
selfSay("I see you have been killing well. Here is your reward.", cid)
selfSay("Now, I need you to kill 150 players. Come back and I will reward you again.", cid)
setPlayerStorageValue(cid, storage.progress, 2)
setPlayerStorageValue(cid, storage.player_killed, 0)
addFocus(cid)
----------Place quest reward for 100 players killed here.-------------
else
local kills_left = 100 - getPlayerStorageValue(cid, storage.players_killed)
selfSay("You have killed "..getPlayerStorageValue(cid, storage.player_killed).." players. You need "..kills_left.." kills more.", cid)
addFocus(cid)
end
------------150 kills quest script ---------------
elseif((isInArray(GREET_MESSAGE, msg)) and not (isFocused(cid)) and getDistanceTo(cid) <= 3 and getPlayerStorageValue(cid, storage.progress) == 2) then
if getPlayerStorageValue(cid, storage.player_killed) == 150 then
selfSay("I see you have been killing well. Here is your reward.", cid)
selfSay("Now, I need you to kill 200 players. Come back and I will reward you again.", cid)
setPlayerStorageValue(cid, storage.progress, 3)
setPlayerStorageValue(cid, storage.player_killed, 0)
addFocus(cid)
----------Place quest reward for 150 players killed here.-------------
else
local kills_left = 150 - getPlayerStorageValue(cid, storage.players_killed)
selfSay("You have killed "..getPlayerStorageValue(cid, storage.player_killed).." players. You need "..kills_left.." kills more.", cid)
addFocus(cid)
end
------------200 kills quest script ---------------
elseif((isInArray(GREET_MESSAGE, msg)) and not (isFocused(cid)) and getDistanceTo(cid) <= 3 and getPlayerStorageValue(cid, storage.progress) == 3) then
if getPlayerStorageValue(cid, storage.player_killed) == 200 then
selfSay("I see you have been killing well. Here is your reward.", cid)
selfSay("Now, I need you to kill 250 players. Come back and I will reward you again.", cid)
setPlayerStorageValue(cid, storage.progress, 4)
setPlayerStorageValue(cid, storage.player_killed, 0)
addFocus(cid)
----------Place quest reward for 200 players killed here.-------------
else
local kills_left = 200 - getPlayerStorageValue(cid, storage.players_killed)
selfSay("You have killed "..getPlayerStorageValue(cid, storage.player_killed).." players. You need "..kills_left.." kills more.", cid)
addFocus(cid)
end
------------250 kills quest script ---------------
elseif((isInArray(GREET_MESSAGE, msg)) and not (isFocused(cid)) and getDistanceTo(cid) <= 3 and getPlayerStorageValue(cid, storage.progress) == 4) then
if getPlayerStorageValue(cid, storage.player_killed) == 250 then
selfSay("I see you have been killing well. Here is your reward.", cid)
selfSay("Now, I need you to kill 300 players. Come back and I will reward you again.", cid)
setPlayerStorageValue(cid, storage.progress, 5)
setPlayerStorageValue(cid, storage.player_killed, 0)
addFocus(cid)
----------Place quest reward for 250 players killed here.-------------
else
local kills_left = 250 - getPlayerStorageValue(cid, storage.players_killed)
selfSay("You have killed "..getPlayerStorageValue(cid, storage.player_killed).." players. You need "..kills_left.." kills more.", cid)
addFocus(cid)
end
------------300 kills quest script ---------------
elseif((isInArray(GREET_MESSAGE, msg)) and not (isFocused(cid)) and getDistanceTo(cid) <= 3 and getPlayerStorageValue(cid, storage.progress) == 5) then
if getPlayerStorageValue(cid, storage.player_killed) == 3000 then
selfSay("I see you have been killing well. Here is your reward.", cid)
selfSay("That is all I have left for you.", cid)
setPlayerStorageValue(cid, storage.progress, 6)
setPlayerStorageValue(cid, storage.player_killed, 0)
addFocus(cid)
----------Place quest reward for 300 players killed here.-------------
else
local kills_left = 300 - getPlayerStorageValue(cid, storage.players_killed)
selfSay("You have killed "..getPlayerStorageValue(cid, storage.player_killed).." players. You need "..kills_left.." kills more.", cid)
addFocus(cid)
end
elseif((isInArray(GREET_MESSAGE, msg)) and not (isFocused(cid)) and getDistanceTo(cid) <= 3 and getPlayerStorageValue(cid, storage.progress) == 6) then
selfSay("I do not have any more quests for you.", cid)
--bye message
elseif((isFocused(cid)) and (isInArray(BYE_MESSAGE, msg)) and getDistanceTo(cid) <= 4) then
selfSay("Good-bye.", cid)
removeFocus(cid)
end
end