Ir para conteúdo

Posts Recomendados

Eai galera, pra ajudar o evento que o xtibia esta promovendo de scripting o OMS vou posta um sistema simples pra concorrer.


O Zombie Hunter, é um npc de Task que lhe permite trocar pontos que você acumula matando Monstros por dinheiro e exp mas os pontos só podem ser trocados depois de você ter terminado duas Tasks que o npc vai lhe dar.



o sistema pode ser facilmente modificado pra vários tipos de monstros a edição fica por conta de vocês :D.



para instalção do creature scripts é só adicionar essa linha no creaturescripts.xml,e jogar o script pra dentro da pasta scripts.



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

e registrar o evento Hunter no onLogin.lua




Creaturescripts:



local zombies = { -- task --
["Zombie [1]"] = {storagetask = 3290, storagecount = 4290, count = 10, points = 80},
["Zombie [2]"] = {storagetask = 3289, storagecount = 4291, count = 20, points = 130},
["Zombie [3]"] = {storagetask = 3288, storagecount = 4292, count = 30, points = 200},
["Zombie [4]"] = {storagetask = 3287, storagecount = 4293, count = 40, points = 250},
--No-task--
["Rat"] = {storagetask = nil, storagecount = nil, count = nil, points = 15} ,
["Wolf"] = {storagetask = nil, storagecount = nil, count = nil, points = 35},
}

