Ir para conteúdo

ecdouradojr

Membro
  • Registro em

  • Última visita

  1. quando executei a talkaction que eu fiz dessa maneira: criei uma script assim com o nome teste.lua function onSay(cid, words, param) local seen={} function dump(t,i) seen[t]=true local s={} local n=0 for k in pairs(t) do n=n+1 s[n]=k end table.sort(s) for k,v in ipairs(s) do print(i,v) v=t[v] if type(v)=="table" and not seen[v] then dump(v,i.."\t") end end end dump(_G,"") return true end e no talkactions.xml eu coloquei assim: <talkaction words="!teste" event="script" value="teste.lua"/> entrei no server, falei !teste e o server caiu e o console mandou um texto enorme: e agora, oq devo fazer?
  2. fiz como voce falou, usando assim local config = { minlevel = 100, --- level inical para resetar price = 10000, --- preço inicial para resetar newlevel = 20, --- level após reset priceByReset = 10000, --- preço acrescentado por reset percent = 100, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total) maxresets = 20, levelbyreset = 100 --- quanto de level vai precisar a mais no próximo reset } --- end config function getResets(uid) resets = getPlayerStorageValue(uid, 378378) if resets < 0 then resets = 0 end return resets end 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 function addReset(cid) if(npcHandler:isFocused(cid)) then npcHandler:releaseFocus(cid) end talkState[talkUser] = 0 resets = getResets(cid) setPlayerStorageValue(cid, 378378, resets+1) doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) local hp = getCreatureMaxHealth(cid) local resethp = hp*(config.percent/100) setCreatureMaxHealth(cid, resethp) local differencehp = (hp - resethp) doCreatureAddHealth(cid, -differencehp) local mana = getCreatureMaxMana(cid) local resetmana = mana*(config.percent/100) setCreatureMaxMana(cid, resetmana) local differencemana = (mana - resetmana) doCreatureAddMana(cid, -differencemana) doRemoveCreature(cid) local description = resets+1 db.query("UPDATE `players` SET `description` = ' [Reset: "..description.."]' WHERE `players`.`id`= ".. playerid .."") db.query("UPDATE `players` SET `level`="..config.newlevel..",`experience`= 0,`cap`= 200 WHERE `players`.`id`= ".. playerid .."") return true end local newPrice = config.price + (getResets(cid) * config.priceByReset) local newminlevel = config.minlevel + (getResets(cid) * config.levelbyreset) if msgcontains(msg, 'poder') then if getResets(cid) < config.maxresets then selfSay('sim eu desenvolvi uma tecnica que concentra seu poder em sua alma possibilitando o acumulo de mais poder que seu corpo fisico n suportaria. eu te ensinarei isso por '..newPrice..' gp\'s!', cid) talkState[talkUser] = 1 else selfSay('eu ja te ensinei tudo que sei, mais um reset poderia destruir seu fragil e instavel corpo mortal!', cid) end elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if getPlayerMoney(cid) < newPrice then selfSay('voce precisa de '..newPrice..' gp\'s para que eu possa te treinar!', cid) elseif getPlayerLevel(cid) < newminlevel then selfSay('Ainda esta cedo para isso.. Voce so podera repetir essa tecnica no nivel '..newminlevel..'!', cid) else doPlayerRemoveMoney(cid,newPrice) playerid = getPlayerGUID(cid) addEvent(function() if isPlayer(cid) then addReset(cid) selfSay('Voce resetou!, pergunte por "resets para saber quantos resets tem!', cid) end end, 3000) local number = getResets(cid)+1 local msg ="---[Reset: "..number.."]-- voce resetou! desperte bravo guerreiro, a jornada ainda não terminou..." doPlayerPopupFYI(cid, msg) talkState[talkUser] = 0 npcHandler:releaseFocus(cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'no')) and isInArray({1}, talkState[talkUser]) == TRUE then talkState[talkUser] = 0 npcHandler:releaseFocus(cid) selfSay('Ok.', cid) elseif msgcontains(msg, 'resets') then selfSay('voce tem um total de '..getResets(cid)..' reset(s).', cid) talkState[talkUser] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) o npc aparece responde, reseta mas não altera o lvl, e da outro erro no console eu ja testei db.Query, db.query e db.executeQuery e nada
  3. ola, desculpe reviver mais uma vez esse tópico, eu estou tendo problemas para usar essa script a versão do meu server é 8.6 local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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 local config = { minlevel = 100, --- Level inical para resetar price = 10000, --- Preço inicial para resetar newlevel = 20, --- Level após reset priceByReset = 10000, --- Preço acrescentado por reset percent = 100, ---- Porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total) maxresets = 50, ---- Maximo de resets levelbyreset = 100 --- Quanto de level vai precisar a mais no próximo reset } local function addReset(uid) local player = Player(uid) if player then local resets = player:getResets()+1 local hp = player:getMaxHealth() local resethp = hp*(config.percent/100) player:setMaxHealth(resethp) local mana = player:getMaxMana() local resetmana = mana*(config.percent/100) player:setMaxMana(resetmana) local playerid = player:getGuid() player:remove() db.query("UPDATE `players` SET `resets`="..resets..",`experience`= 0 WHERE `players`.`id`= ".. playerid .."") db.query("UPDATE `players` SET `level`="..config.newlevel..",`experience`= 0 WHERE `players`.`id`= ".. playerid .."") end return true end local function getResets(uid) local player = Player(uid) local resets = 0 if player then resets = math.max(0, player:getStorageValue(378378)) end return resets end function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end local player = Player(cid) local newPrice = config.price + (getResets(cid) * config.priceByReset) local newminlevel = config.minlevel + (getResets(cid) * config.levelbyreset) if msgcontains(msg, 'poder') then if getResets(cid) < config.maxresets then npcHandler:say('sim eu desenvolvi uma tecnica que concentra seu poder em sua alma possibilitando o acumulo de mais poder que seu corpo fisico n suportaria. eu te ensinarei isso por '..newPrice..' gp\'s!', cid) npcHandler.topic[cid] = 1 else npcHandler:say('eu ja te ensinei tudo que sei, mais um reset poderia destruir seu fragil e instavel corpo mortal!', cid) end elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then if player:getLevel() > newminlevel then if player:removeMoney(newPrice) then addEvent(function() if isPlayer(cid) then addReset(cid) end end, 3000) local number = getResets(cid)+1 local msg ="---[Reset: "..number.."]-- voce resetou! desperte bravo guerreiro, a jornada ainda não terminou...." player:popupFYI(msg) npcHandler.topic[cid] = 0 npcHandler:releaseFocus(cid) else npcHandler:say('voce precisa de '..newPrice..' gp\'s para que eu possa te treinar!', cid) npcHandler.topic[cid] = 0 end else npcHandler:say('Ainda esta cedo para isso.. Voce so podera repetir essa tecnica no nivel '..newminlevel..'!', cid) npcHandler.topic[cid] = 0 end elseif(msgcontains(msg, 'no')) and isInArray({1}, npcHandler.topic[cid]) then npcHandler.topic[cid] = 0 npcHandler:releaseFocus(cid) npcHandler:say('Ok.', cid) elseif msgcontains(msg, 'resets') then npcHandler:say('voce possue um total de '..getResets(cid)..' reset(s).', cid) npcHandler.topic[cid] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) quando eu ponho dessa maneira, o npc aparece no servidor, porem assim que eu falo com o npc eu recebo uma mensagem de erro e o npc não responde voces poderiam me ajudar?

Informação Importante

Confirmação de Termo