• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved Simple Task System [Please]

felipemko

New Member
Joined
Mar 2, 2010
Messages
175
Reaction score
3
Anybody can help me?
Please I need a Simple Task System with:

Hi, task, yes
and when finish gain the reward in the npc or automatic.

Without need to choose the monster, 1 NPC to only 1 TASK

Please REP+ for who help me
 
Did you added the creaturescript and did you register it in login.lua?
If it still doesn't work, post which server you use and how you added it.
 
Yes i did, my server is custom, but is TFS 0.4dev, i dont know why dont work..
local config = {
['rotworm'] = {amount = 2, storage = 19555, startstorage = 5555, 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 and (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

<event type="kill" name="taskRotworm" event="script" value="task/taskRotworm.lua"/>

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end

local storage = 5555

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", "task") then
if getPlayerStorageValue(cid, storage) == -1 then
selfSay("I have a mission for you to kill 2 rotworm, do you accept?", cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, storage) == 1 then
selfSay("Did you kill 2 rotworm?", cid)
talkState[talkUser] = 1
else
selfSay("You already did the mission.", cid)
end
elseif msgcontains(msg, "yes","sim") 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, 19555) == 5 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...", cid)
talkState[talkUser] = 0
end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

registerCreatureEvent(cid, "taskRotworm")
 
Test what the exact problems are with the script, test with different monsters etc and when exactly you get problems or errors and when not.
The problem is not with the script itself, only thing it does is check for storage and set storage and give textmessages.
 

Similar threads

Back
Top