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

Items drop on line

Na 5tyk

New Member
Joined
Sep 16, 2012
Messages
13
Reaction score
0
Hello. I have code:
Code:
    -- Rain item Events created by Maniucza (c) --
     
    local fromPos = {x=996, y=998, z=6}
    local toPos = {x=1004, y=998, z=6}
    local items = {{2667,1}, {2679,1}, {2671,1}, {2696,1}, {2689,1}}
    local maxItems = 20
     
    function isWalkable(pos, creature, proj, pz)
    if getTileThingByPos({x=pos.x,y=pos.y,z=pos.z}).itemid == 0 then return false end
    local n = not proj and 3 or 2
    for i = 0, 255 do
    pos.stackpos = i
    local tile = getTileThingByPos(pos)
    if tile.itemid ~= 0 and not isCreature(tile.uid) then
    if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
    return true
    end
    end
    end
    return true
    end
     
    function checkPositions(n)
	local pos = {x=math.random(fromPos.x,toPos.x), y=math.random(fromPos.y,toPos.y), z=math.random(fromPos.z,toPos.z)}    if isWalkable(pos, true, false, true) then
    return pos
    end
    return (checkPositions(n+1) or false)
    end

     
    function onSay(cid, words, param)
    doBroadcastMessage("Serek sie zaczal!", MESSAGE_EVENT_ADVANCE)
    return addEvent(spawnItem, 0, 1)
    end
     
    function spawnItem(created)
    if created >= maxItems then
    return doBroadcastMessage("", MESSAGE_EVENT_ADVANCE)
    end
    local itemPos, itemInf = checkPositions(1), math.random(#items)
    doCreateItem(items[itemInf][1], items[itemInf][2], itemPos)
    doSendMagicEffect(itemPos, CONST_ME_LOSEENERGY)
    return addEvent(spawnItem, 0, created+1)
    end
And I want to items drop in line but now drop random position (in line).

SS:
Good effect: (by me, no script)
46884496123844814950.jpg

Bad effect (by script, random postion):
97225658467608132701.jpg

_____
Sorry for my english. I'm from Poland ;].
 
Last edited:
LUA:
local fromPos = {x=996, y=998, z=6}
local toPos = {x=1004, y=998, z=6}
local items = {{2667,1}, {2679,1}, {2671,1}, {2696,1}, {2689,1}}
local maxItems = 20

function isWalkable(pos, creature, proj, pz)

	if getTileThingByPos({x=pos.x,y=pos.y,z=pos.z}).itemid == 0 then
		return false
	end
	local n = not proj and 3 or 2
	for i = 0, 255 do
		pos.stackpos = i
		local tile = getTileThingByPos(pos)
		if tile.itemid ~= 0 and not isCreature(tile.uid) then
			if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
				return true
			end
		end
	end
	return true
end

function checkPositions(n)
	local pos = {x=(fromPos.x + n), y=(fromPos.y), z=(fromPos.z)}
	if pos.x > toPos.x then
		return false
	elseif isWalkable(pos, true, false, true) then
		return pos
	end

	return (checkPositions(n+1) or false)
end

function spawnItem(created)
	if created >= maxItems then
		return doBroadcastMessage("", MESSAGE_EVENT_ADVANCE)
	end
	local itemPos, itemInf = checkPositions(1), math.random(#items)
	doCreateItem(items[itemInf][1], items[itemInf][2], itemPos)
	doSendMagicEffect(itemPos, CONST_ME_LOSEENERGY)

	return addEvent(spawnItem, 0, created+1)
end

function onSay(cid, words, param)
	doBroadcastMessage("Serek sie zaczal!", MESSAGE_EVENT_ADVANCE)

	return addEvent(spawnItem, 0, 1)
end
but this is a bad script
 
Back
Top