• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC Reseting one.

EvulMastah

๏̯͡๏﴿
Premium User
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
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:
looks nice looks like a good idea ;p except for the knight using sds part =S
 
looks nice looks like a good idea ;p except for the knight using sds part =S

Well, I figured this out, so I updated it for myself to reset all skills except fishing and magic level ;p

Here is the fix/update/edit/w.e:
replace from local name = ...
Code:
                local target = getPlayerGUID(cid)
		doRemoveCreature(cid)
		db.executeQuery("UPDATE players SET level = 8, experience = 4200, maglevel = 0, vocation = "..voc[talkUser].." WHERE id = "..target..";")
		db.executeQuery("UPDATE player_skills SET value = 10 WHERE skillid != 6 and player_id = "..target..";")
		--db.executeQuery("DELETE FROM player_storage WHERE player_id = "..target..";")

Reseting storage values is commented (disabled) because player will lose addons too, I might fix it later, but I prefer to keeps the quests done always done.

Ciao~
 
Can you make this for 0.2?
I'd like to have this man.

Question:
Players who change from a sorcerer to a knight.
They dont keep their magic levels do they?
A knight with ml 85 is crazy...
 
Code:
[31/10/2008  21:19:52] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/downgradator.lua
[31/10/2008  21:19:52] data/npc/scripts/downgradator.lua:51: '<eof>' expected near 'end'

Not work.... on TFS 0.3 ap3
 
Can you make this for 0.2?
I'd like to have this man.

Question:
Players who change from a sorcerer to a knight.
They dont keep their magic levels do they?
A knight with ml 85 is crazy...

Yea, all the skills are reseted to default ones.

Code:
[31/10/2008  21:19:52] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/downgradator.lua
[31/10/2008  21:19:52] data/npc/scripts/downgradator.lua:51: '<eof>' expected near 'end'

Not work.... on TFS 0.3 ap3

Someone here doesnt know how to use copy/paste...
 
thats pretty sweet, could you possibly make it for tfs 0.2? thanks
 
Working!!:)
Thanks.....

PS: I not like of choose vocation :(

Edit...
I edited you code, now working whitout choose the vocations.
 
Last edited:
[21/12/2008 18:54:46] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/reset.lua
[21/12/2008 18:54:46] data/npc/scripts/reset.lua:68: ')' expected (to close '(' at line 67) near 'assert'

help? use TFS 0.2
 
Code:
		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..";")

=>
Code:
		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..";"))
 
[21/12/2008 19:12:52] Lua Script Error: [Npc interface]
[21/12/2008 19:12:52] data/npc/scripts/reset.lua:eek:nCreatureSay

[21/12/2008 19:12:52] data/npc/scripts/reset.lua:62: attempt to call field 'sqlite3' (a nil value)
[21/12/2008 19:12:52] stack traceback:
[21/12/2008 19:12:52] data/npc/scripts/reset.lua:62: in function 'callback'
[21/12/2008 19:12:52] data/npc/lib/npcsystem/npchandler.lua:374: in function 'onCreatureSay'
[21/12/2008 19:12:52] data/npc/scripts/reset.lua:12: in function <data/npc/scripts/reset.lua:12>

i used mySql, have problem?
 
Well, I dont see any reason why it should not work, try copying it again from the first page, make sure you copy whole script.
 
OMG! THIS MY PROBLEM
-- SQL
sqlType = "mySql"
passwordType = "plain"

and edited

-- SQL
sqlType = "mysql"
passwordType = "plain"

and perfect 100% function

[EDIT]
Marcinek, help-me.
I need add in table Players Reset +1.
I create reset in table players.
 
Last edited:
PHP:
assert(con:execute("UPDATE players SET reset = reset + 1 WHERE id = "..target..";")

Add it where the other ones are :)
 
Last edited:
Modded the script extremely little, this is working on TFS 0.3.6 :)
Instead of letting you change the vocation, it will just put you to lvl 8 and keep all skills. :)
+rep to EvulMastah for creating this awsome script!! :D

Lua:
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, 'downgrade')) then
		selfSay('Would you like to reset your level to 8? You will keep all your skills and magic level. This action will cost you 300 Crystal Coins and you will be kicked out of the game.', cid)
		selfSay('After you get kicked please press escape and login again or you will just loose your money', 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

					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

		local name = getCreatureName(cid)
		doRemoveCreature(cid)
		db.executeQuery("UPDATE players SET level = 8, experience = 4200 WHERE name ='"..name.."';")
		--db.executeQuery("DELETE FROM player_storage WHERE player_id = "..target..";")
	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())
 
Back
Top