Jump to content

Sistema De Resets Sem Bug com tempo.


JulioLancetti

Recommended Posts

Sistema de Reset por Talkactions com Exhausted para não ser bugado.
 
Vá em talkaction.xml e adicione :
<talkaction words="!resetar;/installreset" event="script" value="resetar.lua"/>
 
Agora va em talkaction/scripts e crie um arquivo lua chamado resetar.lua e cole dentro do arquivo :
 
 

local exhaustionMinutes = 1 -- exausted em minutos
local storageUse = 34538 -- storage usado no exausted.

function onSay(cid, words, param)
if words =="!resetar" then
if(exhaustion.check(cid, storageUse) == TRUE) then
if (exhaustion.get(cid, storageUse) >= 30) then
doPlayerSendCancel(cid, "Voçê só pode usar após [" .. math.floor(exhaustion.get(cid, storageUse) / 80 + 1) .."] Minutos.")
end
if (exhaustion.get(cid, storageUse) <= 30) then
doPlayerSendCancel(cid, "Voçê só pode usar após [" .. exhaustion.get(cid, storageUse).."] segundos.")
end
return TRUE
end


exhaustion.set(cid, storageUse, exhaustionMinutes*10)
--[ Condições de Reset ] --
local coNdConf = {
needPz = false, -- Precisa estar em Pz pra resetar? [true, false]
needPa = false, -- Precisa ser Premium Account Pra resetar? [true, false]
withe = false, -- Players com Pk Withe podem resetar? [true, false]
red = false, -- Players com Pk Red pode resetar? [true, false]
battle = true, -- Players precisão estar sem battle pra resetar? [true, false]
teleport = false, -- Teleportar Player para o templo após resetar? [true, false]
look = true, -- Aparecer Resets no Look do Player? [true, false]
pid = getPlayerGUID(cid), -- Não Mexer.

--[ Configurações do Reset ] --
resetConf = {
Level = 350, -- Level Necessário para Resetar. [Valor]
backLvl = 50, -- Level que voltará após o Reset. [Valor]
time = 1, -- Tempo para o Player deslogar ao resetar, em segundos. [Valor]
},
}


--[[>> STAGES <<]]--
x=true;X=true -- Não Mexer.
local stage = {Abilitar = {x}, Desabilitar = {}, --<< Abilitar Stages?? >>-- [{x};{}]


-- [RESETS] | [PREMMY] | [FREE]
stage1= {resets= 4, premmy= 350, free= 350},
stage2= {resets= 9, premmy= 360, free= 360}, -- EXPLICANDO e Configurando stages. (Se estiver Abilitado [Abilitar = {x}])
stage3= {resets= 14, premmy= 370, free= 370}, -- resets = Número de resets para o Stage;
stage4= {resets= 19, premmy= 380, free= 380}, -- premmy = Level necessário para Premium Accounts;
stage5= {resets= 24, premmy= 390, free= 390}, -- free = Level necessário para Free Accounts;
stage6= {resets= 29, premmy= 400, free= 400}, -- Coloque em Ordem...
stage7= {resets= 34, premmy= 420, free= 420}, -- [OBS: MARQUE UM "X" PARA ABILITAR OU DESABILITAR OS STAGES]
stage8= {resets= 39, premmy= 440, free= 440}, -- EX: para desabilitar mude: Abilitar = {}, Desabilitar = {x}
stage9= {resets= 44, premmy= 460, free= 460},
stage10={resets= 49, premmy= 480, free= 480},
stage11={resets= 54, premmy= 500, free= 500},
stage12={resets= 59, premmy= 525, free= 525},
stage13={resets= 64, premmy= 900, free= 900},
stage14={resets= 69, premmy= 750, free= 950},
stage15={resets= 74, premmy= 760, free= 960},
stage16={resets= 79, premmy= 1300, free= 1370},
stage17={resets= 84, premmy= 1450, free= 1450},
stage18={resets= 89, premmy= 1470, free= 1470},
stage19={resets= 94, premmy= 1590, free= 1590},
stage20={resets= 99, premmy= 1610, free= 1610},
stage21={resets= 100, premmy= 1651, free= 1651},
stage22={resets= 108, premmy= 1710, free= 1710},
stage23={resets= 130, premmy= 2000, free= 2000},
stage24={resets= 138, premmy= 3146, free= 3146},
stage25={resets= 143, premmy= 3646, free= 3646},
}


