- Joined
- Aug 19, 2007
- Messages
- 4,941
- Solutions
- 11
- Reaction score
- 352
This NPC will reset your chars level, xp points, skills and mlvl leaving health, mana and capacity points.
data/npc:
somenpc.xml
The Forgotten Server 0.3:
data/npc/scripts/downgradator.lua
The Forgotten Server 0.2(Its not tested by me but should work):
Bye. :thumbup:
data/npc:
somenpc.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Somenpc" script="data/npc/scripts/downgradator.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="289" head="20" body="39" legs="45" feet="7" addons="3"/>
</npc>
The Forgotten Server 0.3:
data/npc/scripts/downgradator.lua
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local voc = {}
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
if(msgcontains(msg, 'reset') or msgcontains(msg, 'downgadate')) then
selfSay('Would you like to reset your level to 8 and switch vocation? It will cost you 3,000,000 gold coins and you will be kicked out of the game.', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if isPremium(cid) == TRUE then
if getPlayerLevel(cid) >= 350 then
if doPlayerRemoveMoney(cid, 3000000) == TRUE then
selfSay('Ok. Now tell me what vocation would you like to be?', cid)
talkState[talkUser] = 2
else
selfSay('Sorry, you don\'t have enough gold.', cid)
talkState[talkUser] = 0
end
else
selfSay('Only characters of level 350 or higher can be reseted.', cid)
talkState[talkUser] = 0
end
else
selfSay('Only premium account players may be reseted.', cid)
talkState[talkUser] = 0
end
elseif msgcontains(msg, 'sorcerer') and talkState[talkUser] == 2 then
voc[talkUser] = 1
selfSay('A sorcerer. Are you sure?', cid)
talkState[talkUser] = 3
elseif msgcontains(msg, 'druid') and talkState[talkUser] == 2 then
voc[talkUser] = 2
selfSay('A druid. Are you sure?', cid)
talkState[talkUser] = 3
elseif msgcontains(msg, 'paladin') and talkState[talkUser] == 2 then
voc[talkUser] = 3
selfSay('A oaladin. Are you sure?', cid)
talkState[talkUser] = 3
elseif msgcontains(msg, 'knight') and talkState[talkUser] == 2 then
voc[talkUser] = 4
selfSay('A knight. Are you sure?', cid)
talkState[talkUser] = 3
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 3 then
local name = getCreatureName(cid)
doRemoveCreature(cid)
db.executeQuery("UPDATE players SET level = 8, experience = 4200, vocation = "..voc[talkUser].." WHERE name ='"..name.."';")
elseif msgcontains(msg, 'no') and talkState[talkUser] == 3 then
selfSay('Well, you can either be a sorcerer, a druid, a paladin or a knight. Choose wisely.', cid)
talkState[talkUser] = 2
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Ok then.', cid)
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
The Forgotten Server 0.2(Its not tested by me but should work):
Code:
dofile("./config.lua")
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local voc = {}
local level = 150
local money = 3000000
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
if(msgcontains(msg, 'reset') or msgcontains(msg, 'downgadate')) then
selfSay('Would you like to reset your level to 8 and switch vocation? It will cost you '..money..' gold coins and you will be kicked out of the game.', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if isPremium(cid) == TRUE then
if getPlayerLevel(cid) >= level then
if doPlayerRemoveMoney(cid, money) == TRUE then
selfSay('Ok. Now tell me what vocation would you like to be?', cid)
talkState[talkUser] = 2
else
selfSay('Sorry, you don\'t have enough gold.', cid)
talkState[talkUser] = 0
end
else
selfSay('Only characters of level '..level..' or higher can be reseted.', cid)
talkState[talkUser] = 0
end
else
selfSay('Only premium account players may be reseted.', cid)
talkState[talkUser] = 0
end
elseif msgcontains(msg, 'sorcerer') and talkState[talkUser] == 2 then
voc[talkUser] = 1
selfSay('A sorcerer. Are you sure?', cid)
talkState[talkUser] = 3
elseif msgcontains(msg, 'druid') and talkState[talkUser] == 2 then
voc[talkUser] = 2
selfSay('A druid. Are you sure?', cid)
talkState[talkUser] = 3
elseif msgcontains(msg, 'paladin') and talkState[talkUser] == 2 then
voc[talkUser] = 3
selfSay('A paladin. Are you sure?', cid)
talkState[talkUser] = 3
elseif msgcontains(msg, 'knight') and talkState[talkUser] == 2 then
voc[talkUser] = 4
selfSay('A knight. Are you sure?', cid)
talkState[talkUser] = 3
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 3 then
if sqlType == "mysql" then
env = assert(luasql.mysql())
con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
else -- sqlite
env = assert(luasql.sqlite3())
con = assert(env:connect(sqliteDatabase))
end
local target = getPlayerGUID(cid)
doRemoveCreature(cid)
assert(con:execute("UPDATE players SET level = 8, experience = 4200, maglevel = 0, vocation = "..voc[talkUser].." WHERE id = "..target..";"))
assert(con:execute("UPDATE player_skills SET value = 10 WHERE skillid != 6 and player_id = "..target..";"))
--assert(con:execute("DELETE FROM player_storage WHERE player_id = "..target..";"))
con:close()
env:close()
elseif msgcontains(msg, 'no') and talkState[talkUser] == 3 then
selfSay('Well, you can either be a sorcerer, a druid, a paladin or a knight. Choose wisely.', cid)
talkState[talkUser] = 2
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Ok then.', cid)
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Bye. :thumbup:
Last edited: