Ir para conteúdo

AutoTask System - SmiX


SmiX

Posts Recomendados

Olá, hoje venho postar um sistema que bolei ontem e terminei hoje – ele se chama: Auto Task System.

O que faz? O player pode escolher qualquer monstro, definido no script, para fazer a task. No final da mesma ele ganha Experiência, de acordo com o nível que está.

 

Exemplo: Se o player escolher a task de rat, no nível 1, ele vai precisar matar 60, no nível 2, ele mata 120 e assim prossegue.

 

 

COMANDOS:

!autoTask – aparece a janela com todos os comandos
!autoTask  info – mostra todos os monstros na autoTask
!autoTask i – mostra em qual autoTask você está registrado
!autoTask sair/leave – sai da autoTask atual

Vamos aos códigos: Primeiro vá em (data/talkactions/scripts) e crie um arquivo chamado “autoTask.lua” e cole isto dentro:

function onSay(cid, words, param)

if (param == '') then
local str = ""
str = str .. "Você pode usar os seguintes comandos: \n\ninfo - todos os monstros da autoTask\ni - em qual autoTask você está\nsair/leave - sai da autoTask atual"
doShowTextDialog(cid, 7416, str)
return true
end
if autoTaskConfig.monsters[param] then
if getPlayerStorageValue(cid, autoTaskConfig.systemStors[1]) ~= -1 then
doPlayerSendTextMessage(cid, 27, "Você já está em uma autoTask. Digite '!autoTask i' e descubra qual.")
return true
end
mid = autoTaskConfig.monsters[param]
setPlayerStorageValue(cid, autoTaskConfig.systemStors[1], param)
setPlayerStorageValue(cid, autoTaskConfig.systemStors[2], 0)
if getPlayerStorageValue(cid, autoTaskConfig.monsters[param].storNivel) == -1 then
setPlayerStorageValue(cid, autoTaskConfig.monsters[param].storNivel, 1)
end
getCount = getPlayerStorageValue(cid, autoTaskConfig.monsters[param].storNivel)
doPlayerSendTextMessage(cid, 27, "Você precisa, agora, matar " ..(mid.minKills * getCount).. " " .. param .. ((mid.minKills * getCount) < 2 and "" or "s") .. ".")
return true
elseif param == "info" then
local str = "Monstros dispóniveis na autoTask:\n"
for id, id2 in pairs(autoTaskConfig.monsters) do
str = str .. id .. "\n"
end
doShowTextDialog(cid, 7416, str)
return true
elseif param == "i" then
name = getPlayerStorageValue(cid, autoTaskConfig.systemStors[1])
if name == -1 then return true end
doPlayerSendTextMessage(cid, 27, "Você já está na autoTask de:\n["..name.."] - Mortos: "..getPlayerStorageValue(cid, autoTaskConfig.systemStors[2])..", Restantes: "..(autoTaskConfig.monsters[name].minKills*getPlayerStorageValue(cid, autoTaskConfig.monsters[name].storNivel)) - getPlayerStorageValue(cid, autoTaskConfig.systemStors[2])..".")
return true
elseif param == "sair" or param == "leave" then
setPlayerStorageValue(cid, autoTaskConfig.systemStors[1], -1)
setPlayerStorageValue(cid, autoTaskConfig.systemStors[2], -1)
doPlayerSendTextMessage(cid, 27, "Você saiu da sua task atual.")
return true
else
return true
end
return true
end

 

Cole está tag em (data/talkactions/talkactions.XML):

<talkaction words="!autoTask" event="script" value="autoTask.lua"/>

Agora em (data/creaturescripts/scripts) crie um arquivo chamado “autoTask.lua” e cole isto dentro:

function onKill(cid, target)

