marekbuum
New Member
- Joined
- Jul 31, 2012
- Messages
- 7
- Reaction score
- 2
Hello, I have a problem with the Task System, namely the task system works fine, but when I enter the command !Task Info crashes me with an error.
Then he types !Task info and there is such an error in the console
source file
Then he types !Task info and there is such an error in the console
source file
XML:
<talkaction words="!task" event="script">
<![CDATA[
domodlib('task_config')
function onSay(cid, words, param)
local currentTask, tasks = '', {}
for k, v in pairs(taskMonsters) do
if getCreatureStorage(cid, taskConfig.taskStorage) == k then
currentTask = k
end
table.insert(tasks, k)
end
param = param:lower()
if param == '' then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[TASK]\n"!task info" - check your current task\n"!task TaskName" - start new task\n"!task off" - stop current task')
elseif param == 'info' then
local t = (getPlayerVocation(cid) - 4 > 0) and taskConfig.potion[getPlayerVocation(cid)-4] or taskConfig.potion[getPlayerVocation(cid)]
if currentTask ~= '' then
local task, text = taskMonsters[currentTask], ''
if getCreatureStorage(cid, t.doneStorage) == 0 and getCreatureStorage(cid, t.storage) >= 0 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[TASK INFO] You are doing potion task and you have used them '..getCreatureStorage(cid, t.storage)..' of '..t.uses..'.')
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[TASK INFO] You are doing '..currentTask..' task. You killed '..getCreatureStorage(cid, task.storage)..' of '..task.kills..' this kind of monsters.'..text)
else
if getCreatureStorage(cid, t.doneStorage) == 0 and getCreatureStorage(cid, t.storage) >= 0 then
return true, doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[TASK INFO] You are doing potion task and you have used them '..getCreatureStorage(cid, t.storage)..' of '..t.uses..'.')
end
doPlayerSendCancel(cid, 'You are not in any task.')
end
elseif param == 'off' then
if currentTask == '' then
return doPlayerSendCancel(cid, 'You are not in any task.')
end
doCreatureSetStorage(cid, taskConfig.taskStorage, '')
doCreatureSetStorage(cid, taskMonsters[currentTask].storage, 0)
doCreatureSetStorage(cid, taskMonsters[currentTask].doneStorage, 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You stopped currently '..currentTask..' task. You can now start other task.')
elseif param == 'potion' then
local p = (getPlayerVocation(cid) - 4 > 0) and taskConfig.potion[getPlayerVocation(cid)-4] or taskConfig.potion[getPlayerVocation(cid)]
if getCreatureStorage(cid, p.doneStorage) == 1 then
return doPlayerSendCancel(cid, 'You arleady done this kind of tasks.')
elseif p.minLevel > getPlayerLevel(cid) then
return doPlayerSendCancel(cid, 'You don\'t have enough level.')
end
if getCreatureStorage(cid, p.storage) < 0 then
doCreatureSetStorage(cid, p.storage, 0)
doCreatureSetStorage(cid, p.doneStorage, 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You have started potion task. You have to use '..p.uses..' potions. Good luck!')
else
doCreatureSetStorage(cid, p.storage, -1)
doPlayerSendCancel(cid, 'Currently you are doing this task.')
end
elseif param == 'superpotion' then
local p = (getPlayerVocation(cid) - 4 > 0) and taskConfig.superPotion[getPlayerVocation(cid)-4] or taskConfig.superPotion[getPlayerVocation(cid)]
local normal_p = (getPlayerVocation(cid) - 4 > 0) and taskConfig.potion[getPlayerVocation(cid)-4] or taskConfig.potion[getPlayerVocation(cid)]
if getCreatureStorage(cid, normal_p.doneStorage) < 1 then
return doPlayerSendCancel(cid, 'You have to finish normal potion task until you start new one.')
elseif getCreatureStorage(cid, p.doneStorage) == 1 then
return doPlayerSendCancel(cid, 'You arleady done this kind of tasks.')
elseif p.minLevel > getPlayerLevel(cid) then
return doPlayerSendCancel(cid, 'You don\'t have enough level.')
end
if getCreatureStorage(cid, p.storage) < 0 then
doCreatureSetStorage(cid, p.storage, 0)
doCreatureSetStorage(cid, p.doneStorage, 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You have started super potion task. You have to use '..p.uses..' potions. Good luck!')
else
doCreatureSetStorage(cid, p.storage, -1)
doPlayerSendCancel(cid, 'Currently you are doing this task.')
end
elseif isInArray(tasks, param) then
if currentTask ~= '' then
return doPlayerSendCancel(cid, 'Currently you are doing '..currentTask..' task. You can stop it typing "!taskoff".')
elseif taskMonsters[param].minLevel > getPlayerLevel(cid) then
return doPlayerSendCancel(cid, 'You do not have required '..taskMonsters[param].minLevel..' level to start this task.')
elseif taskMonsters[param].vip and getCreatureStorage(cid, taskConfig.vipStorage) < 1 then
return doPlayerSendCancel(cid, 'You have to be vip to start this task.')
elseif getCreatureStorage(cid, taskMonsters[param].doneStorage) == 1 then
return doPlayerSendCancel(cid, 'You arleady done task with '..param..'s.')
end
doCreatureSetStorage(cid, taskConfig.taskStorage, param)
doCreatureSetStorage(cid, taskMonsters[param].storage, 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You have started '..param..' task. You have to kill '..taskMonsters[param].kills..' '..param..'s. Good luck!')
else
doPlayerSendCancel(cid, 'Type your param propely or type: "!task".')
end
return true
end
]]>
</talkaction>
<event type="kill" name="task_kill" event="script">
<![CDATA[
domodlib('task_config')
function onKill(cid, target, damage, flags)
if bit.band(flags, 1) == 1 and isMonster(target) then
if isPlayer(cid) then
if getCreatureStorage(cid, taskConfig.taskStorage) == getCreatureName(target):lower() then
local task = taskMonsters[getCreatureName(target):lower()]
if getCreatureStorage(cid, task.storage) + 1 >= task.kills then
doCreatureSetStorage(cid, taskConfig.taskStorage, '')
doCreatureSetStorage(cid, task.storage, task.kills)
doCreatureSetStorage(cid, task.doneStorage, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You have finished task. You have killed enough '..getCreatureName(target):lower()..'s and you got a reward.')
doPlayerAddExperience(cid, task.exp)
local backpack = doPlayerAddItem(cid, 11244, 1)
for k, v in ipairs(task.items) do
doAddContainerItem(backpack, v[1], v[2])
end
else
doCreatureSetStorage(cid, task.storage, math.max(0, getCreatureStorage(cid, task.storage)) + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[TASK] You killed '..getCreatureStorage(cid, task.storage)..'/'..task.kills..' '..getCreatureName(target):lower()..'s.')
end
end
end
end
return true
end
]]>
</event>
<event type="login" name="task_login" event="buffer">
<![CDATA[
registerCreatureEvent(cid, 'task_kill')
]]>
</event>
</mod>