[My first script release]
Script updated: 3/28/2012
I've been seeking for a npc that gives a player storagevalue and that storagevalue makes that, if you kill a monster (a monster as you want) it counts until the player got enough. When the player comes back with the kills, he gets a reward. But if he don't get it, no reward. I've search for that in 2 weeks. I just found old versions of these, and they did'nt work. So I decided to make one by my self. For rev... TFS 0.3.6.
I did this version of npc task becouse I want many quests as this that don't need to take much time to make. So I made many locals becouse you can just change them, then ur done.
So here it is:
1. Actions:
1*. actions.xml:
2*. .../data/actions/scripts/taskquestdoor.lua:
2. NPC:
1*. NPC: ...data/npc/Richard.xml:
2*. NPC script: .../data/npc/scripts/simple_task.lua:
3. Creaturescript:
1*. .../data/creaturescripts/creaturescripts.xml:
2*. .../data/creaturescripts/scripts/taskquest.lua:
3*. .../data/creaturescripts/scripts/login.lua:
above:
add:
Then, you are done! rep if i helped (y)
Sorry for my bad english
Script updated: 3/28/2012
Script updated: 3/28/2012
I've been seeking for a npc that gives a player storagevalue and that storagevalue makes that, if you kill a monster (a monster as you want) it counts until the player got enough. When the player comes back with the kills, he gets a reward. But if he don't get it, no reward. I've search for that in 2 weeks. I just found old versions of these, and they did'nt work. So I decided to make one by my self. For rev... TFS 0.3.6.
I did this version of npc task becouse I want many quests as this that don't need to take much time to make. So I made many locals becouse you can just change them, then ur done.
So here it is:
1. Actions
2. NPcs
3. Creaturescripts
2. NPcs
3. Creaturescripts
1. Actions:
1*. actions.xml:
XML:
<action actionid="1899" event="script" value="taskquestdoor.lua"/>
Lua:
local function doorEnter(cid, item, toPosition)
doTransformItem(item.uid, item.itemid + 1)
doTeleportThing(cid, toPosition)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local doorStorage = 98 -- (Must be the same in npcs)
if(getPlayerStorageValue(cid, doorStorage) > 0) then
doorEnter(cid, item, toPosition)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only enter if you've done Rangelongs task!")
return true
end
return true
end
2. NPC:
1*. NPC: ...data/npc/Richard.xml:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Richard" script="simple_task.lua" walkinterval="0" floorchange="0">
<look typeex="9242"/>
<parameters>
<parameter key="message_greet" value="Hi, welcome to Cronus World. This will be your very first {mission} you make."/>
</parameters>
</npc>
2*. NPC script: .../data/npc/scripts/simple_task.lua:
Lua:
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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
-- CFG
local configA = {
reward = true,
experience = true,
skill = true,
door = true,
missions = 6 -- Must be more than 1 and under 7 missions (6)
}
local rewardE = {{2160, 1}, {2160, 3}} -- item, count
local experienceE = 480000 -- exp
local skillE = {{4, 1}, {5, 2}} -- skillid, count
local mission = {
-- Info about what to kill for every mission. [1] = first mission and [2] second mission and so on...
[1] = "You have to kill 50 Dragons, 20 Dragon Lords.",
[2] = "You have to kill 4 Wyrms and 9 Demons.",
[3] = "You have to kill 6 Demodras and 9 Dragon Lords.",
[4] = "You have to kill 40 Vampires and 60 Ghouls.",
[5] = "You have to kill 40 Behemoths and 40 Wyverns.",
[6] = "You have to kill 30 Juggernauts and 10 Cyclops."
}
local Cmissions = {
-- {monsterStorage1, monsterstorage2} (Must be the same in creaturescripts)
[1] = {101, 102}, -- Enter empty storages
[2] = {103, 104},
[3] = {105, 106},
[4] = {107, 108},
[5] = {109, 110},
[6] = {111, 112}
}
local questStorage = 100 -- Enter empty storage (Must be the same in creaturescripts)
local questMission = 99 -- Enter empty storage
local doorStorage = 98 -- Enter empty storage (Must be the same in actions)
-- Don't touch --
local getStorage = getPlayerStorageValue(cid, questStorage)
local getMission = getPlayerStorageValue(cid, questMission)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'quest') or msgcontains(msg, 'mission')) then
if(getStorage < 0) then
if(getMission < 0) then
if(configA.missions >= 0) then
selfSay('You are on your first task. You want to continue?', cid)
talkState[talkUser] = 1
end
end
elseif(getStorage == 1) then
selfSay("You aren't done with your task yet. Go and continue.", cid)
talkState[talkUser] = 0
elseif(getStorage == 2) then
setPlayerStorageValue(cid, questStorage, 3)
setPlayerStorageValue(cid, questMission, 1)
selfSay("There you are! Talk to me again for more information!", cid)
if(configA.missions == 1) then
setPlayerStorageValue(cid, questStorage, 18)
if(configA.reward == true) then
for i = 1, #rewardE do
doPlayerAddItem(cid, rewardE[i][1], rewardE[i][2])
end
end
if(configA.experience == true) then
doPlayerAddExperience(cid, experienceE)
end
if(configA.skill == true) then
for i = 1, #skillE do
doPlayerAddSkill(cid, skillE[i][1], skillE[i][2])
end
end
if(configA.door == true) then
setPlayerStorageValue(cid, doorStorage, 1)
end
end
elseif(getStorage == 3) then
if(getMission == 1) then
if(configA.missions >= 1) then
selfSay('You are on your second task. You want to continue?', cid)
talkState[talkUser] = 2
end
end
elseif(getStorage == 4) then
selfSay("You aren't done with your task yet. Go and continue.", cid)
talkState[talkUser] = 0
elseif(getStorage == 5) then
setPlayerStorageValue(cid, questStorage, 6)
setPlayerStorageValue(cid, questMission, 2)
selfSay("There you are! Talk to me again for more information!", cid)
if(configA.missions == 2) then
setPlayerStorageValue(cid, questStorage, 18)
if(configA.reward == true) then
for i = 1, #rewardE do
doPlayerAddItem(cid, rewardE[i][1], rewardE[i][2])
end
end
if(configA.experience == true) then
doPlayerAddExperience(cid, experienceE)
end
if(configA.skill == true) then
for i = 1, #skillE do
doPlayerAddSkill(cid, skillE[i][1], skillE[i][2])
end
end
if(configA.door == true) then
setPlayerStorageValue(cid, doorStorage, 1)
end
end
elseif(getStorage == 6) then
if(getMission == 2) then
if(configA.missions >= 2) then
selfSay('You are on your third task. You want to continue?', cid)
talkState[talkUser] = 3
end
end
elseif(getStorage == 7) then
selfSay("You aren't done with your task yet. Go and continue.", cid)
talkState[talkUser] = 0
elseif(getStorage == 8) then
setPlayerStorageValue(cid, questStorage, 9)
setPlayerStorageValue(cid, questMission, 3)
selfSay("There you are! Talk to me again for more information!", cid)
if(configA.missions == 3) then
setPlayerStorageValue(cid, questStorage, 18)
if(configA.reward == true) then
for i = 1, #rewardE do
doPlayerAddItem(cid, rewardE[i][1], rewardE[i][2])
end
end
if(configA.experience == true) then
doPlayerAddExperience(cid, experienceE)
end
if(configA.skill == true) then
for i = 1, #skillE do
doPlayerAddSkill(cid, skillE[i][1], skillE[i][2])
end
end
if(configA.door == true) then
setPlayerStorageValue(cid, doorStorage, 1)
end
end
elseif(getStorage == 9) then
if(getMission == 3) then
if(configA.missions >= 3) then
selfSay('You are on your fourth task. You want to continue?', cid)
talkState[talkUser] = 4
end
end
elseif(getStorage == 10) then
selfSay("You aren't done with your task yet. Go and continue.", cid)
talkState[talkUser] = 0
elseif(getStorage == 11) then
setPlayerStorageValue(cid, questStorage, 12)
setPlayerStorageValue(cid, questMission, 4)
selfSay("There you are! Talk to me again for more information!", cid)
if(configA.missions == 4) then
setPlayerStorageValue(cid, questStorage, 18)
if(configA.reward == true) then
for i = 1, #rewardE do
doPlayerAddItem(cid, rewardE[i][1], rewardE[i][2])
end
end
if(configA.experience == true) then
doPlayerAddExperience(cid, experienceE)
end
if(configA.skill == true) then
for i = 1, #skillE do
doPlayerAddSkill(cid, skillE[i][1], skillE[i][2])
end
end
if(configA.door == true) then
setPlayerStorageValue(cid, doorStorage, 1)
end
end
elseif(getStorage == 12) then
if(getMission == 4) then
if(configA.missions >= 4) then
selfSay('You are on your fifth task. You want to continue?', cid)
talkState[talkUser] = 5
end
end
elseif(getStorage == 13) then
selfSay("You aren't done with your task yet. Go and continue.", cid)
talkState[talkUser] = 0
elseif(getStorage == 14) then
setPlayerStorageValue(cid, questStorage, 15)
setPlayerStorageValue(cid, questMission, 5)
selfSay("There you are! Talk to me again for more information!", cid)
if(configA.missions == 5) then
setPlayerStorageValue(cid, questStorage, 18)
if(configA.reward == true) then
for i = 1, #rewardE do
doPlayerAddItem(cid, rewardE[i][1], rewardE[i][2])
end
end
if(configA.experience == true) then
doPlayerAddExperience(cid, experienceE)
end
if(configA.skill == true) then
for i = 1, #skillE do
doPlayerAddSkill(cid, skillE[i][1], skillE[i][2])
end
end
if(configA.door == true) then
setPlayerStorageValue(cid, doorStorage, 1)
end
end
elseif(getStorage == 15) then
if(getMission == 5) then
if(configA.missions >= 5) then
selfSay('You are on your sixth task. You want to continue?', cid)
talkState[talkUser] = 6
end
end
elseif(getStorage == 16) then
selfSay("You aren't done with your task yet. Go and continue.", cid)
talkState[talkUser] = 0
elseif(getStorage == 17) then
setPlayerStorageValue(cid, questStorage, 18)
setPlayerStorageValue(cid, questMission, 6)
selfSay("There you are! You have now done the whole mission!", cid)
if(configA.missions == 6) then
setPlayerStorageValue(cid, questStorage, 18)
if(configA.reward == true) then
for i = 1, #rewardE do
doPlayerAddItem(cid, rewardE[i][1], rewardE[i][2])
end
end
if(configA.experience == true) then
doPlayerAddExperience(cid, experienceE)
end
if(configA.skill == true) then
for i = 1, #skillE do
doPlayerAddSkill(cid, skillE[i][1], skillE[i][2])
end
end
if(configA.door == true) then
setPlayerStorageValue(cid, doorStorage, 1)
end
end
elseif(getStorage == 18) then
selfSay("You have already done all my tasks.", cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
selfSay("".. mission[1] .." You want to do it?", cid)
talkState[talkUser] = 7
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 7) then
for i = 1, #Cmissions[1] do
setPlayerStorageValue(cid, Cmissions[1][i], 0)
end
setPlayerStorageValue(cid, questStorage, 1)
selfSay("You can go and kill them now!", cid)
talkState[talkUser] = 0
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
selfSay("".. mission[2] .." You want to do it?", cid)
talkState[talkUser] = 8
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 8) then
for i = 1, #Cmissions[2] do
setPlayerStorageValue(cid, Cmissions[2][i], 0)
end
setPlayerStorageValue(cid, questStorage, 4)
selfSay("You can go and kill them now!", cid)
talkState[talkUser] = 0
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 3) then
selfSay("".. mission[3] .." You want to do it?", cid)
talkState[talkUser] = 9
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 9) then
for i = 1, #Cmissions[3] do
setPlayerStorageValue(cid, Cmissions[3][i], 0)
end
setPlayerStorageValue(cid, questStorage, 7)
selfSay("You can go and kill them now!", cid)
talkState[talkUser] = 0
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 4) then
selfSay("".. mission[4] .." You want to do it?", cid)
talkState[talkUser] = 10
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 10) then
for i = 1, #Cmissions[4] do
setPlayerStorageValue(cid, Cmissions[4][i], 0)
end
setPlayerStorageValue(cid, questStorage, 10)
selfSay("You can go and kill them now!", cid)
talkState[talkUser] = 0
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 5) then
selfSay("".. mission[5] .." You want to do it?", cid)
talkState[talkUser] = 11
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 11) then
for i = 1, #Cmissions[5] do
setPlayerStorageValue(cid, Cmissions[5][i], 0)
end
setPlayerStorageValue(cid, questStorage, 13)
selfSay("You can go and kill them now!", cid)
talkState[talkUser] = 0
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 6) then
selfSay("".. mission[6] .." You want to do it?", cid)
talkState[talkUser] = 12
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 12) then
for i = 1, #Cmissions[6] do
setPlayerStorageValue(cid, Cmissions[6][i], 0)
end
setPlayerStorageValue(cid, questStorage, 16)
selfSay("You can go and kill them now!", cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
3. Creaturescript:
1*. .../data/creaturescripts/creaturescripts.xml:
XML:
<event type="kill" name="TaskQuest" event="script" value="taskquest.lua"/>
2*. .../data/creaturescripts/scripts/taskquest.lua:
Lua:
function onKill(cid, target)
local Cmissions = {
-- {monsterStorage1, monsterstorage2} (Must be the same in creaturescripts)
[1] = {101, 102},
[2] = {103, 104},
[3] = {105, 106},
[4] = {107, 108},
[5] = {109, 110},
[6] = {111, 112}
}
local monsterNames = {
-- {"monstername1", kill1, "monstername2", kill2}
[1] = {"Dragon", 50, "Dragon Lord", 20}, -- Write down the exact name. It wont work with bad spelled name.
[2] = {"Wyrm", 4, "Demon", 9},
[3] = {"Demodras", 6, "Dragon Lord", 9},
[4] = {"Vampire", 40, "Ghoul", 60},
[5] = {"Behemoth", 40, "Wyvern", 40},
[6] = {"Juggernaut", 30, "Cyclops", 10}
}
local questStorage = 100 -- Same storage value as in NPC(questStorage == 100)
if(getPlayerStorageValue(cid, questStorage) == 1) then
if(getCreatureName(target) == monsterNames[1][1]) then
if(getPlayerStorageValue(cid, Cmissions[1][1]) < monsterNames[1][2]) then
setPlayerStorageValue(cid, Cmissions[1][1], getPlayerStorageValue(cid, Cmissions[1][1]) + 1)
doPlayerSendTextMessage(cid, 19, "".. getPlayerStorageValue(cid, Cmissions[1][1]) .." / ".. monsterNames[1][2] .." ".. monsterNames[1][1] .."s killed.")
end
elseif(getCreatureName(target) == monsterNames[1][3]) then
if(getPlayerStorageValue(cid, Cmissions[1][2]) < monsterNames[1][4]) then
setPlayerStorageValue(cid, Cmissions[1][2], getPlayerStorageValue(cid, Cmissions[1][2]) + 1)
doPlayerSendTextMessage(cid, 19, "".. getPlayerStorageValue(cid, Cmissions[1][2]) .." / ".. monsterNames[1][4] .." ".. monsterNames[1][3] .."s killed.")
end
end
if(getPlayerStorageValue(cid, Cmissions[1][1]) >= monsterNames[1][2] and getPlayerStorageValue(cid, Cmissions[1][2]) >= monsterNames[1][4]) then
setPlayerStorageValue(cid, questStorage, 2)
end
elseif(getPlayerStorageValue(cid, questStorage) == 4) then
if(getCreatureName(target) == monsterNames[2][1]) then
if(getPlayerStorageValue(cid, Cmissions[2][1]) < monsterNames[2][2]) then
setPlayerStorageValue(cid, Cmissions[2][1], getPlayerStorageValue(cid, Cmissions[2][1]) + 1)
doPlayerSendTextMessage(cid, 19, "".. getPlayerStorageValue(cid, Cmissions[2][1]) .." / ".. monsterNames[2][2] .." ".. monsterNames[2][1] .."s killed.")
end
elseif(getCreatureName(target) == monsterNames[2][3]) then
if(getPlayerStorageValue(cid, Cmissions[2][2]) < monsterNames[2][4]) then
setPlayerStorageValue(cid, Cmissions[2][2], getPlayerStorageValue(cid, Cmissions[2][2]) + 1)
doPlayerSendTextMessage(cid, 19, "".. getPlayerStorageValue(cid, Cmissions[2][2]) .." / ".. monsterNames[2][4] .." ".. monsterNames[2][3] .."s killed.")
end
end
if(getPlayerStorageValue(cid, Cmissions[2][1]) >= monsterNames[2][2] and getPlayerStorageValue(cid, Cmissions[2][2]) >= monsterNames[2][4]) then
setPlayerStorageValue(cid, questStorage, 5)
end
elseif(getPlayerStorageValue(cid, questStorage) == 7) then
if(getCreatureName(target) == monsterNames[3][1]) then
if(getPlayerStorageValue(cid, Cmissions[3][1]) < monsterNames[3][2]) then
setPlayerStorageValue(cid, Cmissions[3][1], getPlayerStorageValue(cid, Cmissions[3][1]) + 1)
doPlayerSendTextMessage(cid, 19, "".. getPlayerStorageValue(cid, Cmissions[3][1]) .." / ".. monsterNames[3][2] .." ".. monsterNames[3][1] .."s killed.")
end
elseif(getCreatureName(target) == monsterNames[3][3]) then
if(getPlayerStorageValue(cid, Cmissions[3][2]) < monsterNames[3][4]) then
setPlayerStorageValue(cid, Cmissions[3][2], getPlayerStorageValue(cid, Cmissions[3][2]) + 1)
doPlayerSendTextMessage(cid, 19, "".. getPlayerStorageValue(cid, Cmissions[3][2]) .." / ".. monsterNames[3][4] .." ".. monsterNames[3][3] .."s killed.")
end
end
if(getPlayerStorageValue(cid, Cmissions[3][1]) >= monsterNames[3][2] and getPlayerStorageValue(cid, Cmissions[3][2]) >= monsterNames[3][4]) then
setPlayerStorageValue(cid, questStorage, 8)
end
elseif(getPlayerStorageValue(cid, questStorage) == 10) then
if(getCreatureName(target) == monsterNames[4][1]) then
if(getPlayerStorageValue(cid, Cmissions[4][1]) < monsterNames[4][2]) then
setPlayerStorageValue(cid, Cmissions[4][1], getPlayerStorageValue(cid, Cmissions[4][1]) + 1)
doPlayerSendTextMessage(cid, 19, "".. getPlayerStorageValue(cid, Cmissions[4][1]) .." / ".. monsterNames[4][2] .." ".. monsterNames[4][1] .."s killed.")
end
elseif(getCreatureName(target) == monsterNames[4][3]) then
if(getPlayerStorageValue(cid, Cmissions[4][2]) < monsterNames[4][4]) then
setPlayerStorageValue(cid, Cmissions[4][2], getPlayerStorageValue(cid, Cmissions[4][2]) + 1)
doPlayerSendTextMessage(cid, 19, "".. getPlayerStorageValue(cid, Cmissions[4][2]) .." / ".. monsterNames[4][4] .." ".. monsterNames[4][3] .."s killed.")
end
end
if(getPlayerStorageValue(cid, Cmissions[4][1]) >= monsterNames[4][2] and getPlayerStorageValue(cid, Cmissions[4][2]) >= monsterNames[4][4]) then
setPlayerStorageValue(cid, questStorage, 11)
end
elseif(getPlayerStorageValue(cid, questStorage) == 13) then
if(getCreatureName(target) == monsterNames[5][1]) then
if(getPlayerStorageValue(cid, Cmissions[5][1]) < monsterNames[5][2]) then
setPlayerStorageValue(cid, Cmissions[5][1], getPlayerStorageValue(cid, Cmissions[5][1]) + 1)
doPlayerSendTextMessage(cid, 19, "".. getPlayerStorageValue(cid, Cmissions[5][1]) .." / ".. monsterNames[5][2] .." ".. monsterNames[5][1] .."s killed.")
end
elseif(getCreatureName(target) == monsterNames[5][3]) then
if(getPlayerStorageValue(cid, Cmissions[5][2]) < monsterNames[5][4]) then
setPlayerStorageValue(cid, Cmissions[5][2], getPlayerStorageValue(cid, Cmissions[5][2]) + 1)
doPlayerSendTextMessage(cid, 19, "".. getPlayerStorageValue(cid, Cmissions[5][2]) .." / ".. monsterNames[5][4] .." ".. monsterNames[5][3] .."s killed.")
end
end
if(getPlayerStorageValue(cid, Cmissions[5][1]) >= monsterNames[5][2] and getPlayerStorageValue(cid, Cmissions[5][2]) >= monsterNames[5][4]) then
setPlayerStorageValue(cid, questStorage, 14)
end
elseif(getPlayerStorageValue(cid, questStorage) == 16) then
if(getCreatureName(target) == monsterNames[6][1]) then
if(getPlayerStorageValue(cid, Cmissions[6][1]) < monsterNames[6][2]) then
setPlayerStorageValue(cid, Cmissions[6][1], getPlayerStorageValue(cid, Cmissions[6][1]) + 1)
doPlayerSendTextMessage(cid, 19, "".. getPlayerStorageValue(cid, Cmissions[6][1]) .." / ".. monsterNames[6][2] .." ".. monsterNames[6][1] .."s killed.")
end
elseif(getCreatureName(target) == monsterNames[6][3]) then
if(getPlayerStorageValue(cid, Cmissions[6][2]) < monsterNames[6][4]) then
setPlayerStorageValue(cid, Cmissions[6][2], getPlayerStorageValue(cid, Cmissions[6][2]) + 1)
doPlayerSendTextMessage(cid, 19, "".. getPlayerStorageValue(cid, Cmissions[6][2]) .." / ".. monsterNames[6][4] .." ".. monsterNames[6][3] .."s killed.")
end
end
if(getPlayerStorageValue(cid, Cmissions[6][1]) >= monsterNames[6][2] and getPlayerStorageValue(cid, Cmissions[6][2]) >= monsterNames[6][4]) then
setPlayerStorageValue(cid, questStorage, 17)
end
end
return true
end
3*. .../data/creaturescripts/scripts/login.lua:
above:
Lua:
return true
end
add:
Lua:
registerCreatureEvent(cid, "TaskQuest")
Then, you are done! rep if i helped (y)
Sorry for my bad english
Script updated: 3/28/2012
Last edited: