• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Creaturescripts -> Full HP & Mana when level up!

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,855
Solutions
18
Reaction score
671
I need to make an 2 scripts:

1)
- If you level up your hp & mana are restore to 100%
- You and other players got an textmessage above your head: Level Up!

2)
- If you magic up your mana are restore to 100%
- You and other players got an textmessage above your head: Magic Up!


Rep++,
thx above.:peace:
 
Hello, you can try this.
in login.lua add
LUA:
registerCreatureEvent(cid,'lvlup')
in creature scripts add
LUA:
<event type="advance" name="lvlup" event="script" value="lvlup.lua"/>
and make a file in creaturescript/scripts named lvlup.lua and paste this in it.
LUA:
function onAdvance(cid, skill, oldlevel, newlevel)
local pos = getCreaturePosition(cid)
if skill == SKILL__LEVEL then
	doPlayerAddHealth(cid,getCreatureMaxHealth(cid))
	doPlayerAddMana(cid,getCreatureMaxMana(cid))
	doSendAnimatedText(pos, "Level Up!", 18)
elseif skill == SKILL__MAGLEVEL then
	doPlayerAddMana(cid,getCreatureMaxMana(cid)-getCreatureMana(cid))
	doSendAnimatedText(pos, "Magic Up!", 180)
end
return true
end
not tested but should work for the 2 scripts you wanted.

sorry for bad english.
 
Last edited:
[10/07/2010 12:31:58] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/lvlup.lua:13: 'end' expected (to close 'function' at line 1) near '<eof>'
[10/07/2010 12:31:58] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/lvlup.lua)
[10/07/2010 12:31:58] data/creaturescripts/scripts/lvlup.lua:13: 'end' expected (to close 'function' at line 1) near '<eof>'
[10/07/2010 12:31:58] Reloaded creature events.

Dude It gives this error.
 
Last edited:
Im using this and works perfectly
-- Credits: Synthetic @ OTFans & OTLand

function onAdvance(cid, skill, oldlevel, newlevel)
local pPos = getPlayerPosition(cid)
if skill == 8 then
doSendAnimatedText(pPos, "Level Up", 210)
doSendMagicEffect(pPos, 28)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
doCreatureAddMana(cid, getCreatureMaxMana(cid))
end
return TRUE
I hope this will help.
 
I made a mod version of it here:
LUA:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Level Up" version="1.0" author="Hakeee" contact="otland.net" enabled="yes">
<event type="login" name="reglvlup" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid,'lvlup')
return true
end
]]></event>
<event type="advance" name="lvlup" event="script"> <![CDATA[
function onAdvance(cid, skill, oldlevel, newlevel)
local pos = getCreaturePosition(cid)
if skill == SKILL__LEVEL then
	doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
	doCreatureAddMana(cid, getCreatureMaxMana(cid)) 
	doSendAnimatedText(pos, "Level Up!", 18)
elseif skill == SKILL__MAGLEVEL then
	doCreatureAddMana(cid, getCreatureMaxMana(cid)) 
	doSendAnimatedText(pos, "Magic Up!", 180)
end
end
]]></event>
</mod>
its just to make a file in mod folder and name it to something. the filename doesnt change anything
or in you dont want mod
add in login.lua
LUA:
registerCreatureEvent(cid,'lvlup')
in creature scripts add
LUA:
<event type="advance" name="lvlup" event="script" value="lvlup.lua"/>
and make a file in creaturescript/scripts named lvlup.lua and paste this in it.
LUA:
function onAdvance(cid, skill, oldlevel, newlevel)
local pos = getCreaturePosition(cid)
if skill == SKILL__LEVEL then
	doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
	doCreatureAddMana(cid, getCreatureMaxMana(cid)) 
	doSendAnimatedText(pos, "Level Up!", 18)
elseif skill == SKILL__MAGLEVEL then
	doCreatureAddMana(cid, getCreatureMaxMana(cid)) 
	doSendAnimatedText(pos, "Magic Up!", 180)
end
end
 
Last edited:
wesoly, what are you talking about?
When i used the first script it gave error.
I was just indicated it.

yea you are right, my english isnt good? so what?
 
[10/07/2010 12:31:58] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/lvlup.lua:13: 'end' expected (to close 'function' at line 1) near '<eof>'
[10/07/2010 12:31:58] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/lvlup.lua)
'end' expected (to close 'function' at line 1) near '<eof>'
Transalate this and you will know whats the error. It is a little mistake which everybody should know how to fix it instead of writing posts 'doesn't work', 'errors', 'your script sux' :/ ...
 
firstly it's not my script and secondly when you fix "end", script still doesnt work. it doesnt give error but when you level up you mana and health dont be full!
 
Back
Top