if getPlayerStorageValue(cid, autoTaskConfig.systemStors[1]) ~= -1 then
--if isMonster(target) then
if getCreatureName(target) == getPlayerStorageValue(cid, autoTaskConfig.systemStors[1]) then
countTask = getPlayerStorageValue(cid, autoTaskConfig.systemStors[2])
setPlayerStorageValue(cid, autoTaskConfig.systemStors[2], countTask +1)
name = getPlayerStorageValue(cid, autoTaskConfig.systemStors[1])
getNivel = getPlayerStorageValue(cid, autoTaskConfig.monsters[name].storNivel)
countNow = (autoTaskConfig.monsters[name].minKills * getNivel) - getPlayerStorageValue(cid, autoTaskConfig.systemStors[2])
if countNow < 1 then
doPlayerAddExp(cid, autoTaskConfig.monsters[name].exp * getNivel)
doSendAnimatedText(getThingPos(cid), autoTaskConfig.monsters[name].exp * getNivel, 215)
doPlayerSendTextMessage(cid, 27, "Você completou a sua task.")
setPlayerStorageValue(cid, autoTaskConfig.monsters[name].storNivel, getPlayerStorageValue(cid, autoTaskConfig.monsters[name].storNivel) +1)
doSendMagicEffect(getThingPos(cid), autoTaskConfig.effectTaskCompleted)
for i = 1, 2 do
setPlayerStorageValue(cid, autoTaskConfig.systemStors, -1)
end
return true
end
doPlayerSendTextMessage(cid, 27, "Faltam apenas " .. countNow .. " " .. name .. (countNow < 2 and "" or "s")..".")
end
--end
end
return true
end

 

Cole está tag em (data/creaturescript/creaturescripts.XML):

<event type="kill" name="autoTask" script=" autoTask.lua "/> 

Agora em (data/creaturescripts/scripts/login.lua) cole isso, antes do ultimo “return true”:

registerCreatureEvent(cid, " autoTask ")

Agora em (data/lib) crie um arquivo chamado “autoTask.lua” e cole isto dentro:

autoTaskConfig = {

monsters = { -- Monster que estão na lista de autoTask
["Abra"] = {minKills = 10, exp = 500, storNivel = 3000},
["Rattata"] = {minKills = 50, exp = 200, storNivel = 3001},
["Rat"] = {minKills = 60, exp = 300, storNivel = 3002},
["Cave Rat"] = {minKills = 10, exp = 500, storNivel = 3003},
--[NomeMonster] = minimo de monstros que o player vai ter que matar, experiência que ele ganhara quando matar todos
},
systemStors = {2500, 2501},
effectTaskCompleted = 28, -- Efeito que soltara quando o player completar a task
}

 

OBS: Todas as suas configurações são feitas na LIB. Para adicionar mais monstros basta copiar uma linha e mudar os valores.

 

 

Espero que tenham gostado. Até mais.

Editado por SmiX
Link para o comentário
Compartilhar em outros sites

Cara no meu server ta dando esse erro aqui:

 

 

[06/11/2013 15:13:14] [Error - LuaScriptInterface::loadFile] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'

[06/11/2013 15:13:14] [Warning - LuaScriptInterface::initState] Cannot load data/lib/
[06/11/2013 15:13:14] [Error - LuaScriptInterface::loadFile] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'
[06/11/2013 15:13:14] [Warning - LuaScriptInterface::initState] Cannot load data/lib/
[06/11/2013 15:13:14] [Error - LuaScriptInterface::loadFile] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'
[06/11/2013 15:13:14] [Warning - LuaScriptInterface::initState] Cannot load data/lib/
[06/11/2013 15:13:14] [Error - Action Interface]
[06/11/2013 15:13:14] data/actions/scripts/boost.lua
[06/11/2013 15:13:14] Description:
[06/11/2013 15:13:14] data/actions/scripts/boost.lua:351: table index is nil
[06/11/2013 15:13:14] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/boost.lua)
[06/11/2013 15:13:14] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'
[06/11/2013 15:13:14] [Error - Action Interface]
[06/11/2013 15:13:14] data/actions/scripts/evolution.lua
[06/11/2013 15:13:14] Description:
[06/11/2013 15:13:14] data/actions/scripts/evolution.lua:4: table index is nil
[06/11/2013 15:13:14] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/evolution.lua)
[06/11/2013 15:13:14] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'
[06/11/2013 15:13:14] [Error - LuaScriptInterface::loadFile] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'
[06/11/2013 15:13:14] [Warning - LuaScriptInterface::initState] Cannot load data/lib/
[06/11/2013 15:13:14] [Warning - Event::loadScript] Event onSay not found (data/talkactions/scripts/autoTask.lua)
[06/11/2013 15:13:14] [Error - LuaScriptInterface::loadFile] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'
[06/11/2013 15:13:14] [Warning - LuaScriptInterface::initState] Cannot load data/lib/
[06/11/2013 15:13:14] [Error - LuaScriptInterface::loadFile] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'
[06/11/2013 15:13:14] [Warning - LuaScriptInterface::initState] Cannot load data/lib/
[06/11/2013 15:13:15] [Error - LuaScriptInterface::loadFile] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'
[06/11/2013 15:13:15] [Warning - LuaScriptInterface::initState] Cannot load data/lib/

