• 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.

TalkAction Reset System

Stewie

Family Guy # ;3
Joined
May 3, 2010
Messages
786
Reaction score
12
Location
TV
Reset System

Type: TalkAction
Version: TFS 0.3.6


I am bringing a system reset, so when you reset your skills, magic and items are the same, the HP / MANA will accumulate, so let's start.

Go data/talkaction and create a reset.lua and put this:

PHP:
function onSay(cid, words, param)
config = {
level=450, -- level necessary to reset.
RemainingLvl=8, -- that level will be reset after.
exper=4200, -- experience that will be reset after.
pid=getPlayerGUID(cid), 
skull="yes", -- players with white skull can reset? ("yes" or "no").
redskull="yes", -- players with red skull can reset? ("yes" or "no").
prot="yes", -- players need to be in protection zone to reset? ("yes" or "no").
bat="yes" --Players must be no fight to reset ("yes" or "no").
}

function getResets(cid)
reset = getPlayerStorageValue(cid,1020)
if reset < 0 then
reset = 0
end
return reset
end

if(config.skull == "no") and (getCreatureSkullType(cid) == 3) then
doPlayerSendTextMessage(cid,22,"only players without white skull can reset.")
return TRUE
end

if(config.redskull == "no") and (getCreatureSkullType(cid) == 4) then
doPlayerSendTextMessage(cid,22,"only player without red skull can reset.")
return TRUE
end

if(config.prot == "yes") and (getTilePzInfo(getCreaturePosition(cid)) == FALSE) then
doPlayerSendTextMessage(cid,22,"you need stay in PZ to reset.")
return TRUE
end

if(config.bat == "yes") and (getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
doPlayerSendTextMessage(cid,22,"players without battle can reset.")
return TRUE
end

if getPlayerLevel(cid) >= config.level then
setPlayerStorageValue(cid,1020,getResets(cid)+1)
doPlayerSetNameDescription(cid, " Have a "..getResets(cid)+(1).." reset\'s.")
doPlayerPopupFYI(cid,"you now was reset, you have "..getResets(cid)+(1).." reset\'s.")
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = "..config.RemainingLvl..", `experience` = "..config.exper.." WHERE `id` = "..config.pid)
else
doPlayerSendCancel(cid, "You need to have level "..config.level.." or more you may be reset.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end

return TRUE
end

Now go Talkacionts.xml and put this:

PHP:
<talkaction log="yes" words="!reset" access="0" event="script" value="reset.lua"/>

Credits: marcryzius 99%
Mraz 1%​
 
Last edited:
reset is reset, reset here means "reborn", reset is meant for all players.
like this;
Code:
local t = {
	skull = "yes",
	red = "yes",
	prot = "yes",
	bat = "yes",
	exp = 4200,
	lvl = 8,
	level = 450
}
t.skulls = getBooleanFromString(t.skulls)
t.red = getBooleanFromString(t.red)
t.prot = getBooleanFromString(t.prot)
t.bat = getBooleanFromString(t.bat)
function onSay(cid, words, param, channel)
	reset = 0
	c = {}
	for _, v in ipairs(getPlayersOnline()) do
		if #v > 0 and not t.skulls and not t.red and not t.prot and not t.bat and not getCreatureSkullType(v) >= 0 and getTilePzInfo(getThingPos(v)).protection and getPlayerLevel(cid) >= t.level and not getCreatureCondition(v, CONDITION_INFIGHT) then
			db.executeQuery("UPDATE `players` SET `level` = " .. t.lvl .. ", `experience` = " .. t.exp .." WHERE `id` = " .. getPlayerGUID(v))
			setmetatable(c, {__index = _G})
			setfenv(0, c)
			_G.v = _G.v
			_G.reset = _G.reset + 1
		else
			doPlayerSendTextMessage(cid, 27, "Theres no players online.")
			break
		end
	end
	return true
end
 
Code:
local function getStats(cid, __this)
	if __this == "health" then
		return isKnight(cid) and getPlayerLevel(cid) * 15 + 65 or isPaladin(cid) and getPlayerLevel(cid) * 10 + 105 or (isSorcerer(cid) or isDruid(cid)) and getPlayerLevel(cid) * 5 + 145
	elseif __this == "mana" then
		return isKnight(cid) and getPlayerLevel(cid) * 5 - 5 or isPaladin(cid) and getPlayerLevel(cid) * 15 - 85 or (isSorcerer(cid) or isDruid(cid)) and getPlayerLevel(cid) * 30 - 205
	end
end

local t = {
	skull = "yes",
	red = "yes",
	prot = "yes",
	bat = "yes",
	exp = 4200,
	lvl = 8,
	level = 450
}
t.skulls = getBooleanFromString(t.skulls)
t.red = getBooleanFromString(t.red)
t.prot = getBooleanFromString(t.prot)
t.bat = getBooleanFromString(t.bat)
function onSay(cid, words, param, channel)
	reset = 0
	c = {}
	for _, v in ipairs(getPlayersOnline()) do
		if #v > 0 and not t.skulls and not t.red and not t.prot and not t.bat and not getCreatureSkullType(v) >= 0 and getTilePzInfo(getThingPos(v)).protection and getPlayerLevel(cid) >= t.level and not getCreatureCondition(v, CONDITION_INFIGHT) then
			db.executeQuery("UPDATE `players` SET `level` = " .. t.lvl .. ", `experience` = " .. t.exp .." WHERE `id` = " .. getPlayerGUID(v)
			setCreatureMaxHealth(cid, getStats(cid, "health"))
			setCreatureMaxMana(cid, getStats(cid, "mana"))
			doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid), false)
			doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid), false)
			setmetatable(c, {__index = _G})
			setfenv(0, c)
			_G.v = _G.v
			_G.reset = _G.reset + 1
		else
			doPlayerSendTextMessage(cid, 27, "Theres no players online.")
			break
		end
	end
	return true