--[[>> FIM STAGES <<]]--
--=[Pega Valor de Resets]=--
function getPlayerReset(cid)
local qr = db.getResult("SELECT `reset` FROM `players` WHERE `id`= "..coNdConf.pid..";")
rss = qr:getDataInt("reset", coNdConf.pid)
if rss < 0 then
rss = 0
end
return rss
end
local success = " ~~ Sucesso! ~~ \nVocê tem agora "..(getPlayerReset(cid)+1).." resets. \nVocê será deslogado em "..coNdConf.resetConf.time.." segundos." ;err = doPlayerSendTextMessage
local qrt = db.getResult("SELECT `reset` FROM `players` WHERE `id`= "..coNdConf.pid..";");rss_db = qrt:getDataInt("reset", coNdConf.pid)
local lvl_query = "UPDATE `players` SET `level` = "..(coNdConf.resetConf.backLvl)..", `experience` = 0 WHERE `id`= " .. coNdConf.pid .. ";"
local reset_query = "UPDATE `players` SET `reset` = "..(getPlayerReset(cid)+(1)).." WHERE `id`= " .. coNdConf.pid .. ";"
local nolook_query = "UPDATE `players` SET `description` = '' WHERE `players`.`id`= " .. coNdConf.pid .. ";"
local look_query = "UPDATE `players` SET `description` = ' [Reset "..(getPlayerReset(cid)+(1)).."]' WHERE `players`.`id`= " .. coNdConf.pid .. ";"
--=[Reseta]=--
function addValue(value)
if coNdConf.look == false then
doRemoveCreature(cid)
db.executeQuery(lvl_query);db.executeQuery(reset_query);db.executeQuery(nolook_query)
else
doRemoveCreature(cid)
db.executeQuery(lvl_query);db.executeQuery(reset_query);db.executeQuery(look_query)
return LUA_NO_ERROR
end
end
function nowReseting()
if (getPlayerLevel(cid) < coNdConf.resetConf.Level) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "- Level Necessário Para o Reset ["..coNdConf.resetConf.Level.."]. Faltam "..coNdConf.resetConf.Level-getPlayerLevel(cid).." level's para você Resetar. -")
return true
end
if getPlayerLevel(cid) >= coNdConf.resetConf.Level and (coNdConf.teleport == false) then
doPlayerPopupFYI(cid, success)
addEvent(addValue, coNdConf.resetConf.time*1000, value)
else
doPlayerPopupFYI(cid, success)
addEvent(doTeleportThing, coNdConf.resetConf.time*900, cid, getTownTemplePosition(getPlayerTown(cid)))
addEvent(addValue, coNdConf.resetConf.time*1000, value)
return true
end
end
--[sTAGES Nao mexer em nada.]--
function checkLevelStageReset(cid)
local stages = {
{resets= stage.stage1.resets, premmy= stage.stage1.premmy, free= stage.stage1.free},
{resets= stage.stage2.resets, premmy= stage.stage2.premmy, free= stage.stage2.free},
{resets= stage.stage3.resets, premmy= stage.stage3.premmy, free= stage.stage3.free},
{resets= stage.stage4.resets, premmy= stage.stage4.premmy, free= stage.stage4.free},
{resets= stage.stage5.resets, premmy= stage.stage5.premmy, free= stage.stage5.free},
{resets= stage.stage6.resets, premmy= stage.stage6.premmy, free= stage.stage6.free},
{resets= stage.stage7.resets, premmy= stage.stage7.premmy, free= stage.stage7.free},
{resets= stage.stage8.resets, premmy= stage.stage8.premmy, free= stage.stage8.free},
{resets= stage.stage9.resets, premmy= stage.stage9.premmy, free= stage.stage9.free},
{resets=stage.stage10.resets, premmy=stage.stage10.premmy, free=stage.stage10.free},
{resets=stage.stage11.resets, premmy=stage.stage11.premmy, free=stage.stage11.free},
{resets=stage.stage12.resets, premmy=stage.stage12.premmy, free=stage.stage12.free},
{resets=stage.stage13.resets, premmy=stage.stage13.premmy, free=stage.stage13.free},
{resets=stage.stage14.resets, premmy=stage.stage14.premmy, free=stage.stage14.free},
{resets=stage.stage15.resets, premmy=stage.stage15.premmy, free=stage.stage15.free},
{resets=stage.stage16.resets, premmy=stage.stage16.premmy, free=stage.stage16.free},
{resets=stage.stage17.resets, premmy=stage.stage17.premmy, free=stage.stage17.free},
{resets=stage.stage18.resets, premmy=stage.stage18.premmy, free=stage.stage18.free},
{resets=stage.stage19.resets, premmy=stage.stage19.premmy, free=stage.stage19.free},
{resets=stage.stage20.resets, premmy=stage.stage20.premmy, free=stage.stage20.free},
{resets=stage.stage21.resets, premmy=stage.stage21.premmy, free=stage.stage21.free},
{resets=stage.stage22.resets, premmy=stage.stage22.premmy, free=stage.stage22.free},
{resets=stage.stage23.resets, premmy=stage.stage23.premmy, free=stage.stage23.free},
{resets=stage.stage24.resets, premmy=stage.stage24.premmy, free=stage.stage24.free},
{resets=stage.stage25.resets, premmy=stage.stage25.premmy, free=stage.stage25.free},
}
local resets = getPlayerReset(cid)
for i, tab in ipairs(stages) do
if resets <= tab.resets then
coNdConf.resetConf.Level = isPremium(cid) and tab.premmy or tab.free
break
end
end
if (getPlayerLevel(cid) < coNdConf.resetConf.Level) then
err(cid, MESSAGE_STATUS_CONSOLE_BLUE, "- Você necessecita ter ["..coNdConf.resetConf.Level.."]. leveis , Faltam "..coNdConf.resetConf.Level-getPlayerLevel(cid).." levels para você Resetar seu personagem.")
return TRUE
end
if getPlayerLevel(cid) >= coNdConf.resetConf.Level and (coNdConf.teleport == false) then
doPlayerPopupFYI(cid, success)
addEvent(addValue, coNdConf.resetConf.time*1000, value)
else
doPlayerPopupFYI(cid, success)
addEvent(addValue, coNdConf.resetConf.time*1000, value)
addEvent(doTeleportThing, coNdConf.resetConf.time*900, cid, getTownTemplePosition(getPlayerTown(cid)))
return true
end
end
function newReset(cid)
if(coNdConf.needPz == true) and (getTilePzInfo(getCreaturePosition(cid)) == LUA_ERROR) then
err(cid,MESSAGE_STATUS_CONSOLE_BLUE,"- Você Precisa estar em Protection Zone Para Resetar. -") return TRUE end
if(coNdConf.needPa == true) and not isPremium(cid) then
err(cid,MESSAGE_STATUS_CONSOLE_BLUE,"- Você Precisa ser Premium Account para Resetar. -") return TRUE end
if(coNdConf.withe == false) and (getCreatureSkullType(cid) == 3) then
err(cid,MESSAGE_STATUS_CONSOLE_BLUE,"- Você não pode resetar em condições de PK Withe. -") return TRUE end
if(coNdConf.red == false) and (getCreatureSkullType(cid) == 4) then
err(cid,MESSAGE_STATUS_CONSOLE_BLUE,"- Você não pode resetar em condições de PK Red. -") return TRUE end
if(coNdConf.battle == true) and (getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
err(cid,MESSAGE_STATUS_CONSOLE_BLUE,"- Você Precisa estar sem Battle para Resetar. -") return TRUE end
local xy = {true,false}
table.insert(stage.Abilitar, false)
table.insert(stage.Desabilitar, false)
if stage.Abilitar[1] == xy[1] and stage.Desabilitar[1] == xy[2] then
checkLevelStageReset(cid)
elseif stage.Abilitar[1] == xy[2] and stage.Desabilitar[1] == xy[1] then
nowReseting()
else
doPlayerPopupFYI(cid, "LUA_ERROR; Configure corretamente o Sistema de STAGES!")
end
return true
end
function tableResetInstall()
print(not rss_db and LUA_ERROR or "Tabela de Resets: Instalada ... [success] ")
addEvent(newReset, 1000, cid)
return false
end
if tableResetInstall() then
end
end
--=[install System]=--
function installReset()
if db.executeQuery("ALTER TABLE `players` ADD reset INT(11) NOT NULL DEFAULT 0;") then
print("[JulioLancetti] -= Advanced Reset System 2.0 por DataBase =- Instalado com sucesso!")
return TRUE
end
print('[Advanced Reset System] Não foi possível instalar o Sistema.')
return FALSE
end
local tt = {
"Preparando Instalação...",
"Instalando: TableReset Db...",
"Instalando: getPlayerReset()...",
"Instalando: addValue()...",
"Instalando: checkLevelStageReset()...",
"Instalando: newReset() and nowReseting()...",
"Finalizando Instalação...",
"...",
success = {
"Iniciando...",
"function: TableReset Db... [success]",
"function: getPlayerReset()... [success]",
"function: addValue(value)... [success]",
"function: checkLevelStageReset()... [success]",
"function: newReset() and nowReseting()... [success]",
"Fim da Instalação. ",
inst = {"JL","Advanced Reset System 2.0 por DataBase"
},
},
}
if words == "/installreset" and getPlayerAccess(cid) >= 3 then
function install()
if installReset() then
print(""..tt.success[7].."")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,""..tt.success[8].."")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "["..tt.success.inst[1].."] -="..tt.success.inst[2].."=- Instalado com sucesso!")
else
print("["..tt.success.inst[1].."] FALHA NA INSTALAÇÃO! [O sistema ja foi instalado].")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "["..tt.success.inst[1].."] FALHA NA INSTALAÇÃO! [O sistema ja foi instalado].")
end
return 1
end
function concl(cid)
local typetx = MESSAGE_STATUS_CONSOLE_BLUE
print(""..tt.success[7].."")
print(""..tt[8].."")
doPlayerSendTextMessage(cid, typetx,""..tt.success[7].."")
doPlayerSendTextMessage(cid, typetx,""..tt[8].."")
addEvent(install, 1000,cid)
end
function finall(cid)
local typetx = MESSAGE_STATUS_CONSOLE_BLUE
print(""..tt.success[6].."")
print(""..tt[7].."")
doPlayerSendTextMessage(cid, typetx,""..tt.success[6].."")
doPlayerSendTextMessage(cid, typetx,""..tt[7].."")
addEvent(concl, 3000,cid)
end
function installDd(cid)
local typetx = MESSAGE_STATUS_CONSOLE_BLUE
print(""..tt.success[5].."")
print(""..tt[6].."")
doPlayerSendTextMessage(cid, typetx,""..tt.success[5].."")
doPlayerSendTextMessage(cid, typetx,""..tt[6].."")
addEvent(finall, 1000,cid)
end
function installCc(cid)
local typetx = MESSAGE_STATUS_CONSOLE_BLUE
print(""..tt.success[4].."")
print(""..tt[5].."")
doPlayerSendTextMessage(cid, typetx,""..tt.success[4].."")
doPlayerSendTextMessage(cid, typetx,""..tt[5].."")
addEvent(installDd, 1000,cid)
end
function installBb(cid)
local typetx = MESSAGE_STATUS_CONSOLE_BLUE
print(""..tt.success[3].."")
print(""..tt[4].."")
doPlayerSendTextMessage(cid, typetx,""..tt.success[3].."")
doPlayerSendTextMessage(cid, typetx,""..tt[4].."")
addEvent(installCc, 1000,cid)
end
function installAa(cid)
local typetx = MESSAGE_STATUS_CONSOLE_BLUE
print(""..tt.success[2].."")
print(""..tt[3].."")
doPlayerSendTextMessage(cid, typetx,""..tt.success[2].."")
doPlayerSendTextMessage(cid, typetx,""..tt[3].."")
addEvent(installBb, 1000,cid)
end
function toInstall()
local typetx = MESSAGE_STATUS_CONSOLE_BLUE
print(""..tt.success[1].."")
print(""..tt[2].."")
doPlayerSendTextMessage(cid, typetx,""..tt.success[1].."")
doPlayerSendTextMessage(cid, typetx,""..tt[2].."")
addEvent(installAa, 1000,cid)
end
function preparation()
local typetx = MESSAGE_STATUS_CONSOLE_BLUE
print(""..tt[1].."")
doPlayerSendTextMessage(cid, typetx,""..tt[1].."")
addEvent(toInstall, 3000,cid)
end
if preparation() then
end
end
return 1
end

 
-------------------------------------------------------------------------- Copie acima ---------------------------------------------------------------------------
 
