what if i need to do alot of monsters? i understood the creatureevents one.local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandlernCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandlernCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandlernCreatureSay(cid, type, msg) end function onThink() npcHandlernThink() end local storage = 5002 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, "mission") then if getPlayerStorageValue(cid, storage) == -1 then selfSay("I have a mission for you to kill 5 dragons and 3 dragon lords, do you accept?", cid) talkState[talkUser] = 1 elseif getPlayerStorageValue(cid, storage) == 1 then selfSay("Did you kill 5 dragons and 3 dragon lords?", cid) talkState[talkUser] = 1 else selfSay("You already did the mission.", cid) end elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then if getPlayerStorageValue(cid, storage) == -1 then selfSay("Good, come back when you killed them.", cid) setPlayerStorageValue(cid, storage, 1) else if getPlayerStorageValue(cid, 19000) == 5 and getPlayerStorageValue(cid, 19001) == 3 then selfSay("Good job, here is your reward.", cid) doPlayerAddItem(cid, 2160, 5) doPlayerAddExp(cid, 50000) setPlayerStorageValue(cid, storage, 2) else selfSay("You didn't kill them all.", cid) end end talkState[talkUser] = 0 elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then selfSay("Ok then.", cid) talkState[talkUser] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
may you show me example please?You can use this one and only add monsters in the tables if you only want it with monsters.
https://otland.net/threads/collecting-items-and-monster-missions.230261/
I'm using tfs 0.4 and i've mitrox script so what i need is like thisWhat kind of example do you mean, can you be more specific about what you are looking for?
[1] = {monsters= {
{name = hydra, count = 12},
{name = demon, count = 20},
[2] = {
monsters = {
{name = "Rats", count = 20, storage = 21900},
{name = "Rotworms", count = 26, storage = 21901}
},
message = "Thanks, for your next mission kill",
level = 30,
rewarditems = {
{id = 2160, count = 5}
},
rewardexp = 40000
},
So for tfs 0.4 i must use this oneThe script I linked has this.
Code:[2] = { monsters = { {name = "Rats", count = 20, storage = 21900}, {name = "Rotworms", count = 26, storage = 21901} }, message = "Thanks, for your next mission kill", level = 30, rewarditems = { {id = 2160, count = 5} }, rewardexp = 40000 },
local config = {
['dragon'] = {amount = 5, storage = 19000, startstorage = 5002, startvalue = 1},
['dragon lord'] = {amount = 3, storage = 19001, startstorage = 5002, startvalue = 1}
}
function onKill(cid, target)
local monster = config[getCreatureName(target):lower()]
if isPlayer(target) or not monster or isSummon(target) then
return true
end
if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')
end
if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
end
return true
end
[2] = {
monsters = {
{name = "Rats", count = 20, storage = 21900},
{name = "Rotworms", count = 26, storage = 21901}
But what about Start value?local config = { ['Rats'] = {amount = 20, storage = 21900, startstorage = 5002, startvalue = 1}, ['Rotworms'] = {amount = 26, storage = 21901, startstorage = 5002, startvalue = 1} }
thanks, gonna try it.The startstorage should be the NPC storage, so 45551, the names of the monsters in the creaturescript should be without capital and s, so just rat and rotworm, the monster storage is correct.
local config = {
['rat'] = {amount = 20, storage = 21900, startstorage = 45551, startvalue = 1},
['rotworm'] = {amount = 26, storage = 21901, startstorage = 45551, startvalue = 1},
['dragon lord'] = {amount = 25, storage = 21902, startstorage = 45551, startvalue = 1}
}
function onKill(cid, target)
local monster = config[getCreatureName(target):lower()]
if isPlayer(target) or not monster or isSummon(target) then
return true
end
if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')
end
if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
end
return true
end
@Limos I've did all what you said and this is the result
when i'm trying to kill a monster that's what i found.Code:local config = { ['rat'] = {amount = 20, storage = 21900, startstorage = 45551, startvalue = 1}, ['rotworm'] = {amount = 26, storage = 21901, startstorage = 45551, startvalue = 1}, ['dragon lord'] = {amount = 25, storage = 21902, startstorage = 45551, startvalue = 1} } function onKill(cid, target) local monster = config[getCreatureName(target):lower()] if isPlayer(target) or not monster or isSummon(target) then return true end if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.') end if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.') setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1) end return true end
and the monster being like this when i kill rotworm.
function isSummon(cid)
return (isCreature(cid) == TRUE and (getCreatureMaster(cid) ~= cid)) and TRUE or FALSE
end
I've got 050-function, gonna past it there and see , thanks broo.