viniciusturko
New Member
I have to do a script that have to count how much itens of id (Ex.: 1528), there is in the tile pos (x= 15 y= 15 z= 15)
Is there a function that count it?
Is there a function that count it?
function getTileItemCountByPos(pos, item)
local i = 0
for j = 1, 255 do
pos.stackpos = j
if getTileThingByPos(pos).itemid == item then
i = i + 1
end
end
return i
end
local position = {x=100, y=100, z=7}
local sword = 2395
doPlayerSendCancel(cid, 'There are '.. getTileItemCountByPos(position, sword)..' swords there.')
function getTileItemCountByPos(pos, item)
local i = 0
for j = 1, 255 do
pos.stackpos = j
if getTileThingByPos(pos).itemid == item then
i = i + 1
break
end
end
return i
end
function onStepIn(cid, item, pos)
if item.uid == 1586 then
if getTileItemCountByPos({x=1416, y=1041, z=7}, 2393) >= 3 then
doPlayerSendTextMessage(cid, 22, "You can plant here")
else
doPlayerSendTextMessage(cid, 22, "You can not plant here")
end
end
end
function getTileItemCountByPos(pos, item)
local i = 0
for j = 1, 255 do
pos.stackpos = j
if getTileThingByPos(pos).itemid == item then
i = i + 1
break
end
end
return i
end
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
if getTileItemCountByPos({x=1416, y=1041, z=7}, 2393) >= 3 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'You can plant here.')
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'You can not plant here.')
end
return true
end
function getTileItemCountByPos(pos, item)
local i = 0
for j = 1, 255 do
pos.stackpos = j
local thing = getTileThingByPos(pos).itemid
if thing == 0 then
break
elseif thing == item then
i = i + 1
end
end
return i
end
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
if getTileItemCountByPos({x=1416, y=1041, z=7}, 2393) >= 3 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'You can plant here.')
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'You can not plant here.')
end
return true
end