Blade33711
Member
I would like to create such a system. Can anyone tell me how to get started?
TFS 0.4
TFS 0.4
Last edited:
local function loop_1(loop_delay, loop_count)
print(loop_count)
if loop_count > 0 then
addEvent(loop_1, loop_delay, loop_count - 1)
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
addEvent(loop_1, 1000, 1000, 10)
return true
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local items = {8982, 2002, 2001, 2005, 2640, 9928, 2160}
local pos1 = {x = 1083, y = 1014, z = 7, stackpos=255}
local pos2 = {x = 1084, y = 1014, z = 7, stackpos=255}
local pos3 = {x = 1085, y = 1014, z = 7, stackpos=255}
if item.itemid == 9826 or item.itemid == 9825 and item.uid == 6431 then
doCreateItem(items[math.random(1, #items)], 1, pos1)
addEvent(function()
doCreateItem(getThingfromPos(pos1).itemid, 1, pos2)
doRemoveItem(getThingfromPos(pos1).uid, 1)
doCreateItem(items[math.random(1, #items)], 1, pos1)
end, 1*1000)
addEvent(function()
doCreateItem(getThingfromPos(pos2).itemid, 1, pos3)
doRemoveItem(getThingfromPos(pos2).uid, 1)
end, 2*1010)
addEvent(function()
doCreateItem(getThingfromPos(pos1).itemid, 1,pos2)
doRemoveItem(getThingfromPos(pos1).uid, 1)
doCreateItem(items[math.random(1, #items)], 1, pos1)
end, 2*1020)
end
return true
end
local function loop_1(loop_delay, loop_count)
print(loop_count)
if loop_count > 0 then
addEvent(loop_1, loop_delay, loop_count - 1)
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
addEvent(loop_1, 1000, 1000, 10)
return true
end
Instead of creating and removing items all over again, it's better to use doTransformItem.I have no idea for that
LUA:function onUse(cid, item, fromPosition, itemEx, toPosition) local items = {8982, 2002, 2001, 2005, 2640, 9928, 2160} local pos1 = {x = 1083, y = 1014, z = 7, stackpos=255} local pos2 = {x = 1084, y = 1014, z = 7, stackpos=255} local pos3 = {x = 1085, y = 1014, z = 7, stackpos=255} if item.itemid == 9826 or item.itemid == 9825 and item.uid == 6431 then doCreateItem(items[math.random(1, #items)], 1, pos1) addEvent(function() doCreateItem(getThingfromPos(pos1).itemid, 1, pos2) doRemoveItem(getThingfromPos(pos1).uid, 1) doCreateItem(items[math.random(1, #items)], 1, pos1) end, 1*1000) addEvent(function() doCreateItem(getThingfromPos(pos2).itemid, 1, pos3) doRemoveItem(getThingfromPos(pos2).uid, 1) end, 2*1010) addEvent(function() doCreateItem(getThingfromPos(pos1).itemid, 1,pos2) doRemoveItem(getThingfromPos(pos1).uid, 1) doCreateItem(items[math.random(1, #items)], 1, pos1) end, 2*1020) end return true end
How to do it in a loop?