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

Level Rollback onDeath

hallabackkid101

New Member
Joined
Feb 7, 2009
Messages
100
Reaction score
0
Location
Georgia, Usa
Hello guys, Im trying to find a script for when a player dies, he is set back to a certain level. For example, Im level 88 and die, I want it to go back to 85. The table below is an example

If a player is 84 or below, go back to 80
If a player is 85-89, go back to 85
90-94
95-99
Etc.


Can someone help?
 
Try this
Lua:
local levelTable = {
	[80] = {maxLvl = 84, toLvl = 80},
	[85] = {maxLvl = 89, toLvl = 85},
	[90] = {maxLvl = 94, toLvl = 90}	
}

function onPrepareDeath(cid, deathList)
	for k, v in pairs(levelTable) do
		local level = getPlayerLevel(cid)
		if(level >= k and level <= v[1]) then
			local difference = level-v[2]
			doPlayerAddLevel(cid, -difference)
			break
		end
	end
	return true
end
 
Try this
Lua:
local levelTable = {
	[80] = {maxLvl = 84, toLvl = 80},
	[85] = {maxLvl = 89, toLvl = 85},
	[90] = {maxLvl = 94, toLvl = 90}	
}

function onPrepareDeath(cid, deathList)
	for k, v in pairs(levelTable) do
		local level = getPlayerLevel(cid)
		if(level >= k and level <= v[1]) then
			local difference = level-v[2]
			doPlayerAddLevel(cid, -difference)
			break
		end
	end
	return true
end

I get an error, and it also sends my character back to level one, also had to change "preparedeath" to "death", was sending numerous errors in my server engine.



[28/05/2013 08:40:24] [Error - CreatureScript Interface]
[28/05/2013 08:40:24] data/creaturescripts/scripts/levelrebalance.lua:eek:nDeath
[28/05/2013 08:40:24] Description:
[28/05/2013 08:40:24] data/creaturescripts/scripts/levelrebalance.lua:10: attempt to compare number with nil
[28/05/2013 08:40:24] stack traceback:
[28/05/2013 08:40:24] data/creaturescripts/scripts/levelrebalance.lua:10: in function <data/creaturescripts/scripts/levelrebalance.lua:7>
 
Maybe this, I think I messed up the table, I forget how to do it the way I tried xD I'll have to look it up

Lua:
local levelTable = {
	-- 	Max Level, To Level
	[80] = {84, 80},
	[85] = {89, 85},
	[90] = {94, 90}	
}
 
function onPrepareDeath(cid, deathList)
	for k, v in pairs(levelTable) do
		local level = getPlayerLevel(cid)
		if(level >= k and level <= v[1]) then
			local difference = level-v[2]
			doPlayerAddLevel(cid, -difference)
			break
		end
	end
	return true
end

Unless getPlayerLevel(cid) isn't a valid function in your version? xD I thought it was a pretty common function though
 
problem is in dchampag's script
jd5aC.png
 
problem is in dchampag's script
jd5aC.png

I fixed my script in later post?

- - - Updated - - -

Lets try this

Lua:
local levelTable = {
	-- 	Max Level, To Level
	[80] = {84, 80},
	[85] = {89, 85},
	[90] = {94, 90}	
}
 
function onPrepareDeath(cid, deathList)
	for k, v in pairs(levelTable) do
		local level = getPlayerLevel(cid)
		if(level >= k and level <= v[1]) then
			local difference = level-v[2]
			if(difference > 0) then
				doPlayerAddLevel(cid, -difference)
			end
			break
		end
	end
	return true
end
 
Back
Top