Creaturescripts.xml
<event type="advance" name="PlayerAdvance" event="script" value="PlayerAdvance.lua"/>
login.lua
registerCreatureEvent(cid, "PlayerAdvance")
PlayerAvance.lua
function onAdvance(cid, skill, oldLevel, newLevel, time)
db.Query("INSERT INTO player_advances (cid, skill, oldlevel, newlevel, time) VALUES ('" .. getPlayerGUID(cid) .. "', '" .. skill .."', '" .. oldLevel .."', '" .. newLevel .."', '" .. os.time() .. "' )")
return true
end