Dentro da pasta data/lib terá um arquivo chamado  "- 034-exhaustion.lua" :
Adicione dentro do arquivo,
 

exhaustion =
{
check = function (cid, storage)
if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
return false
end

return getPlayerStorageValue(cid, storage) >= os.time()
end,

get = function (cid, storage)
if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
return false
end

local exhaust = getPlayerStorageValue(cid, storage)
if(exhaust > 0) then
local left = exhaust - os.time()
if(left >= 0) then
return left
end
end

return false
end,

set = function (cid, storage, time)
setPlayerStorageValue(cid, storage, os.time() + time)
end,

make = function (cid, storage, time)
local exhaust = exhaustion.get(cid, storage)
if(not exhaust) then
exhaustion.set(cid, storage, time)
return true
end

return false
end
}

 
Sistema está funcionando normalmente após a instalação.
 
Edited by JulioLancetti
Link to comment
Share on other sites

  • 2 weeks later...

estou com esse error Julio Meu Servidor Utiliza Site

 

 

 

 

mysql_real_query(): SELECT `reset` FROM `players` WHERE `id`= 17; - MYSQL ERROR: Unknown column 'reset' in 'field list' (1054)
[15/09/2013 19:04:14] [Error - TalkAction Interface]
[15/09/2013 19:04:14] data/talkactions/scripts/reset.lua:onSay
[15/09/2013 19:04:14] Description:
[15/09/2013 19:04:14] data/lib/004-database.lua:60: [Result:getDataInt] Result not set!
[15/09/2013 19:04:14] stack traceback:
[15/09/2013 19:04:14] [C]: in function 'error'
[15/09/2013 19:04:14] data/lib/004-database.lua:60: in function 'getDataInt'
[15/09/2013 19:04:14] data/talkactions/scripts/reset.lua:91: in function 'getPlayerReset'
[15/09/2013 19:04:14] data/talkactions/scripts/reset.lua:97: in function <data/talkactions/scripts/reset.lua:27>
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

 

