Meu primeiro post aqui no XTibia. :smile_positivo:
Pokemon Online Server 8.54
Estava pensando como fazer o Player logo que criar o char possa escolher a cidade a onde morar, ai lembrei dos tempos que jogava Tibia , que tinha que falar com o Oracle para escolher a vocação e a city.
Resolvi colocar no meu P.O Server e deu certo.
Vamos logo com o script:
Va na pasta data\npc . criei um documento XML (Professora Oak)
<?xml version="1.0" encoding="UTF-8"?> <npc name="Professora Oak" floorchange="0" walkinterval="0" script="data/npc/scripts/oracle.lua"> <health now="150" max="150"/> <look type="251" head="114" body="119" legs="114" feet="114" corpse="2212"/> </npc>
depois va em data\npc\scripts e criei um arquivo lua (oracle)
-- area editavel Oracle = { Cities = { -- {id, 'nome', x, y, z, 'premium/free'} {1, 'cerulean',1060,903, 7, 'free'}, {2,'saffron',1032,1058,7,'free'}, {3,'celadon',862,1035,6,'premium'} }, Vocations = { -- {[id] = 'nome'} [1] = 'treinador', [2] = 'viajante', [3] = 'vagabundo', [4] = 'vendedor' }, frases = { noLevel = 'CRIANÇA! Volte quando você estiver crescida!', hi = 'Você está preparado para encarar o seu destino?', askVoc = 'Que vocação você deseja', confirmVoc = 'TEM CERTEZA? PRESENTE decisão é irreversível.', askCity = 'Você quer viver em:', final = 'Boa sorte em sua VIAGEM!', bye = 'Volte quando você se sente preparado' }, talkStorage = 7897, choos = {}, citiesLiberadas = {} } -- fim da area editavel local function getVocations() local ret = "" for id,it in pairs(Oracle.Vocations) do if((id ~= #Oracle.Vocations - 1) and (id ~= #Oracle.Vocations)) then ret = ret.. it ..", " end if(id == #Oracle.Vocations) then ret = ret.. it .."?" elseif(id == #Oracle.Vocations - 1) then ret = ret.. it .." or " end end return ret end --[[> npc por Evesys/Eventide <------------------------------------- \m/ <[------]> \m/ -------------------------------------------> <----> CONSERVE OS CREDITOS <----> <--> 100% por Eventide e Drifitooh <----><]]-- local focuses = {} local function isFocused(cid) for i, v in pairs(focuses) do if(v == cid) then return true end end return false end local function addFocus(cid) if(not isFocused(cid)) then table.insert(focuses, cid) end end local function removeFocus(cid) for i, v in pairs(focuses) do if(v == cid) then table.remove(focuses, i) break end end end local function lookAtFocus() for i, v in pairs(focuses) do if(isPlayer(v) == TRUE) then doNpcSetCreatureFocus(v) return end end doNpcSetCreatureFocus(0) end function onCreatureAppear(cid) end function onCreatureDisappear(cid) if(isFocused(cid)) then selfSay(Oracle.frases.bye, cid) removeFocus(cid) end end function onCreatureSay(cid, type, msg) talkstate = getPlayerStorageValue(cid, Oracle.talkStorage) if((msg == "hi") and not (isFocused(cid))) then addFocus(cid) if(getPlayerLevel(cid) > 7) then selfSay(Oracle.frases.hi, cid) else selfSay(Oracle.frases.nolevel, cid) end setPlayerStorageValue(cid, Oracle.talkStorage, 1) end talkstate = getPlayerStorageValue(cid, Oracle.talkStorage) if((talkstate == 1) and (msg == "yes") and (isFocused(cid))) then selfSay(" ".. Oracle.frases.askVoc .." ".. getVocations(), cid) setPlayerStorageValue(cid, Oracle.talkStorage, 2) end talkstate = getPlayerStorageValue(cid, Oracle.talkStorage) if((talkstate == 2) and (isFocused(cid))) then for it = 1, #Oracle.Vocations do if(msg == Oracle.Vocations[it]) then selfSay(Oracle.frases.confirmVoc, cid) Oracle.choos.voc = it setPlayerStorageValue(cid, Oracle.talkStorage, 3) break end end end talkstate = getPlayerStorageValue(cid, Oracle.talkStorage) if((talkstate == 3) and (isFocused(cid)) and (msg == "yes")) then for _,it in pairs(Oracle.Cities) do if((isPremium(cid)) and (it[6] == "premium")) then table.insert(Oracle.citiesLiberadas, it) elseif(it[6] == "free") then table.insert(Oracle.citiesLiberadas, it) end end ret = "" for id,it in pairs(Oracle.citiesLiberadas) do if((id ~= #Oracle.citiesLiberadas - 1) and (id ~= #Oracle.citiesLiberadas)) then ret = ret.. it[2] ..", " elseif(id == #Oracle.citiesLiberadas) then ret = ret.. it[2] .."?" elseif(id == #Oracle.citiesLiberadas - 1) then ret = ret.. it[2] .." or " end end selfSay(" ".. Oracle.frases.askCity .. ret .." ", cid) setPlayerStorageValue(cid, Oracle.talkStorage, 4) end talkstate = getPlayerStorageValue(cid, Oracle.talkStorage) if((talkstate == 4) and (isFocused(cid)))then for id,it in pairs(Oracle.citiesLiberadas) do if(msg == it[2]) then Oracle.choos.city = it break end end selfSay("VOCÊ ESCOLHEU SER ".. Oracle.Vocations[Oracle.choos.voc] ..", E MORAR EM ".. Oracle.choos.city[2] ..". Esta correto?", cid) setPlayerStorageValue(cid, Oracle.talkStorage, 5) end talkstate = getPlayerStorageValue(cid, Oracle.talkStorage) if((talkstate == 5) and (isFocused(cid)) and (msg == "yes")) then selfSay(Oracle.frases.final, cid) local goto = {x = Oracle.choos.city[3], y = Oracle.choos.city[4], z = Oracle.choos.city[5]} doTeleportThing(cid, goto) doPlayerSetTown(cid, Oracle.choos.city[1]) doPlayerSetVocation(cid, Oracle.choos.voc) setPlayerStorageValue(cid, Oracle.talkStorage, -1) choos.city = 0 choos.voc = 0 removeFocus(cid) end talkstate = getPlayerStorageValue(cid, Oracle.talkStorage) if((isFocused(cid)) and (msg == "bye") or not(isFocused(cid)) and (talkstate ~= -1) and (msg == bye)) then selfSay(Oracle.frases.bye, cid) setPlayerStorageValue(cid, Oracle.talkStorage, -1) Oracle.choos.city = 0 Oracle.choos.voc = 0 removeFocus(cid) end end function onPlayerCloseChannel(cid) if(isFocused(cid)) then selfSay(frases.bye, cid) setPlayerStorageValue(cid, Oracle.talkStorage, -1) removeFocus(cid) end end function onThink() for i, focus in pairs(focuses) do if(isCreature(focus) == FALSE) then removeFocus(focus) else local distance = getDistanceTo(focus) or -1 if((distance > 4) or (distance == -1)) then selfSay(Oracle.frases.bye, cid) removeFocus(focus) end end end lookAtFocus() end
Para mudar ou add mais city , so mudar essa parte
{ -- {id, 'nome', x, y, z, 'premium/free'}
{1, 'cerulean',1060,903, 7, 'free'},
{2,'saffron',1032,1058,7,'free'},
{3,'celadon',862,1035,6,'premium'}
Ele não vai fazer isso para os players que tiverem menos que level 7!Para mudar isso , so modificar:
if(getPlayerLevel(cid) > 7) then