function onUse(cid, item, frompos, item2, topos)
local pos = getPlayerPosition(cid)
monster = {x=pos.x+1, y=pos.y, z=pos.z}
monster2 = {x=pos.x, y=pos.y+1, z=pos.z}
if getTilePzInfo(pos) == FALSE then
if getTilePzInfo(monster) == FALSE then
if getTilePzInfo(monster2) == FALSE then
doSummonCreature("rat", monster)
doSummonCreature("rat", monster2)
else
doPlayerSendCancel(cid,"You cannot summon monster in Protection Zone.")
end
else
doPlayerSendCancel(cid,"You cannot summon monster in Protection Zone.")
end
else
doPlayerSendCancel(cid,"You cannot use this item when you're in a Protect Zone.")
end
return 1
end
<action itemid="[COLOR="Red"]xxxx[/COLOR]" event="script" value="summon.lua"/>
function onUse(cid, item, frompos, item2, topos)
local czas = 0
local tick = 1000
local function heal(i)
doCreatureAddHealth(cid, 1000)
doCreatureAddMana(cid, 1000)
end
if(czas == 0)then
addEvent(heal, 1000)
addEvent(heal, 2000)
addEvent(heal, 3000)
addEvent(heal, 4000)
addEvent(heal, 5000)
addEvent(heal, 6000)
addEvent(heal, 7000)
addEvent(heal, 8000)
addEvent(heal, 9000)
addEvent(heal, 10000)
addEvent(heal, 11000)
addEvent(heal, 12000)
addEvent(heal, 13000)
addEvent(heal, 14000)
addEvent(heal, 15000)
addEvent(heal, 16000)
addEvent(heal, 17000)
addEvent(heal, 18000)
addEvent(heal, 19000)
addEvent(heal, 20000)
czas = os.time()
end
if(os.time() <= 0)then
stopEvent(heal)
end
end
<action itemid="[COLOR="Red"]XXXX[/COLOR]" event="script" value="heal.lua"/>
local condition = createConditionObject(CONDITION_REGENERATION)
setConditionParam(condition, CONDITION_PARAM_SUBID, 4)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setConditionParam(condition, CONDITION_PARAM_TICKS, 20 * 1000)
for i = 4, 7 do
setConditionParam(condition, i, 1000)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
doAddCondition(cid, condition)
return true
end
[30/04/2010 16:06:58] [Error - Action Interface]
[30/04/2010 16:06:58] data/actions/scripts/testing.lua:onUse
[30/04/2010 16:06:58] Description:
[30/04/2010 16:06:58] (luaDoAddCondition) Creature not found
1.
But I made a script that when you use the item it doesn't remove(write when want to change it)
actions/scripts/summon.lua
LUA:function onUse(cid, item, frompos, item2, topos) local pos = getPlayerPosition(cid) monster = {x=pos.x+1, y=pos.y, z=pos.z} monster2 = {x=pos.x, y=pos.y+1, z=pos.z} if getTilePzInfo(pos) == FALSE then if getTilePzInfo(monster) == FALSE then if getTilePzInfo(monster2) == FALSE then doSummonCreature("rat", monster) doSummonCreature("rat", monster2) else doPlayerSendCancel(cid,"You cannot summon monster in Protection Zone.") end else doPlayerSendCancel(cid,"You cannot summon monster in Protection Zone.") end else doPlayerSendCancel(cid,"You cannot use this item when you're in a Protect Zone.") end return 1 end
actions/actions.xml
Write id of your itemCode:<action itemid="[COLOR="Red"]xxxx[/COLOR]" event="script" value="summon.lua"/>
[Tested on TFS 0.3.6]
function onUse(cid, item, frompos, item2, topos)
local pos = getPlayerPosition(cid)
if getTilePzInfo(pos) == FALSE then
for i = 1, 2 do
local monster_to_summon = doSummonCreature("rat", pos)
doConvinceCreature(cid, monster_to_summon)
end
doRemoveItem(item.uid, 1)
else
doPlayerSendCancel(cid, "You cannot use this item when you're in a Protect Zone.")
end
return true
end