/edit. I edit 1st post.
1. If is new player, who doesn't start task yet
data\creaturescripts\scripts\QUEST.lua
data\npc\scripts\ratmission.lua
WHO HELP?
REP++
1. If is new player, who doesn't start task yet
09:56 Alex: Welcome in village my bro. This f#$king creatures are everywhere! Can you help me with killing? Or if you started ask me for monster name.
09:56 GOD Adi [200]: monster name
09:56 GOD Adi [200]: monster
[nothing]
09:57 GOD Adi [200]: hi
09:57 Alex: Welcome in village my bro. This f#$king creatures are everywhere! Can you help me with killing? Or if you started ask me for monster name.
09:58 GOD Adi [200]: killing
09:58 Alex: Huh, I need to kill Wolves, Bears, Goblins, Hunters, Rats. What do you choose for warm-up ? haha!
09:58 GOD Adi [200]: Rats
09:58 Alex: You must kill 5 rats, come back when you kill and ask for rats.You can leave by asking for leave.
09:58 GOD Adi [200]: rats
09:58 Alex: You Still need to kill 5 rats.
09:58 GOD Adi [200]: rats
09:58 Alex: You Still need to kill 5 rats.
09:58 GOD Adi [200]: ok
[Ok, lets check i go kill rats and]
data\creaturescripts\scripts\QUEST.lua
Code:
---locals copied from npc script :)
--keep in mind that names of monsters here must be as same in game so it is "wolf" not "wolves nor Wolf"
-- just edit nams
--["monster name"] = {storage = put unused storage , count = kills for each, rewards = {itemid}
local words = {["wolf"] = {storage = 20000, count = 35, reward = 2146},
["bear"] = {storage = 20001, count = 30, reward = 2146},
["goblin"] = {storage = 20002, count = 20, reward = 2146},
["hunter"] = {storage = 20003, count = 30, reward = 2146},
["rat"] = {storage = 20004, count = 5, reward = 2146}
}
function onKill(cid, target)
if(isPlayer(target) == TRUE) then
return TRUE
end
local monster = words[string.lower(getCreatureName(target))]
if(not monster) then
return TRUE
end
if getPlayerStorageValue(cid,monster.storage) == ((monster.count)-1) then
setPlayerStorageValue(cid,monster.storage, (monster.count)+1)
doPlayerPopupFYI(cid, " *#Congratulations!#*\n\n\n You have completed the ["..getCreatureName(target).."] quest.\n\n *Go talk to the npc to recieve your reward.")
return true
end
if getPlayerStorageValue(cid,monster.storage) == ((monster.count)+1) then
return true
end
if getPlayerStorageValue(cid,monster.storage) < 0 then
return true
end
setPlayerStorageValue(cid, monster.storage ,(getPlayerStorageValue(cid, monster.storage))+1)
doSendAnimatedText(getPlayerPosition(cid),""..getPlayerStorageValue(cid, monster.storage).."", math.random(01,255))
return true
end
data\npc\scripts\ratmission.lua
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
--Copy those locals paste them in the top of the creature script i gave you
local words = { ["Wolves"] = {storage = 20000, count = 35, reward = 2148 , itemcount = 1, expe =100},
["bears"] = {storage = 20001, count = 30, reward = 2148, itemcount = 1, expe =100},
["goblins"] = {storage = 20002, count = 20, reward = 2148, itemcount = 1, expe =100},
["hunters"] = {storage = 20003, count = 30, reward = 2148, itemcount = 1, expe =100},
["rats"] = {storage = 20004, count = 5, reward = 2148, itemcount = 30, expe =100}
--["monster name"] = {storage = put unused storage , count = kills for each, rewards = itemid}
}
local monsters = "Wolves, Bears, Goblins, Hunters, Rats" -- here put the name of monster in list
local unique = 7080
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, "killing") then
if getPlayerStorageValue(cid,unique) == 1 then
npcHandler:say(" You already in quest ask me for monster to see your progress.", cid)
else
npcHandler:say("Huh, I need to kill {"..monsters.."}. What do you choose for warm-up ? haha!", cid)
talkState[talkUser] = 1
end
end
for k, v in pairs(words) do
if msgcontains(msg, k) and (talkState[talkUser] == 1 or talkState[talkUser] == 4) then
if getPlayerStorageValue(cid,v.storage) < 0 then
npcHandler:say(" You must kill {"..v.count.."} "..k..", come back when you kill and ask for {"..k.."}.You can leave by asking for {leave}.", cid)
setPlayerStorageValue(cid,v.storage,0)
setPlayerStorageValue(cid,unique,1)
talkState[talkUser] = 4
elseif getPlayerStorageValue(cid,v.storage) >= 0 then
if getPlayerStorageValue(cid,v.storage) >= 0 and getPlayerStorageValue(cid,v.storage) < v.count then
npcHandler:say("You Still need to kill {"..v.count -(getPlayerStorageValue(cid,v.storage)).." "..k..".", cid)
elseif getPlayerStorageValue(cid,v.storage) == (v.count)+3 then
npcHandler:say(" You have already finished this quest.", cid)
elseif getPlayerStorageValue(cid,v.storage) >= v.count and getPlayerStorageValue(cid,v.storage) < (v.count)+3 then
npcHandler:say("Ahh! I see you have killed them all , here your reward is {"..getItemNameById(v.reward).."} and {"..v.expe.." experience}.", cid)
doPlayerAddItem(cid,v.reward,itemcount)
doPlayerAddExp(cid,expe)
setPlayerStorageValue(cid,complete,1)
setPlayerStorageValue(cid,v.storage,(v.count)+3)
doSendMagicEffect(getThingPos(cid),27)
talkState[talkUser] = 0
end
end
end
end
if msgcontains(msg, "leave") then
if talkState[talkUser] == 4 then
npcHandler:say("Are you sure you want to leave? You will lose all your kills if you did so.", cid)
talkState[talkUser] = 3
else
npcHandler:say("You havn't started a quest yet.", cid)
end
elseif msgcontains(msg, "yes") and talkState[talkUser] == 3 then
for k, v in pairs(words) do
if getPlayerStorageValue(cid,v.storage) > -1 then
setPlayerStorageValue(cid,v.storage,-1)
setPlayerStorageValue(cid,unique,-1)
npcHandler:say("You have cancelled all your kills.To start again come ask for {killing}", cid)
end
end
elseif msgcontains(msg, "no") and talkState[talkUser] == 3 then
npcHandler:say("Then go continue killing.", cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
WHO HELP?
REP++
Last edited: