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

Lua Easy script doesn't work

Fiodor

Lua & Maps
Joined
Mar 14, 2009
Messages
400
Reaction score
10
Location
Poland
I want to make a script: when someone advances in level, script gives him full mana and hp. Simple script and I don't know why it doesn't work. When advance --> nothing happens. Creaturescript ofc

Tibia : 8.5
Engine : TFS 0.3.5PL1
Code:
function onAdvance(cid, fromPosition, toPosition, oldlevel, newlevel)
local ppos = getPlayerPosition(cid)
doSendMagicEffect(ppos, CONST_ME_BIGCLOUDS)
doCreatureAddHealth(cid, 9999)
doPlayerAddMana(cid, 9999)
end

TIA
 
from TFS 0.3.5PL1 sources
//onAdvance(cid, skill, oldLevel, newLevel)
and I think skill == 8 = level
have fun.
 
Last edited:
You mean change
function onAdvance(cid, fromPosition, toPosition, oldlevel, newlevel)

to
function onAdvance(cid, skill, oldLevel, newLevel)
?
 
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
local ppos = getPlayerPosition(cid)
      if skill == 8 then
         doSendMagicEffect(ppos, CONST_ME_BIGCLOUDS)
         doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
         doPlayerAddMana(cid, getPlayerMaxMana(cid))
      end
      return TRUE
end
 
Last edited:
Just to know.. why anyone would like to use something like newLevel = oldLevel+1 or newLevel = newLevel? and if it is a funserver high rate players can up more than 1 level at once....
 
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
local ppos = getPlayerPosition(cid)
      if skill == 8 then
         doSendMagicEffect(ppos, CONST_ME_BIGCLOUDS)
         doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
         doPlayerAddMana(cid, getPlayerMaxMana(cid))
      end
      return TRUE
end

id doesn't work
could someone make script and test it by yourself? :( i'm trying to do this script from morning ;d
cr.xml
<event type="advance" name="Advance" script="advance.lua"/>
 
script.lua
Lua:
function onAdvance(cid, newLevel)
local playerPos = getCreaturePosition(cid)
    if newLevel == SKILL__LEVEL then
        doSendMagicEffect(playerPos, CONST_ME_BIGCLOUDS)
        doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
        doCreatureAddMana(cid, getCreatureMaxMana(cid))
    end
    return TRUE
end

login.lua
PHP:
registerCreatureEvent(cid, "NewLevel")

creaturescripts.xml
PHP:
<event type="advance" name="NewLevel" script="script.lua"/>
 
script.lua
Lua:
function onAdvance(cid, newLevel)
local playerPos = getCreaturePosition(cid)
    if newLevel == SKILL__LEVEL then
        doSendMagicEffect(playerPos, CONST_ME_BIGCLOUDS)
        doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
        doCreatureAddMana(cid, getCreatureMaxMana(cid))
    end
    return TRUE
end

login.lua
PHP:
registerCreatureEvent(cid, "NewLevel")

creaturescripts.xml
PHP:
<event type="advance" name="NewLevel" script="script.lua"/>

It works :thumbup:
++
 
Mine works too lol you just had to add this line in login.lua i tought you already knew that..

Lua:
registerCreatureEvent(cid, "ScriptName")
 
Back
Top Bottom