Postado Abril 25, 2015 10 anos Poderia dar mais detalhes sobre o segundo pedido? Por exemplo, como o jogador irá obter o cartão e o código do NPC que garante acesso a Saffari Zone. E, se possível, seu código de look também (data/creaturescripts/scripts, look.lua). não respondo pms solicitando suporte em programação/scripting
Postado Abril 25, 2015 10 anos Autor Certo. O Saffari card poderá ser obtido em um npc que vende itens em troca de moedas (As moedas que os players ganharão caso doarem) Script do look Mostrar conteúdo oculto function onLook(cid, thing, position, lookDistance) local str = "" if not isCreature(thing.uid) then local iname = getItemInfo(thing.itemid) if isPokeball(thing.itemid) then local lock = getItemAttribute(thing.uid, "lock") --alterado v2.8 local pokename = getItemAttribute(thing.uid, "poke") local item = getItemInfo(thing.itemid) str = "You see "..item.article.." "..item.name.."." --alterado v2.6 if getItemAttribute(thing.uid, "unique") then --alterado v2.8 str = str.." It's an unique item." --alterado v2.6 end str = str.."\nIt contains "..getArticle(pokename).." "..pokename.." [level "..getItemAttribute(thing.uid, "level").."].\n" --alterado v2.6 if lock and lock > 0 then str = str.."It will unlock in ".. os.date("%d/%m/%y %X", lock)..".\n" --alterado v2.8 end local boost = getItemAttribute(thing.uid, "boost") or 0 local boostshow = "" if boost > 0 then str = str.."Boost level: +"..boost..".\n" end if getItemAttribute(thing.uid, "nick") then str = str.."It's nickname is: "..getItemAttribute(thing.uid, "nick")..".\n" end if getItemAttribute(thing.uid, "gender") == SEX_MALE then str = str.."It is male." elseif getItemAttribute(thing.uid, "gender") == SEX_FEMALE then str = str.."It is female." else str = str.."It is genderless." end str = str.."\n--- Status ---" str = str.."\nOffense: "..math.floor(getItemAttribute(thing.uid, "offense")).." Defense: "..math.floor(getItemAttribute(thing.uid, "defense")).."\n" str = str.."Agility: "..math.floor(getItemAttribute(thing.uid, "speed")).." Sp. Attack: "..math.floor(getItemAttribute(thing.uid, "specialattack")).."\n" str = str.."Vitality: "..math.floor(getItemAttribute(thing.uid, "vitality")).."" doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return false elseif string.find(iname.name, "fainted") or string.find(iname.name, "defeated") then str = "You see a "..string.lower(iname.name).." ["..getItemAttribute(thing.uid, "level").."]. " --alterado v2.8 \/ if isContainer(thing.uid) then str = str.."(Vol: "..getContainerCap(thing.uid)..")" end str = str.."\n" if getItemAttribute(thing.uid, "gender") == SEX_MALE then str = str.."It is male." elseif getItemAttribute(thing.uid, "gender") == SEX_FEMALE then str = str.."It is female." else str = str.."It is genderless." end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return false elseif isContainer(thing.uid) then --containers local info = getItemInfo(thing.itemid) --alterado v2.7 if info.name == "dead human" and getItemAttribute(thing.uid, "pName") then str = "You see a dead human (Vol:"..getContainerCap(thing.uid).."). " str = str.."You recognize ".. getItemAttribute(thing.uid, "pName")..". ".. getItemAttribute(thing.uid, "article").." was killed by a " str = str.."".. getItemAttribute(thing.uid, "attacker").."." else str = "You see "..info.article.." "..info.name..". (Vol:"..getContainerCap(thing.uid)..")." end if getPlayerGroupId(cid) >= 4 and getPlayerGroupId(cid) <= 6 then str = str.."\nItemID: ["..thing.itemid.."]" --alterado v2.8 local pos = getThingPos(thing.uid) str = str.."\nPosition: [X: "..pos.x.."][Y: "..pos.y.."][Z: "..pos.z.."]" --alterado v2.8 end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return false elseif getItemAttribute(thing.uid, "unique") then --alterado v2.8 \/ local info = getItemInfo(thing.itemid) local p = getThingPos(thing.uid) local str = "You see " if thing.type > 0 then str = str..thing.type.." "..info.plural.."." else str = str..info.article.." "..info.name.."." end str = str.." It's an unique item.\n" str = str..info.description.."\nItemID: ["..thing.itemid.."]" str = str.."\nPosition: ["..p.x.."]["..p.y.."]["..p.z.."]" sendMsgToPlayer(cid, MESSAGE_INFO_DESCR, str) return false else return true end end local NPCBattle = { ["Brock"] = {artig = "He is", cidbat = "Pewter"}, ["Misty"] = {artig = "She is", cidbat = "Cerulean"}, ["Blaine"] = {artig = "He is", cidbat = "Cinnabar"}, ["Sabrina"] = {artig = "She is", cidbat = "Saffron"}, --alterado v2.7 ["Kira"] = {artig = "She is", cidbat = "Viridian"}, ["Koga"] = {artig = "He is", cidbat = "Fushcia"}, ["Erika"] = {artig = "She is", cidbat = "Celadon"}, ["Surge"] = {artig = "He is", cidbat = "Vermilion"}, } local npcname = getCreatureName(thing.uid) if ehNPC(thing.uid) and NPCBattle[npcname] then --npcs duel str = "You see "..npcname..". "..NPCBattle[npcname].artig.." leader of the gym from "..NPCBattle[npcname].cidbat.."." --alterado v2.7 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return false elseif ehNPC(thing.uid) and getPlayerStorageValue(thing.uid, 697548) ~= -1 then --npcs de TV local str = getPlayerStorageValue(thing.uid, 697548) --alterado v2.7 local pos = getThingPos(thing.uid) str = youAre[getPlayerGroupId(cid)] and str.."\nPosition: [X: "..pos.x.."][Y: "..pos.y.."][Z: "..pos.z.."]." or str doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return false end if not isPlayer(thing.uid) and not isMonster(thing.uid) then str = "You see "..getCreatureName(thing.uid).."." doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return false end if isPlayer(thing.uid) then --player doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, getPlayerDesc(cid, thing.uid, false)) --alterado v2.7 return false end if getCreatureName(thing.uid) == "Evolution" then return false end if not isSummon(thing.uid) then local str = "You see a wild "..string.lower(getCreatureName(thing.uid)).." [level "..getPokemonLevel(thing.uid).."].\n" if getPokemonGender(thing.uid) == SEX_MALE then str = str.."It is male." elseif getPokemonGender(thing.uid) == SEX_FEMALE then str = str.."It is female." else str = str.."It is genderless." end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return false elseif isSummon(thing.uid) and not isPlayer(thing.uid) then local boostlevel = getItemAttribute(getPlayerSlotItem(getCreatureMaster(thing.uid), 8).uid, "boost") or 0 local boostshow = " + "..boostlevel.."]" if showBoostSeparated then boostshow = "] [+"..boostlevel.."]" end local levelinfo = "["..getPokemonLevel(thing.uid)..""..boostshow.."" if getCreatureMaster(thing.uid) == cid then local myball = getPlayerSlotItem(cid, 8).uid local nexp = getItemAttribute(myball, "nextlevelexp") local string = "You see your "..string.lower(getCreatureName(thing.uid)).." "..levelinfo.."." string = string.."\nHit points: "..getCreatureHealth(thing.uid).."/"..getCreatureMaxHealth(thing.uid).."." string = string.."\n"..getPokemonHappinessDescription(thing.uid) if getItemAttribute(myball, "level") <= 99 then string = string.."\nExperience needed to level up: "..nexp.."." end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string) else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You see a "..string.lower(getCreatureName(thing.uid)).." "..levelinfo..".\nIt belongs to "..getCreatureName(getCreatureMaster(thing.uid))..".") end return false end return true end Script do npc que da acesso a saffari caso o player tenha o card. Mostrar conteúdo oculto local tab = { pos = {x = 768, y = 1007, z = 8}, -- posição x, y, z do local a teleportar o player item = {26771, 1}, -- {itemID, count} price = 0 -- quantidade em crystal coins } 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 creatureSayCallback(cid, type, msg) if (not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid if (msgcontains(msg, 'teleport')) then talkState[talkUser] = 1 selfSay('Voce esta certo disso?', cid) selfSay('Lembre-se..voce precisa de '..tab.item[2]..' '..getItemNameById(tab.item[1])..' para prosseguir.', cid) elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if (getPlayerItemCount(cid, tab.item[1]) >= tab.item[2] and doPlayerRemoveMoney(cid, tab.price * 10000)) then doTeleportThing(cid, tab.pos) doPlayerRemoveMoney(cid, tab.price * 10000) doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT) selfSay('Boa sorte no Saffari Zone.', cid) else talkState[talkUser] = 0 selfSay('Voce nao tem o Saffari Card, entao nao poderei move-lo para la.', cid) end elseif (msgcontains(msg, 'no') and talkState[talkUser] == 1) then talkState[talkUser] = 0 selfSay('Okay, Talvez em outra hora.', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Abril 30, 2015 10 anos Desculpe a demora. Como lhe disse por PM, estava em semana de provas e não tive como scriptear. Look: Mostrar conteúdo oculto local cardId = xxx --ID do cartão. function onLook(cid, thing, position, lookDistance) local str = "" if not isCreature(thing.uid) then if thing.itemid == cardId then str = "You see "..getItemInfo(thing.itemid).article.." "..getItemInfo(thing.itemid).name.."." if getItemInfo(thing.itemid).description then str = str.."\n"..getItemInfo(thing.itemid).description end local vality = getItemAttribute(thing.uid, "vality") if vality then if vality < os.time() then str = str.."\nThis card isn't valid anymore." else str = str.."\nValid until "..os.date("%d/%m/%y %X", vality) end end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return false end local iname = getItemInfo(thing.itemid) if isPokeball(thing.itemid) then local lock = getItemAttribute(thing.uid, "lock") --alterado v2.8 local pokename = getItemAttribute(thing.uid, "poke") local item = getItemInfo(thing.itemid) str = "You see "..item.article.." "..item.name.."." --alterado v2.6 if getItemAttribute(thing.uid, "unique") then --alterado v2.8 str = str.." It's an unique item." --alterado v2.6 end str = str.."\nIt contains "..getArticle(pokename).." "..pokename.." [level "..getItemAttribute(thing.uid, "level").."].\n" --alterado v2.6 if lock and lock > 0 then str = str.."It will unlock in ".. os.date("%d/%m/%y %X", lock)..".\n" --alterado v2.8 end local boost = getItemAttribute(thing.uid, "boost") or 0 local boostshow = "" if boost > 0 then str = str.."Boost level: +"..boost..".\n" end if getItemAttribute(thing.uid, "nick") then str = str.."It's nickname is: "..getItemAttribute(thing.uid, "nick")..".\n" end if getItemAttribute(thing.uid, "gender") == SEX_MALE then str = str.."It is male." elseif getItemAttribute(thing.uid, "gender") == SEX_FEMALE then str = str.."It is female." else str = str.."It is genderless." end str = str.."\n--- Status ---" str = str.."\nOffense: "..math.floor(getItemAttribute(thing.uid, "offense")).." Defense: "..math.floor(getItemAttribute(thing.uid, "defense")).."\n" str = str.."Agility: "..math.floor(getItemAttribute(thing.uid, "speed")).." Sp. Attack: "..math.floor(getItemAttribute(thing.uid, "specialattack")).."\n" str = str.."Vitality: "..math.floor(getItemAttribute(thing.uid, "vitality")).."" doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return false elseif string.find(iname.name, "fainted") or string.find(iname.name, "defeated") then str = "You see a "..string.lower(iname.name).." ["..getItemAttribute(thing.uid, "level").."]. " --alterado v2.8 \/ if isContainer(thing.uid) then str = str.."(Vol: "..getContainerCap(thing.uid)..")" end str = str.."\n" if getItemAttribute(thing.uid, "gender") == SEX_MALE then str = str.."It is male." elseif getItemAttribute(thing.uid, "gender") == SEX_FEMALE then str = str.."It is female." else str = str.."It is genderless." end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return false elseif isContainer(thing.uid) then --containers local info = getItemInfo(thing.itemid) --alterado v2.7 if info.name == "dead human" and getItemAttribute(thing.uid, "pName") then str = "You see a dead human (Vol:"..getContainerCap(thing.uid).."). " str = str.."You recognize ".. getItemAttribute(thing.uid, "pName")..". ".. getItemAttribute(thing.uid, "article").." was killed by a " str = str.."".. getItemAttribute(thing.uid, "attacker").."." else str = "You see "..info.article.." "..info.name..". (Vol:"..getContainerCap(thing.uid)..")." end if getPlayerGroupId(cid) >= 4 and getPlayerGroupId(cid) <= 6 then str = str.."\nItemID: ["..thing.itemid.."]" --alterado v2.8 local pos = getThingPos(thing.uid) str = str.."\nPosition: [X: "..pos.x.."][Y: "..pos.y.."][Z: "..pos.z.."]" --alterado v2.8 end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return false elseif getItemAttribute(thing.uid, "unique") then --alterado v2.8 \/ local info = getItemInfo(thing.itemid) local p = getThingPos(thing.uid) local str = "You see " if thing.type > 0 then str = str..thing.type.." "..info.plural.."." else str = str..info.article.." "..info.name.."." end str = str.." It's an unique item.\n" str = str..info.description.."\nItemID: ["..thing.itemid.."]" str = str.."\nPosition: ["..p.x.."]["..p.y.."]["..p.z.."]" sendMsgToPlayer(cid, MESSAGE_INFO_DESCR, str) return false else return true end end local NPCBattle = { ["Brock"] = {artig = "He is", cidbat = "Pewter"}, ["Misty"] = {artig = "She is", cidbat = "Cerulean"}, ["Blaine"] = {artig = "He is", cidbat = "Cinnabar"}, ["Sabrina"] = {artig = "She is", cidbat = "Saffron"}, --alterado v2.7 ["Kira"] = {artig = "She is", cidbat = "Viridian"}, ["Koga"] = {artig = "He is", cidbat = "Fushcia"}, ["Erika"] = {artig = "She is", cidbat = "Celadon"}, ["Surge"] = {artig = "He is", cidbat = "Vermilion"}, } local npcname = getCreatureName(thing.uid) if ehNPC(thing.uid) and NPCBattle[npcname] then --npcs duel str = "You see "..npcname..". "..NPCBattle[npcname].artig.." leader of the gym from "..NPCBattle[npcname].cidbat.."." --alterado v2.7 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return false elseif ehNPC(thing.uid) and getPlayerStorageValue(thing.uid, 697548) ~= -1 then --npcs de TV local str = getPlayerStorageValue(thing.uid, 697548) --alterado v2.7 local pos = getThingPos(thing.uid) str = youAre[getPlayerGroupId(cid)] and str.."\nPosition: [X: "..pos.x.."][Y: "..pos.y.."][Z: "..pos.z.."]." or str doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return false end if not isPlayer(thing.uid) and not isMonster(thing.uid) then str = "You see "..getCreatureName(thing.uid).."." doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return false end if isPlayer(thing.uid) then --player doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, getPlayerDesc(cid, thing.uid, false)) --alterado v2.7 return false end if getCreatureName(thing.uid) == "Evolution" then return false end if not isSummon(thing.uid) then local str = "You see a wild "..string.lower(getCreatureName(thing.uid)).." [level "..getPokemonLevel(thing.uid).."].\n" if getPokemonGender(thing.uid) == SEX_MALE then str = str.."It is male." elseif getPokemonGender(thing.uid) == SEX_FEMALE then str = str.."It is female." else str = str.."It is genderless." end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return false elseif isSummon(thing.uid) and not isPlayer(thing.uid) then local boostlevel = getItemAttribute(getPlayerSlotItem(getCreatureMaster(thing.uid), 8).uid, "boost") or 0 local boostshow = " + "..boostlevel.."]" if showBoostSeparated then boostshow = "] [+"..boostlevel.."]" end local levelinfo = "["..getPokemonLevel(thing.uid)..""..boostshow.."" if getCreatureMaster(thing.uid) == cid then local myball = getPlayerSlotItem(cid, 8).uid local nexp = getItemAttribute(myball, "nextlevelexp") local string = "You see your "..string.lower(getCreatureName(thing.uid)).." "..levelinfo.."." string = string.."\nHit points: "..getCreatureHealth(thing.uid).."/"..getCreatureMaxHealth(thing.uid).."." string = string.."\n"..getPokemonHappinessDescription(thing.uid) if getItemAttribute(myball, "level") <= 99 then string = string.."\nExperience needed to level up: "..nexp.."." end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string) else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You see a "..string.lower(getCreatureName(thing.uid)).." "..levelinfo..".\nIt belongs to "..getCreatureName(getCreatureMaster(thing.uid))..".") end return false end return true end NPC que garante entrada a Saffari Zone: local tab = { pos = {x = 768, y = 1007, z = 8}, -- posição x, y, z do local a teleportar o player cardId = xxx, --ID do Saffari Card. } 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 creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid if msgcontains(msg, 'teleport') then talkState[talkUser] = 1 selfSay("Are you sure? To enter in the Saffari Zone, you need a valid Saffari Card.", cid) elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then local items = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, tab.cardId) if #items == 0 then selfSay("You do not have any Saffari Card in your bag.", cid) talkState[talkUser] = 0 else local checkPlayer = false for i = 1, #items do if getItemAttribute(items[i], "vality") and getItemAttribute(items[i], "vality") > os.time() then checkPlayer = true break end end if checkPlayer then doTeleportThing(cid, tab.pos) doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT) selfSay('Boa sorte no Saffari Zone.', cid) else selfSay("You do not have any valid Saffari Card in your bag.", cid) end end elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then talkState[talkUser] = 0 selfSay('Okay, Talvez em outra hora.', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) NPC que vende o Saffari Card: local config = { cardId = xxx, --ID do Saffari Card. price = {itemid, count}, --Preço do Saffari Card. {ID_do_item, quantidade} days = 30, --Validade, em dias, do Saffari Card. } 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 creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid if msgcontains(msg:lower(), "buy") or msgcontains(msg:lower(), "trade") then selfSay("You wanna buy a Saffari Card for "..config.price[2].."x "..getItemNameById(config.price[1]).."? Vality: "..config.days.." days.", cid) talkState[talkUser] = 1 return true elseif msgcontains(msg:lower(), "yes") and talkState[talkUser] == 1 then if doPlayerRemoveItem(cid, config.price[1], config.price[2]) then selfSay("Here's your Saffari Card!", cid) local item = doPlayerAddItem(cid, config.cardId, 1) doItemSetAttribute(item, "vality", os.time() + (config.days * 24 * 60 * 60)) talkState[talkUser] = 0 return true else selfSay("You do not have the items.", cid) talkState[talkUser] = 0 return true end elseif msgcontains(msg:lower(), "no") and talkState[talkUser] == 1 then selfSay("OK, bye!", cid) talkState[talkUser] = 0 return true end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Editado Maio 2, 2015 10 anos por zipter98 (veja o histórico de edições) não respondo pms solicitando suporte em programação/scripting
Postado Maio 1, 2015 10 anos Autor Muito obrigado, estou com um problema no RME e assim que resolver vou testa-lo. Rep+ Aee mano o npc não está carregando por causa deste erro.
Postado Maio 2, 2015 10 anos Ops, escrevi o código correndo e nem reparei neste erro. Script corrigido (NPC que vende o Saffari Card). não respondo pms solicitando suporte em programação/scripting
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.