• 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:
You can try using doPlayerAddLevel(cid, level) by subtracting levels entirely.

Edit: For a war server, I would suggest implementing this feature by editing the sources of the server.
 
Last edited:
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 I think this is actually working, the only problem im having now is it is not reseting back to 85 for example, i was 88 lost 5 lvls and now im 83
 
I'm testing it at the moment, it does seem to work in a way.
It is correctly setting the level, but it is also adding EXP deathloss on top of that; it also has some kind of weird saving issue.

I had this work in my war server a long time ago (8.6 too), I just can't remember what I did nor can find my server...
 
I'm testing it at the moment, it does seem to work in a way.
It is correctly setting the level, but it is also adding EXP deathloss on top of that; it also has some kind of weird saving issue.

I had this work in my war server a long time ago (8.6 too), I just can't remember what I did nor can find my server...

Yeah, I remember something like this happening with 0.3.6. There is more than one function that "almost works." <_<
 
Yeah, I remember something like this happening with 0.3.6. There is more than one function that "almost works." <_<

0.3 is bugged beyond all repair.

I'm glad TFS team is working tirelessly to make 0.2 compatible with 0.3 datapacks. Then we can get rid of 0.3 altogether.

As for this thread topic in particular, I have no solution at the moment. It is getting late for me.
My guess is that you use SQL queries and update the database.
 
Ive got the script working, but now my level rebalance isnt working... It wont stop at 85 etc, it goes under..
But its taking the lvls right now

I need you to test it using a different level. Okay?

*EDIT-1*: Or, you can try to disable deathloss in your config.lua by setting it to 0, then giving my first script another test.
*EDIT-2*:
Lua:
function onDeath(cid, corpse, deathList)
    local k, a = getPlayerLevel(cid), math.ceil(getPlayerLevel(cid))
    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 = a-1
    until a/5 == math.floor(a/5)
    doPlayerAddExperience(cid, (getExperienceForLevel(a) - getPlayerExperience(cid)))
end
 
Last edited:
PHP:
function onLogin(cid)
local rebalanceStor = getPlayerStorageValue(cid, 37454)

	if rebalanceStor == -1 and getPlayerLevel(cid) >= 90 then
        doPlayerAddExperience(cid, (getExperienceForLevel(90) - getPlayerExperience(cid)))
	setPlayerStorageValue(cid, 37454, 1)

	elseif rebalanceStor == -1 and getPlayerLevel(cid) > 85 and getPlayerLevel(cid) < 85 then
	doPlayerAddExperience(cid, (getExperienceForLevel(85) - getPlayerExperience(cid)))
	setPlayerStorageValue(cid, 37454, 1)

	elseif rebalanceStor == -1 and getPlayerLevel(cid) < 80 then
	doPlayerAddExperience(cid, (getExperienceForLevel(80) - getPlayerExperience(cid)))
	setPlayerStorageValue(cid, 37454, 1)
	
	else setPlayerStorageValue(cid, 37454, 1)

end
return TRUE
end
.
Well its auto-blessed, also it took away dead bodies, when i kill someone it just disappears (which is fine) the -5 script is working perfect, its just my levelrebalance script that is not working now.
 
Lua:
function onDeath(cid, corpse, deathList)
    local x, y = 0, 0
    local z = 0
	local ntable = {}
	local l = getPlayerLevel(cid)
	for n = 1, 717217 do
            if n/5 == math.floor(n/5) then
	        table.insert(ntable, n)
            end
	end
    for i = 1, table.maxn(ntable) do
	    x = n-5
		y = n+5
		z = n
		local t = {
	    [{x, y}] = z
	    }
        for level, k in pairs(t) do
            if(isInArray(level, getPlayerLevel(cid)) and getPlayerLevel(cid) > k) then
                doPlayerAddExperience(cid, (getExperienceForLevel(k) - getPlayerExperience(cid)))
				break
            end
        end
	end
    return true
end
 
Last edited:
Lua:
function onDeath(cid, corpse, deathList)
    local x, y = 0, 0
    local z, n = 0, 0
	local ntable = {}
	local l = getPlayerLevel(cid)
	for 1, 717217 do
	    n = n+1
		if n/5 == math.floor(n/5) then
		    table.insert(ntable, n)
		end
	end
    for 1, table.maxn(ntable) do
	    x = n-5
		y = n+5
		z = n
		local t = {
	    [{x, y}] = z
	    }
        for level, k in pairs(t) do
            if(isInArray(level, getPlayerLevel(cid)) and getPlayerLevel(cid) > k) then
                doPlayerAddExperience(cid, (getExperienceForLevel(k) - getPlayerExperience(cid)))
				break
            end
        end
	end
    return true
end

This should go in levelrebalance right? Or is this a new script for the level relock

[22/05/2013 20:51:49] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/levelrebalance.lua:6: '<name>' expected near '1'
[22/05/2013 20:51:49] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/levelrebalance.lua)
[22/05/2013 20:51:49] data/creaturescripts/scripts/levelrebalance.lua:6: '<name>' expected near '1'
 
Last edited:
Lua:
function onDeath(cid, corpse, deathList)
    local x, y = 0, 0
    local z = 0
	local ntable = {}
	local l = getPlayerLevel(cid)
	for n = 1, 717217 do
            if n/5 == math.floor(n/5) then
	        table.insert(ntable, n)
            end
	end
    for i = 1, table.maxn(ntable) do
	    x = n-5
		y = n+5
		z = n
		local t = {
	    [{x, y}] = z
	    }
        for level, k in pairs(t) do
            if(isInArray(level, getPlayerLevel(cid)) and getPlayerLevel(cid) > k) then
                doPlayerAddExperience(cid, (getExperienceForLevel(k) - getPlayerExperience(cid)))
				break
            end
        end
	end
    return true
end


Try it again.
 
Try it again.

When I died I got this error

[22/05/2013 20:57:50] [Error - CreatureScript Interface]
[22/05/2013 20:57:50] data/creaturescripts/scripts/direct.lua:eek:nDeath
[22/05/2013 20:57:50] Description:
[22/05/2013 20:57:50] data/creaturescripts/scripts/direct.lua:12: attempt to perform arithmetic on global 'n' (a nil value)
[22/05/2013 20:57:50] stack traceback:
[22/05/2013 20:57:50] data/creaturescripts/scripts/direct.lua:12: in function <data/creaturescripts/scripts/direct.lua:1>
 
Try this:
Lua:
function onDeath(cid, corpse, deathList)
    local x, y = 0, 0
    local z, n = 0, 0
	local ntable = {}
	local l = getPlayerLevel(cid)
	for y = 1, 717217 do
            n=n+1
            if n/5 == math.floor(n/5) then
	        table.insert(ntable, n)
            end
	end
    for i = 1, table.maxn(ntable) do
	    x = n-5
		y = n+5
		z = n
		local t = {
	    [{x, y}] = z
	    }
        for level, k in pairs(t) do
            if(isInArray(level, getPlayerLevel(cid)) and getPlayerLevel(cid) > k) then
                doPlayerAddExperience(cid, (getExperienceForLevel(k) - getPlayerExperience(cid)))
				break
            end
        end
	end
    return true
end
 
Back
Top