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

Solved Level Rebalance Script

hallabackkid101

New Member
Joined
Feb 7, 2009
Messages
100
Reaction score
0
Location
Georgia, Usa
I'm not sure if this is the correct place to post this but ill try anyways, I'm looking for a script for when i player dies he goes back to a specific lvl. For example, If i'm lvl 84 and I die, I will be put back at 80, or if I would have past next first 5 lvls and i was 87 it would go back to 85. I hope you guys can understand that xD :D Thanks
 
Last edited:
If the player is between level 1 and 9 -- but above level 5 [k] -- and this player dies, he will be returned to level 5 [k], otherwise it will have no affect on the player.

data/creaturescripts/scripts/script.lua


Lua:
local t = {
-- [The players level] = new level upon death
	[{1, 9}] = 5,
	[{10, 19}] = 15,
	[{20, 29}] = 25
}

function onDeath(cid, corpse)
	for level, k in pairs(t) do
		if(isInArray(level, getPlayerLevel(cid)) and getPlayerLevel(cid) > k) then
			doPlayerAddExperience(cid, (getExperienceForLevel(k) - getPlayerExperience(cid)))
		end
	end
	return true
end
 
Last edited:
If the player is between level 1 and 9 -- but above level 5 [k] -- and this player dies, he will be returned to level 5 [k], otherwise it will have no affect on the player.

data/creaturescripts/scripts/script.lua

Lua:
local t = {
-- [The players level] = new level upon death
	[{1, 9}] = 5,
	[{10, 19}] = 15,
	[{20, 29}] = 25
}

function onDeath(cid, corpse, deathList)
	for level, k in pairs(t) do
		if(isInArray(level, getPlayerLevel(cid)) and getPlayerLevel(cid) > k) then
			doPlayerAddExperience(cid, (getExperienceForLevel(k) - getPlayerExperience(cid)))
		end
	end
	return true
end


Ok this is all I have as of now. I was just looking to see if anyone had one. I don't know much about creating scripts, just editing them. I tryed working with the script above but can't seem to get it to work. What do you mean "k"? like level 1000?
 
Lua:
function onDeath(cid, corpse, deathList)
    local k, a = getPlayerLevel(cid), 0
    local to, zt = {}, {}
    for n = 0, 717217 do
	if n/5 ~= math.floor(n/5) then
	    table.insert(to, n)
	else
            table.insert(zt, n)
        end
    end
    repeat
	a = math.ceil(k)
        k = k-1
    until a/5 == math.floor(a/5)
    doPlayerAddExperience(cid, (getExperienceForLevel(a) - getPlayerExperience(cid)))
end

I kinda fucked up hard on this one. Do test it and tell me what happens, I'll try to fix it if it's not working properly.
 
Ok this is all I have as of now. I was just looking to see if anyone had one. I don't know much about creating scripts, just editing them. I tryed working with the script above but can't seem to get it to work. What do you mean "k"? like level 1000?

It's a variable in the script referring to the level that the player returns to upon death. You don't have to worry about that, just change the levels in the table and it should work fine.
 
It's a variable in the script referring to the level that the player returns to upon death. You don't have to worry about anything, just change the levels in the table and it should work fine.

The problem about your script is that you have to add more lines for every 10 levels, and they aren't doing what he wants properly. He wants it like this... In the range of 10 levels, for example from 10 to 20, if you are less than 15 then when you die you become 10, if you are more than 15 when you die you become 15. Get it?
 
The problem about your script is that you have to add more lines for every 10 levels, and they aren't doing what he wants properly. He wants it like this... In the range of 10 levels, for example from 10 to 20, if you are less than 15 then when you die you become 10, if you are more than 15 when you die you become 15. Get it?

I am quite aware of what he wants.
 
I just thought he wanted a bookmark at every 5 levels.
Which is why I came up with that formula in my post: math.floor(getPlayerLevel / 5) * 5