Link para o comentário
Compartilhar em outros sites

 

Cara no meu server ta dando esse erro aqui:

 

 

[06/11/2013 15:13:14] [Error - LuaScriptInterface::loadFile] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'

[06/11/2013 15:13:14] [Warning - LuaScriptInterface::initState] Cannot load data/lib/
[06/11/2013 15:13:14] [Error - LuaScriptInterface::loadFile] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'
[06/11/2013 15:13:14] [Warning - LuaScriptInterface::initState] Cannot load data/lib/
[06/11/2013 15:13:14] [Error - LuaScriptInterface::loadFile] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'
[06/11/2013 15:13:14] [Warning - LuaScriptInterface::initState] Cannot load data/lib/
[06/11/2013 15:13:14] [Error - Action Interface]
[06/11/2013 15:13:14] data/actions/scripts/boost.lua
[06/11/2013 15:13:14] Description:
[06/11/2013 15:13:14] data/actions/scripts/boost.lua:351: table index is nil
[06/11/2013 15:13:14] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/boost.lua)
[06/11/2013 15:13:14] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'
[06/11/2013 15:13:14] [Error - Action Interface]
[06/11/2013 15:13:14] data/actions/scripts/evolution.lua
[06/11/2013 15:13:14] Description:
[06/11/2013 15:13:14] data/actions/scripts/evolution.lua:4: table index is nil
[06/11/2013 15:13:14] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/evolution.lua)
[06/11/2013 15:13:14] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'
[06/11/2013 15:13:14] [Error - LuaScriptInterface::loadFile] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'
[06/11/2013 15:13:14] [Warning - LuaScriptInterface::initState] Cannot load data/lib/
[06/11/2013 15:13:14] [Warning - Event::loadScript] Event onSay not found (data/talkactions/scripts/autoTask.lua)
[06/11/2013 15:13:14] [Error - LuaScriptInterface::loadFile] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'
[06/11/2013 15:13:14] [Warning - LuaScriptInterface::initState] Cannot load data/lib/
[06/11/2013 15:13:14] [Error - LuaScriptInterface::loadFile] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'
[06/11/2013 15:13:14] [Warning - LuaScriptInterface::initState] Cannot load data/lib/
[06/11/2013 15:13:15] [Error - LuaScriptInterface::loadFile] data/lib/autoTask.lua:10: '}' expected (to close '{' at line 1) near 'effectTaskCompleted'
[06/11/2013 15:13:15] [Warning - LuaScriptInterface::initState] Cannot load data/lib/

 

Você alterou o script adicionando mais monstros ou itens?

Pois este erro é por falta de alguma "}" (colchete) que ficou faltando para finalizar na configuração.

 

Se sim, poste seu script aí para que possamos ver.

 

Abraços e boa sorte.

Link para o comentário
Compartilhar em outros sites

FlamesAdmin

Agora vc fez algo errado, pq o script nao achou a função onSay no talkactions, ou seja, vc deve ter trocado os script. Faça de novo do começo.

Vishi, eu tinha eskecido de adicionar a nova talk autoTask.lua q vc pois ai. Vlw man, funfou aki direitin.

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...