Something I've written ad-hoc to handle your case:
LVL1 = 3
LVL2 = 4
LVL3 = 5
LVL4 = 6
function et_ClientSpawn(clientNum, revived, teamChange, restoreHealth)
local valXP = getXP(clientNum)
local level = et.G_shrubbot_level( clientNum );
if level == LVL1 then
if valXP >= lvl2xp and valXP < lvl3xp then
setlevel(clientNum,2,lvl2xp)
end
elseif level == LVL2 then
if valXP >= lvl3xp and valXP < lvl4xp then
setlevel(clientNum,3,lvl3xp)
end
elseif level == LVL3 then
if valXP >= lvl4xp and valXP < lvl5xp then
setlevel(clientNum,4,lvl4xp)
end
end
endLVL1 .. LVL4 are levels you want to handle, only for those levels xp check will be done. The code inside
if level == LVL1 thenis up to you, here is the behavior I would want, which is: check if the xp is of the higher level and if it is, give the higher level. Not tested.