math.floor(87 / 5) = 17, then 17 * 5 = 85
math.floor(92 / 5) = 18, then 18 * 5 = 90
math.floor(24 / 5) = 4, then 4 * 5 = 20
 
I just thought he wanted a bookmark at every 5 levels.
Which is why I came up with that formula in my post: math.floor(getPlayerLevel / 5) * 5

math.floor(87 / 5) = 17, then 17 * 5 = 85
math.floor(92 / 5) = 18, then 18 * 5 = 90
math.floor(24 / 5) = 4, then 4 * 5 = 20

That will work fine as well, he needs it to be written for him apparently.
I'll do that.
 
So for example I want this to occur starting at 80. Is this correct?

PHP:
local t = {
-- [The players level] = new level upon death
	[{80, 90}] = 85,
	[{90, 100}] = 95,
	[{100, 110}] = 105
}
 
function onDeath(cid, corpse, deathList)
	for level, k in pairs(t) do
		if(isInArray(level, getPlayerLevel(cid)) and getPlayerLevel(cid) > k) then
			doPlayerAddExperience(cid, (getExperienceForLevel(k) - getPlayerExperience(cid)))
		end
	end
	return true
end

- - - Updated - - -

Lua:
function onDeath(cid, corpse, deathList)
    local k, a = getPlayerLevel(cid), 0
    local to, zt = {}, {}
    for n = 0, 717217 do
	if n/5 ~= math.floor(n/5) then
	    table.insert(to, n)
	else
            table.insert(zt, n)
        end
    end
    repeat
	a = math.ceil(k)
        k = k-1
    until a/5 == math.floor(a/5)
    doPlayerAddExperience(cid, (getExperienceForLevel(a) - getPlayerExperience(cid)))
end

I kinda fucked up hard on this one. Do test it and tell me what happens, I'll try to fix it if it's not working properly.

I used it and I put my character at lvl 87, and it only went back to 86
 
So for example I want this to occur starting at 80. Is this correct?

PHP:
local t = {
-- [The players level] = new level upon death
	[{80, 90}] = 85,
	[{90, 100}] = 95,
	[{100, 110}] = 105
}
 
function onDeath(cid, corpse, deathList)
	for level, k in pairs(t) do
		if(isInArray(level, getPlayerLevel(cid)) and getPlayerLevel(cid) > k) then
			doPlayerAddExperience(cid, (getExperienceForLevel(k) - getPlayerExperience(cid)))
		end
	end
	return true
end

- - - Updated - - -



I used it and I put my character at lvl 87, and it only went back to 86

Use this, it's based on Evan's formula.

Lua:
function onDeath(cid, corpse, deathList)
    local newlevel = (math.floor(getPlayerLevel(cid) / 5) * 5)
	if getPlayerLevel(cid) > 80 then
	    doPlayerAddExperience(cid, (getExperienceForLevel(newlevel) - getPlayerExperience(cid)))
	end
 	return true
end
 
You can add as many combinations as you like, the list is not limited to three.

Alright this is what I have now

local t = {
-- [The players level] = new level upon death
[{80, 85}] = 80,
[{85, 90}] = 85,
[{90, 95}] = 90
}

function onDeath(cid, corpse, deathList)
for level, k in pairs(t) do
if(isInArray(level, getPlayerLevel(cid)) and getPlayerLevel(cid) > k) then
doPlayerAddExperience(cid, (getExperienceForLevel(k) - getPlayerExperience(cid)))
end
end
return true
end

Its wont work for me, I was lvl 88 and it took me back to 87

- - - Updated - - -

Use this, it's based on Evan's formula.

Lua:
function onDeath(cid, corpse, deathList)
    local newlevel = (math.floor(getPlayerLevel(cid) / 5) * 5)
	if getPlayerLevel(cid) > 80 then
	    doPlayerAddExperience(cid, (getExperienceForLevel(newlevel) - getPlayerExperience(cid)))
	end
 	return true
end

Evans didn't work either. It just keeps taking me back one level on all the scripts ive tried.
 
Back
Top