end
 
Code:
local function getStats(cid, __this)
	if __this == "health" then
		return isKnight(cid) and getPlayerLevel(cid) * 15 + 65 or isPaladin(cid) and getPlayerLevel(cid) * 10 + 105 or (isSorcerer(cid) or isDruid(cid)) and getPlayerLevel(cid) * 5 + 145
	elseif __this == "mana" then
		return isKnight(cid) and getPlayerLevel(cid) * 5 - 5 or isPaladin(cid) and getPlayerLevel(cid) * 15 - 85 or (isSorcerer(cid) or isDruid(cid)) and getPlayerLevel(cid) * 30 - 205
	end
end

local t = {
	skull = "yes",
	red = "yes",
	prot = "yes",
	bat = "yes",
	exp = 4200,
	lvl = 8,
	level = 450
}
t.skulls = getBooleanFromString(t.skulls)
t.red = getBooleanFromString(t.red)
t.prot = getBooleanFromString(t.prot)
t.bat = getBooleanFromString(t.bat)
function onSay(cid, words, param, channel)
	reset = 0
	c = {}
	for _, v in ipairs(getPlayersOnline()) do
		if #v > 0 and not t.skulls and not t.red and not t.prot and not t.bat and not getCreatureSkullType(v) >= 0 and getTilePzInfo(getThingPos(v)).protection and getPlayerLevel(cid) >= t.level and not getCreatureCondition(v, CONDITION_INFIGHT) then
			db.executeQuery("UPDATE `players` SET `level` = " .. t.lvl .. ", `experience` = " .. t.exp .." WHERE `id` = " .. getPlayerGUID(v)
			setCreatureMaxHealth(cid, getStats(cid, "health"))
			
                        doPlayerSetNameDescription(cid, " Have a "..getResets(cid)+(1).." reset\'s.") 
                        setCreatureMaxMana(cid, getStats(cid, "mana"))
			doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid), false)
			doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid), false)
			setmetatable(c, {__index = _G})
			setfenv(0, c)
			_G.v = _G.v
			_G.reset = _G.reset + 1
		else
			doPlayerSendTextMessage(cid, 27, "Theres no players online.")
			break
		end
	end
	return true
end

add name description
 
Code:
local function getStats(cid, __this)
	if __this == "health" then
		return isKnight(cid) and getPlayerLevel(cid) * 15 + 65 or isPaladin(cid) and getPlayerLevel(cid) * 10 + 105 or (isSorcerer(cid) or isDruid(cid)) and getPlayerLevel(cid) * 5 + 145
	elseif __this == "mana" then
		return isKnight(cid) and getPlayerLevel(cid) * 5 - 5 or isPaladin(cid) and getPlayerLevel(cid) * 15 - 85 or (isSorcerer(cid) or isDruid(cid)) and getPlayerLevel(cid) * 30 - 205
	end
end

local t = {
	skull = "yes",
	red = "yes",
	prot = "yes",
	bat = "yes",
	exp = 4200,
	lvl = 8,
	level = 450
}
t.skulls = getBooleanFromString(t.skulls)
t.red = getBooleanFromString(t.red)
t.prot = getBooleanFromString(t.prot)
t.bat = getBooleanFromString(t.bat)
function onSay(cid, words, param, channel)
	reset = 0
	c = {}
	for _, v in ipairs(getPlayersOnline()) do
		if #v > 0 and not t.skulls and not t.red and not t.prot and not t.bat and getPlayerLevel(v) >= t.level then
			db.executeQuery("UPDATE `players` SET `level` = " .. t.lvl .. ", `experience` = " .. t.exp .." WHERE `id` = " .. getPlayerGUID(v))
			setCreatureMaxHealth(v, getStats(v, "health"))
			setCreatureMaxMana(v, getStats(v, "mana"))
			doCreatureAddHealth(v, getCreatureMaxHealth(v) - getCreatureHealth(v), false)
			doCreatureAddMana(v, getCreatureMaxMana(v) - getCreatureMana(v), false)
			setmetatable(c, {__index = _G})
			setfenv(0, c)
			_G.v = _G.v
			reset = reset + #v
		else
			doPlayerSendTextMessage(cid, 27, "Theres no players online.")
			break
		end
	end
	return true
end
fixed =_=
 
Last edited:
Xeon, you are so much like Cykotitan, it's creepy. You even use his local's.

:blink:
 
Xeon, you are so much like Cykotitan, it's creepy. You even use his local's.

:blink:
do u even know whats lua.org?
i have never seen cykotitan using indexs this way
if ur talking about the locals i answered ur question ^ above
anyways, i have seen u a few times using the same 'locals' too :)
 
Last edited:
I think you should instead do a script for GM's which will reset player levels, skills, items, storages, cap, everything... That will be usefull, cuz I usually need to trunkate all that stuff, but resetting would be nicer.
 
Back
Top