estou com esse error Julio Meu Servidor Utiliza Site

 

 

 

 

mysql_real_query(): SELECT `reset` FROM `players` WHERE `id`= 17; - MYSQL ERROR: Unknown column 'reset' in 'field list' (1054)
[15/09/2013 19:04:14] [Error - TalkAction Interface]
[15/09/2013 19:04:14] data/talkactions/scripts/reset.lua:onSay
[15/09/2013 19:04:14] Description:
[15/09/2013 19:04:14] data/lib/004-database.lua:60: [Result:getDataInt] Result not set!
[15/09/2013 19:04:14] stack traceback:
[15/09/2013 19:04:14] [C]: in function 'error'
[15/09/2013 19:04:14] data/lib/004-database.lua:60: in function 'getDataInt'
[15/09/2013 19:04:14] data/talkactions/scripts/reset.lua:91: in function 'getPlayerReset'
[15/09/2013 19:04:14] data/talkactions/scripts/reset.lua:97: in function <data/talkactions/scripts/reset.lua:27>

 

 

 

Está faltando a coluna reset na sua database, script fácil, só fazer a mão..

para facilitar, fiz a você, adicione na sua database:

 

 

 

ALTER TABLE `player` ADD COLUMN `reset` VARCHAR(255) NOT NULL COMMENT 'mkbrabsolute xtibia possui';

 

 

 

 

