• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Remove and Create Items in positions after X seconds (ex. walls) after pull the lever

The_Hide

Banned User
Joined
Dec 11, 2012
Messages
389
Reaction score
10
You can add as many as u want items to remove, just edit "local c = {" adding;
[number] {item_id = , item_position = {x=,y=,z=}, count = , efekt_create = , efekt_remove = },

LUA:
local c = {
                        [1] = {item_id = 1025, item_position = {x=391,y=274,z=8}, count = 1, efekt_create = 25, efekt_remove = 13},
                        [2] = {item_id = 1025, item_position = {x=389,y=274,z=8}, count = 1, efekt_create = 25, efekt_remove = 13},
                        [3] = {item_id = 1025, item_position = {x=393,y=274,z=8}, count = 1, efekt_create = 25, efekt_remove = 13},
                        }
local time_to_create_items_again = 5 * 1000 --<-- 60 * 1000 = 60 seconds   5 * 1000 = 5 seconds
local removed_items_counter = 0
local created_items_counter = 0
	function create_items_after_time_function()
		for j = 1, #c do
			if not(getTileItemById(c[j].item_position, c[j].item_id).uid > 0) then
				created_items_counter = created_items_counter + 1
				doCreateItem(c[j].item_id, c[j].item_position)
				doSendMagicEffect(c[j].item_position, c[j].efekt_create)
			end
		end
		created_items_counter = 0
		return true
	end
	
	
function onUse(cid, item, fromPosition, itemEx, toPosition)

	if item.itemid == 1945 then 
		for i = 1, #c do
			if getTileItemById(c[i].item_position, c[i].item_id).uid > 0 then
				removed_items_counter = removed_items_counter + 1
				doRemoveThing(getTileItemById(c[i].item_position, c[i].item_id).uid, c[i].count)
				doSendMagicEffect(c[i].item_position, c[i].efekt_remove)
			end
		end
		doCreatureSay(cid, "You removed ".. removed_items_counter .." walls.  They will appear again within ".. time_to_create_items_again/1000 .." seconds.", TALKTYPE_MONSTER)
		doTransformItem(item.uid, 1946)
		our_event_name = addEvent(create_items_after_time_function, time_to_create_items_again)
	elseif item.itemid == 1946 then 
		for k = 1, #c do
			if not(getTileItemById(c[k].item_position, c[k].item_id).uid > 0) then
				created_items_counter = created_items_counter + 1
				doCreateItem(c[k].item_id, c[k].item_position)
				doSendMagicEffect(c[k].item_position, c[k].efekt_create)
			end
		end
		doCreatureSay(cid, "You created ".. created_items_counter .." walls.", TALKTYPE_MONSTER)
		doTransformItem(item.uid, 1945)
		stopEvent(our_event_name)
	end
	created_items_counter = 0
	removed_items_counter = 0
	return true
end
 
Can you add couple of things?
Would be great if lever returned to it's original position else it will be saying "You created 0 walls"
Also it would be great if walls didn't appear on player if he is blocking the way, correct way would be pushing/releporting the player away from the spot when walls reappear.
 
it's so easy to add looool

check is player on wall position --> if is then --> teleport him to pos x+1 or y+1 or y-1 or x -1 or.. etc.
 
then please add it

ok, here:

LUA:
creature_on_wall_position = getTopCreature(c[j].item_position).uid
	creatures_to_teleport_tbl = {}
	if creature_on_wall_position ~= 0 then
		if isMonster(creature_on_wall_position) or isPlayer(creature_on_wall_position) then
			table.insert(creatures_to_teleport_tbl, creature_on_wall_position)
		end
		for q=1, #creatures_to_teleport_tbl do
			doTeleportThing(creatures_to_teleport_tbl[q], {x=c[j].item_position.x, y=c[j].item_position.y -1, z=c[j].item_position.z)
		end
	end
 
Back
Top