Postado Janeiro 31, 2013 12 anos local places = { ["papai noel"] = {pos={x=1, y=2, z=7}, price = 1}, ["teletubies"] = {pos={x=1, y=2, z=7}, price = 1}, ["goku"] = {pos={x=1018, y=1032, z=7}, price = 1}, } [nome] = {pos = {x=1234, y=132456, z=67}, price = 15346},
Postado Janeiro 31, 2013 12 anos Autor Extremamente funcional, obrigado, reputado (1º) | [8.60] - Galaxy Server - Download (2º) | [8.60] - Glorious Server - Download (3º) | [8.60] - Epic Server - Download
Postado Fevereiro 2, 2013 12 anos \data\npc\Marujo.xml <?xml version="1.0" encoding="UTF-8"?> <npc name="Marujo" script="marujo.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="151" head="17" body="54" legs="114" feet="0" addons="3"/> <parameters> </parameters> </npc> \data\npc\scripts\marujo.lua 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)) then doNpcSetCreatureFocus(v) return end end doNpcSetCreatureFocus(0) end local function getPlayerMoney(cid) return ((getPlayerItemCount(cid, 2160) * 10000) + (getPlayerItemCount(cid, 2152) * 100) + getPlayerItemCount(cid, 2148)) end function onCreatureDisappear(cid) if(isFocused(cid)) then selfSay("Bye!") removeFocus(cid) if(isPlayer(cid)) then --Be sure he's online closeShopWindow(cid) end end end function onCreatureAppear(cid) end local places = { ["papai noel"] = {pos={x=1, y=2, z=7}, price = 1}, ["teletubies"] = {pos={x=1, y=2, z=7}, price = 1}, ["goku"] = {pos={x=1018, y=1032, z=7}, price = 1}, } function onCreatureSay(cid, type, msg) if((msg == "hi" or msg == "hello") and not (isFocused(cid))) then selfSay("Welcome, ".. getCreatureName(cid) ..".", cid) addFocus(cid) elseif((isFocused(cid)) and (msg == "travel" or msg == "sail")) then local str = "" for cityName, _ in pairs(places) do str = str.."{"..cityName.."} " end selfSay("Para onde voce quer viajar? "..str, cid) elseif((isFocused(cid)) and places[msg:lower()]) then if not(doPlayerRemoveMoney(cid, places[msg:lower()].price)) then return selfSay("Voce nao tem dinheiro", cid) end selfSay("Bye", cid) doTeleportThing(cid, places[msg:lower()].pos) removeFocus(cid) elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then selfSay("Goodbye!", cid, true) removeFocus(cid) end end function onPlayerCloseChannel(cid) if(isFocused(cid)) then selfSay("Bye!") closeShopWindow(cid) removeFocus(cid) end end function onThink() for i, focus in pairs(focuses) do if(not isCreature(focus)) then removeFocus(focus) else local distance = getDistanceTo(focus) or -1 if((distance > 4) or (distance == -1)) then selfSay("Hmph!") closeShopWindow(focus) removeFocus(focus) end end end lookAtFocus() end +rep, mas só tem um erro, quando você fala hi, travel , ele responde os nomes das city tudo junto exemplo... Você quer viajar para papai noel teletubies goku tem como você colocar para ter virgulas e ponto de interrogação no final em azul claro como mensagem comum exemplo... Você quer viajar para papai noel, temetumbies, goku? E se puder só pra premmy viajar eu ficaria agradecido. edit: cheguei no limite de +reps, amanah eu adiciono. Editado Fevereiro 2, 2013 12 anos por tiagoduuarte (veja o histórico de edições)
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.