Tenho este script completo caso precise!

Nota: Autor do tópico adicione a coluna do mysql ou faça a do sql, sei que você não sabe quase nada, mas é sempre bom adicionar para facilitar a vida dos membros!

 

 

Tenha um excelente dia!

Link to comment
Share on other sites

sinceramente, vc so pois um exhaunstion no script...

 

coloque os creditos do devido autor do codigo,vc n autor dele só fez uma pequena modificação. do contrario será reportado com link do topico que contem o script original como prova.

Link to comment
Share on other sites

  • 5 months later...
  • 2 years later...
Em 05/05/2016 at 10:47, deivisonamorim disse:
 


Esse script de reset ele reseta mana e life?? eu quero um que nao reseta mana nem life e que casa reset que o cara fala a mana e life aumenta um tanto....

Desculpe a demora pela resposta pois nem entrava nesse fórum durante anos pois estava fechado.
Não, esse sistema não volta a vida/mana.

Em 15/09/2013 at 19:05, JonatasLucasf disse:

estou com esse error Julio Meu Servidor Utiliza Site

 

 

 

 

mysql_real_query(): SELECT `reset` FROM `players` WHERE `id`= 17; - MYSQL ERROR: Unknown column 'reset' in 'field list' (1054)
 
[15/09/2013 19:04:14] [Error - TalkAction Interface]
[15/09/2013 19:04:14] data/talkactions/scripts/reset.lua:onSay
[15/09/2013 19:04:14] Description:
[15/09/2013 19:04:14] data/lib/004-database.lua:60: [Result:getDataInt] Result not set!
[15/09/2013 19:04:14] stack traceback:
[15/09/2013 19:04:14] [C]: in function 'error'
[15/09/2013 19:04:14] data/lib/004-database.lua:60: in function 'getDataInt'
[15/09/2013 19:04:14] data/talkactions/scripts/reset.lua:91: in function 'getPlayerReset'
[15/09/2013 19:04:14] data/talkactions/scripts/reset.lua:97: in function <data/talkactions/scripts/reset.lua:27>

Desculpa a demora, não entrava mas em fóruns,
ALTER TABLE players ADD reset INT( 11 ) NOT NULL DEFAULT '0'

Link to comment
Share on other sites

  • 5 weeks later...
Em 15/10/2017 at 18:36, JulioLancetti disse:

Desculpe a demora pela resposta pois nem entrava nesse fórum durante anos pois estava fechado.
Não, esse sistema não volta a vida/mana.

Desculpa a demora, não entrava mas em fóruns,
ALTER TABLE players ADD reset INT( 11 ) NOT NULL DEFAULT '0'

suave, tem um certo tempo já que parei, mesmo assim obrigado <3 :D

Link to comment
Share on other sites

×
×
  • Create New...