O que ela faz?
ao clicar na pedra é salvo a sua posição atual assim quando for usada novamente o jogador será teleportado para a posição salva. ao falar com um npc pode-se resetar a pedra ou então salvar a posição para a cidade atual do npc.
Action
config = { shows_messages = true, level_necessary = 10, exhaustion_time = 50, -- in seconds exaustion_storage = 1234, time_casting = 10, magical_effect = 10, } function checkfight(cid , interval , pos , towname) setPlayerStorageValue(cid, 12345, 1) if config.shows_messages then doPlayerSendTextMessage(cid, 1, getCreatureName(cid).." ["..getPlayerLevel(cid).."]: Teleporting in " ..config.time_casting-interval.. " seconds") end doSendMagicEffect(getCreaturePosition(cid) , config.magical_effect) if getCreatureCondition(cid, CONDITION_INFIGHT) == false then doCreatureSetNoMove(cid, true) if config.time_casting-interval == 0 then doTeleportThing(cid, pos) doCreatureSetNoMove(cid, false) setPlayerStorageValue(cid, 12345, 0) if config.shows_messages then doPlayerSendTextMessage(cid, 1, getCreatureName(cid).." ["..getPlayerLevel(cid).."]: Finally in "..towname) end end exhaustion.set(cid, config.exaustion_storage, config.exhaustion_time) end if getCreatureCondition(cid, CONDITION_INFIGHT) and interval == config.time_casting then if config.shows_messages then doPlayerSendTextMessage(cid, 1, getCreatureName(cid).." ["..getPlayerLevel(cid).."]: I'm in battle") end doCreatureSetNoMove(cid, false) setPlayerStorageValue(cid, 12345, 0) exhaustion.set(cid, config.exaustion_storage, 0) end end function onUse(cid, item, frompos, item2, topos) if not getItemAttribute(item.uid, "description") then setPlayerStorageValue(cid, 301420, getThingPos(cid).x) setPlayerStorageValue(cid, 301421, getThingPos(cid).y) setPlayerStorageValue(cid, 301422, getThingPos(cid).z) doItemSetAttribute(item.uid, "description", 'Recorded in Custom.') doPlayerSendTextMessage(cid, 1, getCreatureName(cid).." ["..getPlayerLevel(cid).."]: Recorded in Custom") return false end local townname = getItemAttribute(item.uid, "description"):match("Recorded in (.*).") local pos = getTownTemplePosition(getTownId(townname)) if townname == "Custom" then pos = {x= getPlayerStorageValue(cid, 301420), y= getPlayerStorageValue(cid, 301421), z= getPlayerStorageValue(cid, 301422)} end if config.level_necessary <= getPlayerLevel(cid) then if not exhaustion.check(cid, config.exaustion_storage) then for i = 1, config.time_casting do addEvent(checkfight ,1000*i ,cid , i , pos , townname) end else if config.shows_messages then doPlayerSendTextMessage(cid, 1, getCreatureName(cid).." ["..getPlayerLevel(cid).."]: I can only use again in "..exhaustion.get(cid, 1234).." seconds") end end else if config.shows_messages then doPlayerSendTextMessage(cid, 1, getCreatureName(cid).." ["..getPlayerLevel(cid).."]: I can only use it when you are level "..config.level_necessary) end end end
Npc
Xml
<?xml version="1.0" encoding="UTF-8"?> <npc name="Jack Stone" script="data/npc/scripts/Town 1.lua" walkinterval="5000" floorchange="0"> <health now="100" max="100"/> <look type="130" head="0" body="114" legs="107" feet="76" addons="3"/> <parameters> <parameter key="message_greet" value="Welcome |PLAYERNAME|! can record your teleport stone for this city {record} or else there-reset{reset}." /> <parameter key="module_keywords" value="1" /> </parameters> </npc>
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 creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local town = 1 local nametown = getTownName(town) local stoneid = 8300 local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if msgcontains(string.lower(msg), 'Record') or msgcontains(string.lower(msg), 'record') then if doPlayerRemoveItem(cid, stoneid, 1) then selfSay("now his teleport stone is engraved in "..nametown..".", cid) local teleport_stone = doPlayerAddItem(cid, stoneid, 1) doItemSetAttribute(teleport_stone, "description", 'Recorded in '..nametown..'.') --doSetItemSpecialDescription(teleport_stone, 'Recorded in '..nametown..'.') else selfSay("you do not have a teleport stone so I can not write to it.", cid) end return true end if msgcontains(string.lower(msg), 'Reset') or msgcontains(string.lower(msg), 'reset') then if doPlayerRemoveItem(cid, stoneid, 1) then doPlayerAddItem(cid, stoneid, 1) selfSay("the stone was reset.", cid) end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
se tiver algum bug ou se tiver alguma ideia, sugestão não deixa de comentar