LUA:
local price = 100000 -- Price of reset
local newlevel = 10 -- level after reset
local newexp = 9300 -- Exp after reset
local maxreset = 10
-- end config
function addReset(cid)
return setPlayerStorageValue(cid, 36874, getResets(cid) + 1)
end
function getResets(cid)
return math.max(0, getPlayerStorageValue(cid, 36874))
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
if msgcontains(msg, 'reset') then
selfSay(' Do you want to reset for '..price..' GP.', cid)
talkState[cid] = 1
elseif(msgcontains(msg, 'yes') and talkState[cid] == 1) then
local resets = getResets(cid)
if resets <= 3 then
resets=-1
end
local minlevel = math.max(math.min(500 ) * 2, 4)
if getPlayerMoney(cid) < price then
selfSay('You must pay '..price..' gold coins to reset.', cid)
elseif getPlayerLevel(cid) < minlevel then
selfSay('you need '.. minlevel ..' to reset.', cid)
else
doPlayerRemoveMoney(cid,price)
addReset(cid)
playerid = getPlayerGUID(cid)
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level`="..newlevel..",`experience`="..newexp.." WHERE `players`.`id`= ".. playerid .."")
end
talkState[cid] = 0
elseif msgcontains(msg, 'no') and isInArray({1}, talkState[cid]) then
talkState[cid] = 0
selfSay('Yes', cid)
elseif msgcontains(msg, 'resets') then
selfSay('You Have '..getResets(cid)..' reset(s).', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
what i want to be fixed is that when you reset first time, next time you can reset is double the first reset.
so lets say first reset is level 1000. next reset should be 2000 and next 4000 and next 8000 and next 10000.
Thanks in advanced
/Elaney