function onKill(cid, target, lastHit)
local name = getCreatureName(target)
if zombies[name] then
if zombies[name].storagetask ~= nil and getPlayerStorageValue(cid, zombies[name].storagetask) > 5 then
if getPlayerStorageValue(cid, zombies[name].storagetask) < 20 and getPlayerStorageValue(cid, zombies[name].storagecount) <= zombies[name].count - 1 then
if getPlayerStorageValue(cid, zombies[name].storagecount) < 0 then
setPlayerStorageValue(cid, zombies[name].storagecount, getPlayerStorageValue(cid, zombies[name].storagecount) + 2)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You Killed ["..getPlayerStorageValue(cid, zombies[name].storagecount).."/20] Zombies [2].")
else
setPlayerStorageValue(cid, zombies[name].storagecount, getPlayerStorageValue(cid, zombies[name].storagecount) + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You Killed ["..getPlayerStorageValue(cid, zombies[name].storagecount).."/20] Zombies [2].")
end
end
end
if getPlayerStorageValue(cid, 4593) < 0 then
setPlayerStorageValue(cid, 4593, getPlayerStorageValue(cid, 4593) + zombies[name].points + 1)
else
setPlayerStorageValue(cid, 4593, getPlayerStorageValue(cid, 4593) + zombies[name].points)
end
doSendAnimatedText(getCreaturePosition(target), "+"..zombies[name].points.." points", math.random(255))
end
return true
end

agora você precisa adicionar o npc ao servidor para isso crie um .xml na pasta npc e nele cole isso:



<?xml version="1.0" encoding="UTF-8"?>
<npc name="Paul" script="task.lua" walkinterval="5000" floorchange="0">
<health now="100" max="100"/>
<look type="76" head="0" body="0" legs="0" feet="0" addons="0"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|, I was looking for some {work} to you, or you can change your {points}.
" />
</parameters>
</npc>

e na pasta npc/scripts crie um arquivo lua e dentro dele cole isso:



dofile("config.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 getPlayerID(cid) -- function by Ramza(Ricardo Ianelli)
local Query = db.getResult("SELECT `id` FROM `players` WHERE `players`.`name` = '"..getCreatureName(cid).."';")
local player_id = Query:getDataInt("id")
return player_id
end
function creatureSayCallback(cid, type, msg)
local playerid = getPlayerID(cid)
if(not npcHandler:isFocused(cid)) then
return false
end
if msg == 'work' then
selfSay('Nowadays, the world is a mess, then I Need your help to "kill" a part of the mess. {Ok}, ', cid)
talkstatus = 2
elseif msg == 'points' then
selfSay(' Do you wanna exchange your points, or {check}/{exchange} them?', cid)
talkstatus = 41
elseif msg == 'points' and getPlayerStorageValue(cid, 3290) < 20 and getPlayerStorageValue(cid, 3289) < 20 then
selfSay('You have to complete all the tasks', cid)
talkstatus = 0
elseif talkstatus == 41 and msg == "exchange" then
if getPlayerStorageValue(cid, 3290) >= 20 and getPlayerStorageValue(cid, 3289) >= 20 then
talkstatus = 29
selfSay('How much points do you wanna exchange?',cid)
else
selfSay('You have to complete 2 tasks to exchange points..',cid)
talkstatus = 0
end
elseif talkstatus == 41 and msg == "check" then
if getPlayerStorageValue(cid, 4593) < 0 then
selfSay('You have '..getPlayerStorageValue(cid, 4593) + 1 ..' points.',cid)
elseif getPlayerStorageValue(cid, 4593) >= 0 then
selfSay('You have '..getPlayerStorageValue(cid, 4593)..' points.',cid)
end
talkstate = 0
elseif talkstatus == 29 then
if isNumber(msg) then
if getPlayerStorageValue(cid, 4593) >= tonumber(msg) then
dinheiro = math.floor(tonumber(msg)*2)
exp = math.floor(tonumber(msg)*3)
menos = msg
selfSay('It will give you of Money: '..dinheiro.." and of Experience: "..exp..". Are you right?", cid)
talkstatus = 30
end
else
selfSay('It is an invalid number.',cid)
end
elseif talkstatus == 30 then
if msg == 'yes' then
talkstatus = 29
doPlayerAddMoney(cid, dinheiro)
doPlayerAddExp(cid, exp)
setPlayerStorageValue(cid, 4593, getPlayerStorageValue(cid, 4593)-menos)
doSendMagicEffect(getCreaturePosition(cid), 98)
selfSay('thanks',cid)
talkstatus = 0
elseif msg == 'no' then
talkstatus = 0
end
elseif talkstatus == 2 then
if msg == 'ok' then
talkstatus = 3
selfSay('Nice! You have four options for work, {Easy}; {Medium}; {Hard}; {Expert}.',cid)
elseif msg == 'no' then
talkstatus = 0
end
elseif talkstatus == 3 and msg == "easy" then
if getPlayerStorageValue(cid, 3290) < 5 and getPlayerStorageValue(cid, 3290) < 20 then
talkstatus = 4
selfSay('Alright! In Easy Mode, you have to kill 10 Zombies Lv 1 or higher, do you Agree?', cid)
elseif getPlayerStorageValue(cid, 3290) > 5 and getPlayerStorageValue(cid, 3290) < 20 then
talkstatus = 14
selfSay('Did you finish the work?', cid)
elseif getPlayerStorageValue(cid, 3290) >= 20 then
selfSay('You have, finished the easy mode', cid)
talkstate = 0
end
elseif talkstatus == 4 then
if msg == 'yes' then
setPlayerStorageValue(cid, 3290, 10)
selfSay('Alright! When you finish the work, come back here, and I will give you a reward.', cid)
talkstate = 0
elseif msg == 'no' then
talkstatus = 2
end
elseif talkstatus == 3 and msg == "medium" then
if getPlayerStorageValue(cid, 3289) < 5 and getPlayerStorageValue(cid, 3289) < 20 then
talkstatus = 5
selfSay('Alright! In Medium Mode, you have to kill 20 Zombies, Lv 2 or higher, do you Agree?', cid)
elseif getPlayerStorageValue(cid, 3289) > 5 and getPlayerStorageValue(cid, 3289) < 20 then
talkstatus = 15
selfSay('Did you finish the work?', cid)
elseif getPlayerStorageValue(cid, 3289) >= 20 then
selfSay('You have, finished the medium mode', cid)
talkstate = 0
end
elseif talkstatus == 5 then
if msg == 'yes' then
setPlayerStorageValue(cid, 3289, 10)
selfSay('Alright! When you finish the work, come back here, and I will give you a reward.', cid)
talkstatus = 0
elseif msg == 'no' then
talkstatus = 2
end
elseif talkstatus == 3 and msg == "hard" then
if getPlayerStorageValue(cid, 3288) < 5 and getPlayerStorageValue(cid, 3288) < 20 then
talkstatus = 6
selfSay('Alright! In Hard Mode, you have to kill 30 Zombies, Lv 3 or higher, do you Agree?', cid)
elseif getPlayerStorageValue(cid, 3288) > 5 and getPlayerStorageValue(cid, 3288) < 20 then
talkstatus = 16
selfSay('Did you finish the work?', cid)
elseif getPlayerStorageValue(cid, 3288) >= 20 then
selfSay('You have, finished the hard mode', cid)
talkstate = 0
end
elseif talkstatus == 6 then
if msg == 'yes' then
setPlayerStorageValue(cid, 3288, 10)
selfSay('Alright! When you finish the work, come back here, and I will give you a reward.', cid)
talkstatus = 0
elseif msg == 'no' then
talkstatus = 2
end
elseif talkstatus == 3 and msg == "expert" then
if getPlayerStorageValue(cid, 3287) < 5 and getPlayerStorageValue(cid, 3287) < 20 then
talkstatus = 7
selfSay('Alright! In Expert Mode, you have to kill 40 Zombies, lv 4 or higher, do you Agree?', cid)
elseif getPlayerStorageValue(cid, 3287) > 5 and getPlayerStorageValue(cid, 3287) < 20 then
talkstatus = 17
selfSay('Did you finish the work?', cid)
elseif getPlayerStorageValue(cid, 3288) >= 20 then
selfSay('You have, finished the expert mode', cid)
talkstate = 0
end
elseif talkstatus == 7 then
if msg == 'yes' then
setPlayerStorageValue(cid, 3287, 10)
selfSay('Alright! When you finish the work, come back here, and I will give you a reward.', cid)
talkstatus = 0
elseif msg == 'no' then
talkstatus = 2
end
elseif talkstatus == 14 then
if msg == 'yes' and getPlayerStorageValue(cid, 4290) >= 10 and getPlayerStorageValue(cid, 3290) < 20 then
setPlayerStorageValue(cid, 3290, 20)
doPlayerAddMoney(cid, 10*100)
doPlayerAddExp(cid, 500)
selfSay('Nice Work! Thanks for the help, take this reward for helping us. (Experience and Money)', cid)
elseif msg == "yes" and getPlayerStorageValue(cid, 4290) < 10 then
selfSay('Alright! When you finish the work, come back here, and I will give you a reward.', cid)
talkstatus = 0
elseif msg == 'no' then
selfSay('Alright! When you finish the work, come back here, and I will give you a reward.', cid)
talkstatus = 0
end
elseif talkstatus == 15 then
if msg == 'yes' and getPlayerStorageValue(cid, 4291) >= 20 and getPlayerStorageValue(cid, 3289) < 20 then
setPlayerStorageValue(cid, 3289, 20)
doPlayerAddMoney(cid, 20*100)
doPlayerAddExp(cid, 1000)
selfSay('Nice Work! Thanks for the help, take this reward for helping us. (Experience and Money)', cid)
elseif msg == "yes" and getPlayerStorageValue(cid, 4289) < 20 then
selfSay('Alright! When you finish the work, come back here, and I will give you a reward.', cid)
talkstatus = 0
elseif msg == 'no' then
selfSay('Alright! When you finish the work, come back here, and I will give you a reward.', cid)
talkstatus = 0
end
elseif talkstatus == 16 then
if msg == 'yes' and getPlayerStorageValue(cid, 4292) >= 30 and getPlayerStorageValue(cid, 3288) < 20 then
setPlayerStorageValue(cid, 3288, 20)
doPlayerAddMoney(cid, 30*100)
doPlayerAddExp(cid, 1800)
selfSay('Nice Work! Thanks for the help, take this reward for helping us. (Experience and Money)', cid)
elseif msg == "yes" and getPlayerStorageValue(cid, 4288) < 30 then
selfSay('Alright! When you finish the work, come back here, and I will give you a reward.', cid)
talkstatus = 0
elseif msg == 'no' then
selfSay('Alright! When you finish the work, come back here, and I will give you a reward.', cid)
talkstatus = 0
end
elseif talkstatus == 17 then
if msg == 'yes' and getPlayerStorageValue(cid, 4290) >= 40 and getPlayerStorageValue(cid, 3287) < 20 then
setPlayerStorageValue(cid, 3287, 20)
doPlayerAddMoney(cid, 40*100)
doPlayerAddExp(cid, 2400)
selfSay('Nice Work! Thanks for the help, take this reward for helping us. (Experience and Money)', cid)
elseif msg == "yes" and getPlayerStorageValue(cid, 4287) < 40 then
selfSay('Alright! When you finish the work, come back here, and I will give you a reward.', cid)
talkstatus = 0
elseif msg == 'no' then
selfSay('Alright! When you finish the work, come back here, and I will give you a reward.', cid)
talkstatus = 0
end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Pronto agora é só colocar o npc pelo mapeditor ou o summonar pra testar. o sistema contem 4 tasks mas só precisa ser feito 2 tasks para poder retirar os seus pontos, os monstros configurados sempre vão dar os pontos então você sempre vai poder trocar pontos mesmo depois de te terminado todas as tasks.



Obs.: o sistema esta configurado pra zombies com digamos level pra utilizar com um servidor normal você tem que editar os monstros no creaturescripts ou criar vários zombies com [lv] no nome exemplo: zombie [1], zombie [2]....




Att+.


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

×
×
  • Criar Novo...