Hey guys,
I am beginner at Lua, and I have problem while compiling these 2 scripts. Would you help me rewrite them to working form?
1. This one works only on tiles of lava on which players can walk. The more tiles player walked, the more damage he will take. This effect should disappear after 3 minutes. I mean if player takes 600 dmg on this tile, after 3 min he will take basis damage (100). And I also want this timer to reset every time player walks on a tile with same ID.
2. In second one there are 3 different tiles. The problem is arithmetic method. I don't know how to write it correctly.
I am beginner at Lua, and I have problem while compiling these 2 scripts. Would you help me rewrite them to working form?
1. This one works only on tiles of lava on which players can walk. The more tiles player walked, the more damage he will take. This effect should disappear after 3 minutes. I mean if player takes 600 dmg on this tile, after 3 min he will take basis damage (100). And I also want this timer to reset every time player walks on a tile with same ID.
Lua:
function onStepIn(cid, item, position)
local ppos = getCreaturePosition(cid)
local dmg = 100 * (getPlayerStorageValue(cid,3600))
if isPlayer(cid) then
doSendMagicEffect(ppos,15)
doAddCondition(cid,3)
if getPlayerStorageValue(cid,3600) <= 0 then
setPlayerStorageValue(cid,3600,1)
addEvent(setPlayerStorageValue,3*60*1000,cid,3600,0)
elseif getPlayerStorageValue(cid,3600) >= 1 then
setPlayerStorageValue(cid,3600,(getPlayerStorageValue(cid,3600)+1))
stopEvent(setPlayerStorageValue)
addEvent(setPlayerStorageValue,3*60*1000,cid,3600,0)
end
doSendAnimatedText(ppos,HERE_SHOULD_BE_THIS_DAMAGE, 192)
doCreatureAddHealth(cid, -(dmg))
end
return TRUE
end
Lua:
local hp = getCreatureHealth(cid)
local mp = getCreatureMana(cid)
local php = 0.99 * hp
local pmp = 0.99 * mp
local pstorage = getPlayerStorageValue(cid,20203)
function onStep (cid, item, postion)
local ppos = getCreaturePosition(cid)
if item.aid == 20200 then
if getPlayerStorageValue(cid,20200) == -1 then
setPlayerStorageValue(cid, 20200,1)
setPlayerStorageValue(cid, 20203,pstorage+1)
doCreatureAddHealth(cid,-php)
doCreatureAddMana(cid,-pmp)
doSendMagicEffect(ppos, 63)
end
elseif item.aid == 20201 then
if getPlayerStorageValue(cid,20201) == -1 then
setPlayerStorageValue(cid, 20201,1)
setPlayerStorageValue(cid, 20203,pstorage+1)
doCreatureAddHealth(cid,-php)
doCreatureAddMana(cid,-pmp)
doSendMagicEffect(ppos, 63)
end
elseif item.aid == 20202 then
if getPlayerStorageValue(cid,20202) == -1 then
setPlayerStorageValue(cid, 20202,1)
setPlayerStorageValue(cid, 20203,pstorage+1)
doCreatureAddHealth(cid,-php)
doCreatureAddMana(cid,-pmp)
doSendMagicEffect(ppos, 63)
end
end
end