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

Do something when level up?

Code:
function onAdvance(cid, skill, oldLevel, newLevel)
	if (skill == SKILL__LEVEL and newLevel > oldLevel) then
		doPlayerAddItem(cid, 2152, 10)
	end
	return true
end
 
creaturescripts.xml
<event type="advance" name="LevelUp" event="script" value="levelup.lua"/>

levelup.lua
function onAdvance(cid, skill, oldLevel, newLevel)
if (skill == SKILL__LEVEL and newLevel > oldLevel) then
doPlayerAddItem(cid, 2152, 10)
doSendAnimatedText(getCreaturePosition(cid), "[LEVEL UP]", TEXTCOLOR_GOLD)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYDAMAGE)
end
return true
end

login.lua
registerCreatureEvent(cid, "LevelUp")

Crashed my server, what did I do wrong? ;p

EDIT:Nvm, works now, thanks! :)
 
Try using this
Code:
function onAdvance(cid, newLevel)
local playerPos = getCreaturePosition(cid)
    if newLevel == SKILL__LEVEL then
        doSendMagicEffect(playerPos, CONST_ME_HOLYDAMAGE)
        doPlayerAddItem(cid, 2152, 10)
        doSendAnimatedText(getCreaturePosition(cid), "[LEVEL UP]", TEXTCOLOR_GOLD)
    end
    return TRUE
end
 
Back
Top Bottom