Postado Abril 24, 2015 10 anos vou te mandar um que eu uso, ai voce configura ele --[[Script made 100% by Nogard and Night Wolf. You can feel free to edit anything you want, but don't remove the credits]] local config = { minlevel = 100000, --- level inical para resetar price = 50000000, --- preço inicial para resetar newlevel = 8, --- level após reset priceByReset = 10000000, --- preço acrescentado por reset percent = 100, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total) maxresets = 5, levelbyreset = 0 --- quanto de level vai precisar a mais no próximo reset } --- end config function getResets(uid) resets = getPlayerStorageValue(uid, 2310) 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, 2310, 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 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, 'reset') then if getResets(cid) < config.maxresets then selfSay('Voce quer resetar seu char?', cid) talkState[talkUser] = 1 else selfSay('You already reached the maximum reset level!', cid) end elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if getPlayerMoney(cid) < newPrice then selfSay('Voce precisa de '..newPrice..' gold coins para resetar!', cid) elseif getPlayerLevel(cid) < newminlevel then selfSay('Voce precisa ser level '..newminlevel..' para resetar!', cid) else doPlayerRemoveMoney(cid,newPrice) playerid = getPlayerGUID(cid) addEvent(function() if isPlayer(cid) then addReset(cid) end end, 3000) local number = getResets(cid)+1 local msg ="---[Reset: "..number.."]-- You have reseted! You'll be disconnected in 3 seconds." 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, 'quantity') then selfSay('You have a total of '..getResets(cid)..' reset(s).', cid) talkState[talkUser] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Editado Abril 24, 2015 10 anos por poko360 (veja o histórico de edições)
Postado Abril 24, 2015 10 anos Autor vou te mandar um que eu uso, ai voce configura ele --[[Script made 100% by Nogard and Night Wolf. You can feel free to edit anything you want, but don't remove the credits]] local config = { minlevel = 100000, --- level inical para resetar price = 50000000, --- preço inicial para resetar newlevel = 8, --- level após reset priceByReset = 10000000, --- preço acrescentado por reset percent = 100, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total) maxresets = 5, levelbyreset = 0 --- quanto de level vai precisar a mais no próximo reset } --- end config function getResets(uid) resets = getPlayerStorageValue(uid, 2310) 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, 2310, 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 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, 'reset') then if getResets(cid) < config.maxresets then selfSay('Voce quer resetar seu char?', cid) talkState[talkUser] = 1 else selfSay('You already reached the maximum reset level!', cid) end elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if getPlayerMoney(cid) < newPrice then selfSay('Voce precisa de '..newPrice..' gold coins para resetar!', cid) elseif getPlayerLevel(cid) < newminlevel then selfSay('Voce precisa ser level '..newminlevel..' para resetar!', cid) else doPlayerRemoveMoney(cid,newPrice) playerid = getPlayerGUID(cid) addEvent(function() if isPlayer(cid) then addReset(cid) end end, 3000) local number = getResets(cid)+1 local msg ="---[Reset: "..number.."]-- You have reseted! You'll be disconnected in 3 seconds." 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, 'quantity') then selfSay('You have a total of '..getResets(cid)..' reset(s).', cid) talkState[talkUser] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) [24/04/2015 19:50:49] In a timer event called from: [24/04/2015 19:50:49] data/npc/scripts/resetador.lua:onCreatureSay [24/04/2015 19:50:49] stack traceback: [24/04/2015 19:50:49] data/lib/arenapvp2.lua:46: in function 'doRemoveCreature' [24/04/2015 19:50:49] data/npc/scripts/resetador.lua:67: in function 'addReset' [24/04/2015 19:50:49] data/npc/scripts/resetador.lua:98: in function <data/npc/scripts/resetador.lua:96> :/ Isso dá muita dor de cabeça, vou testar com os outros db.Query e execute já já edito o post Edit 1: Cara, meu servidor ele tem bug no comando /kick, ou seja o player não é kickado e também NPC quando tento remover utilizando o comando /r não sai, isso interfere na hora do char deslogar no reset? Edit 2: Testei com todos e nenhum funciona, eu acho que o problema é na lib mesmo. Vou te dá logo REP por está me ajudando Editado Abril 24, 2015 10 anos por lordzetros (veja o histórico de edições) Feliz daquele que ensina o que sabe, e aprende o que ensina.
Postado Abril 24, 2015 10 anos mudou na lib o storage? function getResets(uid)resets = getPlayerStorageValue(uid, 2310) if resets < 0 thenresets = 0endreturn resetsend
Postado Abril 25, 2015 10 anos Autor mudou na lib o storage? function getResets(uid) resets = getPlayerStorageValue(uid, 2310) if resets < 0 then resets = 0 end return resets end Sim... ;s Feliz daquele que ensina o que sabe, e aprende o que ensina.
Postado Abril 25, 2015 10 anos adicione na primeira linha em libs/function function getResets(uid) resets = getPlayerStorageValue(uid, 36378) if resets < 0 then resets = 0 end return resets end Simplificando essa função, fica assim function getResets(uid) return getPlayerStorageValue(uid, 36378) < 0 and 0 or getPlayerStorageValue(uid, 36378) end Atenciosamente, David Araujo Meu Conteúdo Fui útil? Gostou? Faça uma doação. "É errando que se erra." "Gambiarras resolvem instantemente, porém podem complicar em problemas futuros." "Cada dia vivido é um aprendizado."
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.