Some comments to the code. function et_ClientSpawn calls getXP 9 times. getXP itself asks the game through the et_gentity_get To make it better, faster, less aggravating for the game store the XP locally and reuse it. For example:
function et_ClientSpawn( clientNum, revived, teamChange, restoreHealth )
local valXP = getXP(clientNum)
if valXP >= lvl1xp and valXP < lvl2xp then
setlevel(clientNum,1,lvl1xp)
elseif valXP >= lvl2xp and valXP < lvl3xp then
setlevel(clientNum,2,lvl2xp)
elseif valXP >= lvl3xp and valXP < lvl4xp then
setlevel(clientNum,3,lvl3xp)
elseif valXP >= lvl4xp and valXP < lvl5xp then
setlevel(clientNum,4,lvl4xp)
elseif valXP >= lvl5xp then
setlevel(clientNum,5,lvl5xp)
end
end