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

Creature gets healed when walking on a field

Moj mistrz

Monster Creator
Joined
Feb 1, 2008
Messages
932
Solutions
10
Reaction score
308
Location
Poland
Hello people. Like thread says. Is it possible to make creature gain health when walking on a fire field for example(but first it should also lose this 20 hp by fire ofc)?
Can it be made in creaturescripts? Does getTileItemById have something to do with it?
 
Movement script.

Example:
Code:
local health = 15

function onStepIn(cid, item, position, fromPosition)
    if isMonster(cid) == true and getCreatureName(cid) == "Fire Elemental" then
        doCreatureAddHealth(cid, health)
    end
    return true
end
 
Movement script.

Example:
Code:
local health = 15

function onStepIn(cid, item, position, fromPosition)
    if isMonster(cid) == true and getCreatureName(cid) == "Fire Elemental" then
        doCreatureAddHealth(cid, health)
    end
    return true
end
But how to add it to the movements not destroying original script?
Code:
<movevent event="StepIn" itemid="1487" function="onStepInField"/>
Its fire field event, but when I remove this or add something like that(#down) fire field wont damage any creature, but only add health.
Code:
<movevent event="StepIn" itemid="1487" function="onStepInField" script="monster heal.lua"/>
  <movevent event="StepIn" itemid="1487" script="monster heal.lua"/>
 
Code:
function onThink(cid)
local hp = getCreatureHealth(cid)
    addEvent(Teleport, 5000, cid)
    end
    end


function Teleport (cid)
    position = {fromx=92, fromy=114, tox=98, toy=120, z=7}
        for i = position.fromx, position.tox do
        for j = position.fromy, position.toy do
    local pos = {x=i, y=j, z=position.z, stackpos=253}
    local getThing = getThingfromPos(pos).uid
    doSummonCreature(cid, "Demon", isInArray(position))
    doCreatureAddHealth(cid, hp)
    doRemoveCreature(cid)
        end
      end
    return TRUE
end
I want this script to work like tp for monster, after 3 secs it removes monster from any position and respawns with hp it had(just before tp) on another position from table. It crashes server when executed.
 
Look at your code:
View attachment 24882
The functions aren't closed. You should download Notepad++
This will help you with scripting.

http://notepad-plus-plus.org/download/v6.5.5.html
Code:
function onThink(cid)
local hp = getCreatureHealth(cid)
    addEvent(Teleport, 5000, cid)
end

function Teleport (cid)
    position = {fromx=92, fromy=114, tox=98, toy=120, z=7}
        for i = position.fromx, position.tox do
        for j = position.fromy, position.toy do
    local pos = {x=i, y=j, z=position.z, stackpos=253}
    local getThing = getThingfromPos(pos).uid
    doSummonCreature(cid, "Demon", isInArray(position))
    doCreatureAddHealth(cid, hp)
    doRemoveCreature(cid)
    end
    end
    return TRUE
end
Well, I removed one 'end' and it still crashes.
 
Back
Top